@svgsketch/core 2.3.0 → 3.0.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,20 +1,84 @@
1
- "use strict";var ji=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var pu=Object.getOwnPropertyNames;var mu=Object.prototype.hasOwnProperty;var hu=(n,e)=>{for(var t in e)ji(n,t,{get:e[t],enumerable:!0})},gu=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pu(e))!mu.call(n,i)&&i!==t&&ji(n,i,{get:()=>e[i],enumerable:!(r=fu(e,i))||r.enumerable});return n};var yu=n=>gu(ji({},"__esModule",{value:!0}),n);var zp={};hu(zp,{Arrow:()=>Ri,Audio:()=>Gi,BUILTIN_MARKER_ID_MAP:()=>Ls,COLLAB_PROTOCOL_VERSION:()=>zo,COMMON_PROP_DEFAULTS:()=>J,COMMON_TRANSFORM_NODE_DEFAULTS:()=>qi,CURRENT_SCHEMA_VERSION:()=>xe,Circle:()=>hi,Cloud:()=>Mi,Container:()=>Ei,ContainerShapeBuilder:()=>tt,Cross:()=>Ti,DEFAULT_COORDINATE_PRECISION:()=>rl,DEFAULT_RICH_TEXT_STYLE:()=>Xt,Document:()=>wn,DocumentBuilder:()=>wn,EASING_CURVES:()=>Cn,EasingType:()=>Mn,Ellipse:()=>gi,Gear:()=>_i,Heart:()=>Ai,Hyperlink:()=>Di,IDENTITY_AFFINE:()=>rn,ImageShape:()=>Wi,KNOWN_STATE_KEYS:()=>Qi,LIBRARY_EMIT_ORDER:()=>Zs,Lightning:()=>Ii,Line:()=>Si,LinearGradientBuilder:()=>Pn,MARKER_HEIGHT:()=>Nr,MARKER_VIEWBOX:()=>Sn,MARKER_WIDTH:()=>Lr,MAX_COORDINATE_PRECISION:()=>il,MIGRATIONS:()=>_s,NGon:()=>vi,NON_WIRE_PROP_KEYS:()=>Fa,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>Bt,NestedSvg:()=>Li,NodeSchemaRegistry:()=>Wt,PUZZLE_DEFAULTS:()=>ya,Path:()=>Vi,PathCurveType:()=>Ki,PathPointType:()=>Aa,PatternBuilder:()=>Rn,Polyline:()=>Ui,RICH_TEXT_STYLE_KEYS:()=>vt,RadialGradientBuilder:()=>_n,Rectangle:()=>yi,Ring:()=>wi,SERIALIZED_SHAPE_STATE_KEYS:()=>Xi,SHAPE_TRANSFORM_STATE_KEYS:()=>Yi,SceneGraph:()=>Nn,SceneNode:()=>Be,ShapeBuilder:()=>ae,ShapeReference:()=>Ni,SpeechBubble:()=>Ci,Spiral:()=>Pi,Square:()=>bi,Star:()=>ki,Switch:()=>Fi,Text:()=>xi,Timeline:()=>mi,Track:()=>pi,Triangle:()=>$i,Video:()=>zi,View:()=>Oi,affine:()=>We,affineFromArray:()=>rr,affineToArray:()=>Ye,almostEqualAffine:()=>rc,applyAffineToPoint:()=>sc,applyAffineToVector:()=>ac,applyOpToSnapshot:()=>Do,applyOpsInPlace:()=>bs,applyOpsToSnapshot:()=>Fo,applyOpsToSnapshotWithAccepted:()=>Ss,applyRichTextFormat:()=>qt,applyTextSplice:()=>no,applyTextTransform:()=>xn,arcEndpointToCenter:()=>pa,areTracksTimingEquivalent:()=>ua,around:()=>vs,buildCompoundTransformValues:()=>Qr,buildSmilKeyframeData:()=>et,canonicalPolygonTransformString:()=>Ts,canonicalTransformString:()=>At,collaborationResourceKey:()=>us,collectMarkerReferences:()=>yn,collectReferencedLibraryDefs:()=>vn,collectReferencedMarkerIds:()=>yl,compareOrderKeys:()=>Ut,composeLegacyTransformMatrix:()=>ln,computeArrowVertices:()=>$r,computeCloudPath:()=>wr,computeCrossVertices:()=>xr,computeDashArray:()=>Mt,computeFlowchartBoxPath:()=>Ir,computeGearPath:()=>Rr,computeGearVertices:()=>Ds,computeHeartPath:()=>Tr,computeLightningVertices:()=>kr,computePolygonVertices:()=>mn,computeRectanglePath:()=>Ar,computeRingPath:()=>Pr,computeSpeechBubbleVertices:()=>vr,computeSpiralPath:()=>_r,computeSplinePath:()=>qe,computeStarVertices:()=>Sr,createDocument:()=>lr,createSceneNode:()=>rt,createShape:()=>tl,createViewbox:()=>fn,createWordSearchPrimitiveMask:()=>du,cubicBezierExtent1D:()=>si,customPatternDefToLibraryDef:()=>Ue,declaredRichTextDeltaKeys:()=>Xn,decomposeAffine2D:()=>Ac,defaultVariableMode:()=>Su,deriveRichTextFormatRanges:()=>uo,deriveSegments:()=>Ve,deriveTextSplice:()=>to,downTranslateAnimationKeyframeOps:()=>Lo,downTranslateCollectionMoveOps:()=>Bo,downTranslateDocumentFieldOps:()=>Go,downTranslateScenePlaceOps:()=>Oo,downTranslateTextFormatOps:()=>No,ellipticalArcBounds:()=>ma,escXml:()=>Y,extractVariables:()=>hr,filterAttr:()=>Er,findShapeById:()=>ct,flattenShapeStateTree:()=>Ht,flattenStateExtra:()=>Ne,foldLegacyAncestorTransformIntoMatrix:()=>ks,forEachLibraryRefInState:()=>gl,forEachMarkerRefInState:()=>hl,forEachReachableShape:()=>gn,forEachShapeInLibraryDefs:()=>ml,formatOperationValidationIssues:()=>eo,formatSmilKeySpline:()=>Wr,formatSmilKeyTime:()=>be,freezeSiblingOrderKeys:()=>tn,generateCode:()=>fi,generateCssCode:()=>di,generateD3Code:()=>ci,generateId:()=>_,generatePatternSvgContent:()=>Or,generatePuzzlePieces:()=>Hl,generateReactCode:()=>li,generateSudokuPuzzle:()=>nu,generateSvgCode:()=>oi,generateVueCode:()=>ui,generateWordSearch:()=>cu,getBuiltInMarkerDefs:()=>bl,getEasingCubicBezier:()=>bu,getEffectivePrecision:()=>sl,getKeyframeCubicBezier:()=>sa,getMarkerDescriptors:()=>pt,getPatternElements:()=>bn,getSmilAdditive:()=>qr,getSmilBeginValue:()=>mt,getSmilFillMode:()=>ht,getSmilMotionKeyPoints:()=>Zr,getSmilRepeatCount:()=>Yr,getSmilSetBeginValue:()=>Xr,getSmilTrackDuration:()=>Qe,getWordSearchDirections:()=>ka,initialOrderKeys:()=>On,invertAffine:()=>ic,isDefaultKeyPoints:()=>Hr,isDefaultKeyTimes:()=>kn,isFiniteAffineArray:()=>_t,isIdentityAffine:()=>$s,isIdentityLinearSplines:()=>la,isIndefiniteSetTrack:()=>jr,isReusablePatternTile:()=>Zt,isSetSequenceTrack:()=>Kr,isValidOrderKey:()=>Vt,keyBetween:()=>bt,keysBetween:()=>En,legacyEndpointMarkerId:()=>hn,linearGradient:()=>Nl,lintWordSearchOptions:()=>Ta,materializeSceneTreeOrderKeys:()=>Eo,matrixTransformPart:()=>xs,maxCollaborationTimestamp:()=>So,mergeRichTextStyle:()=>jn,migrateSnapshot:()=>ar,moveResourceById:()=>er,multiplyAffine:()=>ne,nodeSchemas:()=>O,normalizeRichTextRuns:()=>st,normalizeRichTextStyle:()=>Ce,normalizeRichTextStyleDelta:()=>Yt,orderSiblings:()=>Pe,parseDocument:()=>cr,parseSvgTransformList:()=>ir,parseVariableArgs:()=>nl,parseWordSearchWords:()=>lu,partitionShapeStateTree:()=>nt,partitionStateExtra:()=>Ln,pathDataBounds:()=>ga,pattern:()=>zl,patternLibraryDefToCustomPatternDef:()=>kt,patternTileSize:()=>as,planTransformFusion:()=>Jr,projectSceneTreeOntoClipMaskGroups:()=>Tt,projectSceneTreeOntoShapes:()=>gs,promoteRebasedShapeUpdateClock:()=>xo,quadraticBezierExtent1D:()=>ai,radialGradient:()=>Bl,rebaseRichTextFormatRanges:()=>lo,rebaseRichTextRuns:()=>co,reflectCubicBezier:()=>oa,removeResourceById:()=>ye,removeResourceByKey:()=>Un,removeResourceByName:()=>Hn,removeTrackKeyframe:()=>hs,renderAnimationElements:()=>ni,renderBuiltinMarkerDefs:()=>Ee,renderCircle:()=>zs,renderEllipse:()=>Gs,renderFilterDefs:()=>fl,renderFilterLibraryDef:()=>ia,renderFilterPrimitive:()=>Fr,renderFilterPrimitivesForType:()=>Es,renderFlowchartBox:()=>Ys,renderImage:()=>Ks,renderLibraryDef:()=>Js,renderLibraryDefs:()=>$n,renderLine:()=>Us,renderLinearGradientLibraryDef:()=>ta,renderMarkerLibraryDef:()=>ea,renderPatternLibraryDef:()=>ra,renderPolygonShape:()=>qs,renderPolyline:()=>js,renderRadialGradientLibraryDef:()=>na,renderRectangle:()=>Vs,renderReferencedLibraryDefs:()=>Ze,renderShape:()=>de,renderSpline:()=>Hs,renderSvgPrimitiveChainFilter:()=>Fs,renderSymbolInstance:()=>Xs,renderSymbolLibraryDef:()=>Qs,renderText:()=>Ws,renderToSvg:()=>Et,resolveRichTextStyleAt:()=>oo,resolveSymbolInstanceShapes:()=>Br,rewriteDocumentEmbeddedPayloads:()=>Jo,rewriteShapeStateEmbeddedPayloads:()=>or,richTextFontVariantCss:()=>Dt,richTextLineSpans:()=>is,richTextRunsFromState:()=>Zn,richTextStyleDelta:()=>Kn,richTextStyleDeltasEqual:()=>qn,richTextStylesEqual:()=>Yn,richTextTspanAttributes:()=>zr,rotateAffine:()=>Rt,roundCoord:()=>yr,roundNumberString:()=>Is,roundSerializedShape:()=>gr,roundSnapshot:()=>al,runsFromSegments:()=>at,sanitizeRichTextFormatRanges:()=>Jn,scaleAffine:()=>sn,senderCorrectionsForOp:()=>Mo,skewXAffine:()=>an,skewYAffine:()=>on,smilKeyframeAttributes:()=>Tn,solveCubicBezier:()=>aa,solveSudoku:()=>In,splinePathBounds:()=>Dl,stringifyDocument:()=>ur,substituteString:()=>dr,substituteVariables:()=>mr,symbolInstanceTargetId:()=>Ct,transformSplice:()=>Kt,translateAffine:()=>_e,tryParseSvgTransformList:()=>Ko,upsertResourceById:()=>ge,upsertResourceByKey:()=>Vn,upsertResourceByName:()=>Wn,upsertTrackKeyframe:()=>ms,validateDocumentOperations:()=>Ja,validateOperation:()=>Gn,validatePresenceOperation:()=>Qa,validateSnapshot:()=>dn,validateSudokuPuzzle:()=>tu,verticesToPath:()=>Ae});module.exports=yu(zp);var Mn=(C=>(C.LINEAR="linear",C.EASE="ease",C.EASE_IN="ease-in",C.EASE_OUT="ease-out",C.EASE_IN_OUT="ease-in-out",C.EASE_IN_QUAD="ease-in-quad",C.EASE_OUT_QUAD="ease-out-quad",C.EASE_IN_OUT_QUAD="ease-in-out-quad",C.EASE_IN_CUBIC="ease-in-cubic",C.EASE_OUT_CUBIC="ease-out-cubic",C.EASE_IN_OUT_CUBIC="ease-in-out-cubic",C.EASE_IN_QUART="ease-in-quart",C.EASE_OUT_QUART="ease-out-quart",C.EASE_IN_OUT_QUART="ease-in-out-quart",C.EASE_IN_SINE="ease-in-sine",C.EASE_OUT_SINE="ease-out-sine",C.EASE_IN_OUT_SINE="ease-in-out-sine",C.EASE_IN_QUINT="ease-in-quint",C.EASE_OUT_QUINT="ease-out-quint",C.EASE_IN_OUT_QUINT="ease-in-out-quint",C.EASE_IN_EXPO="ease-in-expo",C.EASE_OUT_EXPO="ease-out-expo",C.EASE_IN_OUT_EXPO="ease-in-out-expo",C.EASE_IN_CIRC="ease-in-circ",C.EASE_OUT_CIRC="ease-out-circ",C.EASE_IN_OUT_CIRC="ease-in-out-circ",C.EASE_IN_BACK="ease-in-back",C.EASE_OUT_BACK="ease-out-back",C.EASE_IN_OUT_BACK="ease-in-out-back",C.CUSTOM_BEZIER="custom-bezier",C.LINEAR_FUNCTION="linear-function",C.STEPS="steps",C))(Mn||{}),Cn={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 bu(n){let e=Cn[n];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var Ki=(a=>(a.LINEAR="linear",a.QUADRATIC="quadratic",a.CUBIC="cubic",a.CATMULL_ROM="catmull-rom",a.ARC="arc",a.BASIS="basis",a.MIXED="mixed",a))(Ki||{}),Aa=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(Aa||{});function Su(n){return n==="color"?"live":"stamped"}var Xi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform","ancestorTransform","layerName","fillColor","borderColor","borderWidth","opacity","fillOpacity","strokeOpacity","locked","visible","fillType","fillGradient","strokeType","strokeGradient","fillRule","strokeLinejoin","strokeLinecap","strokeMiterlimit","lineStyle","dashLength","gapLength","dashOffset","strokeDasharray","colorInterpolation","filters","filterColorInterpolation","filterUnits","primitiveUnits","filterX","filterY","filterWidth","filterHeight","metadata","cssClipPath","cssMaskProperties","groupId","structural","displayMode","display","visibility","inheritFill","inheritStroke","preserveFillOpacity","preserveStrokeOpacity","fillLibraryId","strokeLibraryId","filterLibraryIds","fillRuleExplicit","paintOrder","vectorEffect","transformBox","pathLength","markerStart","markerMid","markerEnd","blendMode","shapeRendering","textRendering","imageRendering","colorRendering","systemLanguage","requiredExtensions","inlineStyle","authoredAttributes","bindings","scripts","lastSolidFillColor","lastSolidStrokeColor","connectionPoints","isRootSvg","x","y","width","height","rx","ry","cornerRadius","cornerShape","cornerMode","cornerRadiusTL","cornerRadiusTR","cornerRadiusBL","cornerRadiusBR","cornerShapeTL","cornerShapeTR","cornerShapeBL","cornerShapeBR","size","radius","cx","cy","shiftAngle","x1","y1","x2","y2","startEndpoint","endEndpoint","routingMode","sourceRef","targetRef","sourcePoint","targetPoint","waypoints","label","labelPosition","labelOffset","mermaidEdgeStyle","textX","textY","fontSize","text","fontFamily","fontWeight","fontStyle","fontVariant","fontVariantLigatures","fontVariantPosition","fontVariantCaps","fontVariantNumeric","fontVariantEastAsian","textDecoration","textTransform","baselineShift","dominantBaseline","writingMode","textAnchor","letterSpacing","wordSpacing","lineHeight","inlineSize","overflowWrap","whiteSpace","textDirection","unicodeBidi","useRichText","richTextRuns","richTextData","charOffsets","fontVariationSettings","linePositions","textLength","lengthAdjust","shapeInsideRef","shapePadding","isTextPath","textPathPoints","textPathStartOffset","textPathStartOffsetUnit","textPathSide","textPathMethod","textPathSpacing","textPathLengthAdjust","textPathLength","textPathLengthUnit","textPathPathLength","textPathCurveType","textPathInlineFormat","textPathRefShapeId","textPathImportRefId","href","originalWidth","originalHeight","preserveAspectRatio","specPreserveAspectRatio","imageOpacity","pathPoints","pathArcParams","pathControlBounds","pathCurveType","pathClosed","pathTension","polylinePoints","polylineClosed","sides","arms","innerRadiusPercent","armWidthPercent","turns","thicknessPercent","spiralDirection","teeth","toothDepthPercent","holeRadiusPercent","headWidthPercent","headLengthPercent","shaftWidthPercent","tailAngleDeg","tailLengthPercent","tailWidthPercent","lobeRadiusPercent","cleftDepthPercent","boltSegments","boltJaggednessPercent","boltWidthPercent","cloudBumps","cloudPuffinessPercent","slantPercent","topWidthPercent","capHeightPercent","waveAmplitudePercent","symbolId","symbolOverrides","variantKey","instancePresentation","scaleContentToViewport","groupData","mediaKind","mediaMimeType","naturalDuration","begin","trimStart","trimEnd","volume","muted","loop","playbackRate","mediaOpacity","fadeInDuration","fadeOutDuration","posterHref","sourceRect","hrefXlink","linkTarget","linkRel","linkDownload","linkPing","linkHreflang","linkType","linkReferrerPolicy","containerPresentation","targetShapeId","offsetX","offsetY","targetWidth","targetHeight","broken","switchSystemLanguage","switchRequiredExtensions","svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio","viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight","viewName","viewPreserveAspectRatio","viewZoomAndPan","viewTarget","isHomeView","children","viewLinkedSvgId"],xe=6;var Yi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],Bt=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],qi={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Oe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Fn=Oe.length,Le=Oe[0],Ia=Oe[Fn-1],Ca=Oe[Math.floor(Fn/2)],Zi=97,xu=122;function yt(n){let e=Oe.indexOf(n);if(e===-1)throw new Error(`order-key: invalid digit '${n}'`);return e}function $u(n){let e=n.charCodeAt(0);if(e<Zi||e>xu)throw new Error(`order-key: invalid head '${n}'`);return e-Zi+1}function Ke(n){if(n<1||n>26)throw new Error(`order-key: integer length ${n} out of range`);return String.fromCharCode(Zi+n-1)}function zt(n){let e=$u(n[0]);if(n.length<1+e)throw new Error(`order-key: '${n}' shorter than its integer part`);let t=n.slice(1,1+e),r=n.slice(1+e);for(let i of t)yt(i);for(let i of r)yt(i);return{integer:t,fraction:r}}function Dn(n){for(let e of n)if(e!==Le)return!1;return!0}function Vt(n){if(n.length===0)return!1;try{let{integer:e,fraction:t}=zt(n);return!(t.endsWith(Le)||Dn(e)&&t.length===0||e.length>1&&e[0]===Le)}catch{return!1}}function Ma(n,e){if(!Vt(n))throw new Error(`order-key: invalid ${e} '${n}'`)}function Ut(n,e){return n<e?-1:n>e?1:0}function vu(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=yt(e[t]);if(r<Fn-1){e[t]=Oe[r+1];for(let i=t+1;i<e.length;i++)e[i]=Le;return e.join("")}}return null}function Ji(n){let{integer:e}=zt(n),t=vu(e);if(t!==null)return Ke(e.length)+t;let r="1"+Le.repeat(e.length);return Ke(r.length)+r}function ku(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=yt(e[t]);if(r>0){e[t]=Oe[r-1];for(let i=t+1;i<e.length;i++)e[i]=Ia;return e.join("")}e[t]=Ia}throw new Error(`order-key: cannot decrement zero integer '${n}'`)}function Tu(n){let e=0;for(;e<n.length-1&&n[e]===Le;)e++;return n.slice(e)}function wu(n){let{integer:e,fraction:t}=zt(n);if(!Dn(e)){let r=ku(e);if(!Dn(r)){let i=Tu(r);return Ke(i.length)+i}return Ke(1)+Le+Ca}return Ke(1)+Le+Gt("",t)}function Gt(n,e){if(e!==null){if(e.length===0||n>=e)throw new Error(`order-key: fraction bounds out of order ('${n}' >= '${e}')`);let i=0;for(;i<e.length&&(n[i]??Le)===e[i];)i++;if(i>0)return e.slice(0,i)+Gt(n.slice(i),e.slice(i))}let t=n.length>0?yt(n[0]):0,r=e!==null?yt(e[0]):Fn;return r-t>1?Oe[Math.floor((t+r)/2)]:Oe[t]+Gt(n.slice(1),null)}function bt(n,e){if(n!==null&&Ma(n,"lower bound"),e!==null&&Ma(e,"upper bound"),n!==null&&e!==null&&n>=e)throw new Error(`order-key: bounds out of order ('${n}' >= '${e}')`);if(n===null&&e===null)return Ke(1)+"1";if(n===null)return wu(e);if(e===null)return Ji(n);let t=zt(n),r=zt(e),i=Ke(t.integer.length)+t.integer,s=Ke(r.integer.length)+r.integer;if(i===s)return i+Gt(t.fraction,r.fraction);let o=Ji(i+(Dn(t.integer)?Ca:""));return Ut(o,e)<0?o:i+Gt(t.fraction,null)}function En(n,e,t){if(t<=0)return[];let r=[],i=n;for(let s=0;s<t;s++){let o=bt(i,e);r.push(o),i=o}return r}function On(n){if(n<=0)return[];let e=[],t=bt(null,null);e.push(t);for(let r=1;r<n;r++)t=Ji(t),e.push(t);return e}var Wt=class{schemas=new Map;register(e,t){this.schemas.set(e,t)}get(e){return this.schemas.get(e)}typeIds(){return[...this.schemas.keys()]}getDefaults(e){let t=this.schemas.get(e);if(!t)return{};let r={};for(let i of Object.keys(t))r[i]=t[i].default;return r}validate(e,t,r){let i=this.schemas.get(e);if(!i)return r;let s=i[t];return s?.validate?s.validate(r):r}},E=n=>Math.max(0,n),St=n=>Math.max(0,Math.min(1,n)),te=n=>Math.max(0,Math.min(100,n)),Pu=n=>Math.max(1,n),_u=n=>Math.max(3,Math.min(100,Math.floor(n))),Ru=n=>Math.max(3,Math.min(50,Math.floor(n))),Au=n=>Math.max(3,Math.min(30,Math.floor(n))),Iu=n=>Math.max(1,Math.min(10,n));function Mu(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{default:t}]))}var Cu=Mu(qi),J={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:St},fillOpacity:{default:1,validate:St},strokeOpacity:{default:1,validate:St},...Cu,locked:{default:!1},visible:{default:!0},fillType:{default:"solid"},fillGradient:{default:null},strokeType:{default:"solid"},strokeGradient:{default:null},fillRule:{default:"nonzero"},strokeLinejoin:{default:"miter"},strokeLinecap:{default:"butt"},strokeMiterlimit:{default:4,validate:Pu},lineStyle:{default:"solid"},dashLength:{default:8},gapLength:{default:4},dashOffset:{default:0},strokeDasharray:{default:null},colorInterpolation:{default:null},filters:{default:[]},filterColorInterpolation:{default:null},filterUnits:{default:null},primitiveUnits:{default:null},filterX:{default:null},filterY:{default:null},filterWidth:{default:null},filterHeight:{default:null},metadata:{default:null},cssClipPath:{default:null},cssMaskProperties:{default:null},groupId:{default:null}},ke={...J,cx:{default:0},cy:{default:0},radius:{default:50,validate:E},cornerRadius:{default:0,validate:E},shiftAngle:{default:0}},xt={...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:60,validate:E}},Da={...J,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},href:{default:""},mediaMimeType:{default:""},originalWidth:{default:0},originalHeight:{default:0},naturalDuration:{default:0},preserveAspectRatio:{default:!0},begin:{default:0},trimStart:{default:0},volume:{default:1,validate:St},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:St},fadeInDuration:{default:0,validate:E},fadeOutDuration:{default:0,validate:E},posterHref:{default:""},sourceRect:{default:null}},O=new Wt;O.register("rectangle",{...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},rx:{default:0,validate:E},ry:{default:0,validate:E},cornerRadius:{default:0,validate:E},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:E},cornerRadiusTR:{default:0,validate:E},cornerRadiusBL:{default:0,validate:E},cornerRadiusBR:{default:0,validate:E},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});O.register("square",{...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},rx:{default:0,validate:E},ry:{default:0,validate:E},cornerRadius:{default:0,validate:E},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:E},cornerRadiusTR:{default:0,validate:E},cornerRadiusBL:{default:0,validate:E},cornerRadiusBR:{default:0,validate:E},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});O.register("circle",{...J,x:{default:0},y:{default:0},radius:{default:50,validate:E}});O.register("ellipse",{...J,cx:{default:0},cy:{default:0},rx:{default:50,validate:E},ry:{default:30,validate:E}});O.register("line",{...J,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("text",{...J,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},richTextData:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},shapeInsideRef:{default:null},shapePadding:{default:0}});O.register("image",{...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:St}});O.register("path",{...J,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("polyline",{...J,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},polylinePoints:{default:[]},polylineClosed:{default:!1}});O.register("triangle",{...ke,sides:{default:3}});O.register("ngon",{...ke,sides:{default:6,validate:_u}});O.register("star",{...ke,arms:{default:5,validate:Ru},innerRadiusPercent:{default:40,validate:te}});O.register("cross",{...ke,armWidthPercent:{default:30,validate:te}});O.register("ring",{...ke,innerRadiusPercent:{default:50,validate:te}});O.register("spiral",{...ke,turns:{default:3,validate:Iu},thicknessPercent:{default:15,validate:te},spiralDirection:{default:1}});O.register("gear",{...ke,teeth:{default:8,validate:Au},toothDepthPercent:{default:25,validate:te},holeRadiusPercent:{default:20,validate:te}});O.register("arrow",{...ke,headWidthPercent:{default:100,validate:te},headLengthPercent:{default:40,validate:te},shaftWidthPercent:{default:40,validate:te}});O.register("symbol-instance",{...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},symbolId:{default:""}});O.register("group",{...J,groupId:{default:null}});O.register("cloud",{...ke,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:te}});O.register("heart",{...ke,lobeRadiusPercent:{default:50,validate:te},cleftDepthPercent:{default:25,validate:te}});O.register("lightning",{...ke,boltSegments:{default:3},boltWidthPercent:{default:30,validate:te},boltJaggednessPercent:{default:40,validate:te}});O.register("speechBubble",{...ke,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:te},tailWidthPercent:{default:25,validate:te}});O.register("diamond",{...xt});O.register("parallelogram",{...xt,slantPercent:{default:20,validate:te}});O.register("trapezoid",{...xt,topWidthPercent:{default:70,validate:te}});O.register("terminator",{...xt});O.register("cylinder",{...xt,capHeightPercent:{default:15,validate:te}});O.register("document-shape",{...xt,waveAmplitudePercent:{default:15,validate:te}});O.register("hyperlink",{...J,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});O.register("switch",{...J,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});O.register("svg",{...J,svgX:{default:0},svgY:{default:0},svgWidth:{default:0,validate:E},svgHeight:{default:0,validate:E},svgViewBoxX:{default:0},svgViewBoxY:{default:0},svgViewBoxWidth:{default:0,validate:E},svgViewBoxHeight:{default:0,validate:E},svgPreserveAspectRatio:{default:""}});O.register("view",{...J,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:E},viewBoxHeight:{default:0,validate:E},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});O.register("shape-reference",{...J,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:E},targetHeight:{default:0,validate:E},broken:{default:!1}});O.register("video",{...Da,mediaKind:{default:"video"}});O.register("audio",{...Da,mediaKind:{default:"audio"}});O.register("document",{});function Du(){let n=new Set(Xi);for(let e of Yi)n.add(e);for(let e of O.typeIds())for(let t of Object.keys(O.getDefaults(e)))n.add(t);return n.delete("scaleAnchor"),n.delete("extra"),n}var Qi=Du(),Fa=new Set(["scaleAnchor","displayAttr"]);function Ln(n){let e=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:void 0;for(let t of Object.keys(n)){if(t==="extra"||Qi.has(t))continue;let r=n[t];delete n[t],r!==void 0&&((e??={})[t]=r)}return e&&Object.keys(e).length>0?n.extra=e:delete n.extra,n}function nt(n){if(!n?.state||typeof n.state!="object")return n;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)nt(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))i&&typeof i=="object"&&!Array.isArray(i)&&Ln(i);return Ln(e),n}function Ht(n){if(!n?.state||typeof n.state!="object")return n;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)Ht(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))i&&typeof i=="object"&&!Array.isArray(i)&&Ne(i);return Ne(e),n}function Ne(n){let e=n.extra;if(!e||typeof e!="object"||Array.isArray(e))return delete n.extra,n;for(let[t,r]of Object.entries(e))t!=="extra"&&(t in n||(n[t]=r));return delete n.extra,n}function rt(n,e,t,r="verbatim"){if(r==="verbatim")return new Be(n,e,t&&"extra"in t?Ne({...t}):t);let i={...O.getDefaults(e),...t},s=O.get(e);if(s)for(let o of Object.keys(i)){let a=s[o];a?.validate&&i[o]!==void 0&&(i[o]=a.validate(i[o]))}return new Be(n,e,i)}var Be=class n{static writeHook=null;static _baseReadDepth=0;static withBaseProps(e){n._baseReadDepth++;try{return e()}finally{n._baseReadDepth--}}id;type;parent=null;children=[];onChange=null;_props;_dirty=new Set;_overlay=null;_propTimestamps=new Map;constructor(e,t,r){this.id=e,this.type=t,this._props=r?{...r}:{}}get(e){return this._overlay!==null&&n._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}set(e,t){this._props[e]!==t&&(n.writeHook?.(this,e),this._props[e]=t,this._dirty.add(e),this.onChange?.(this,this._dirty))}getProp(e){return this._overlay!==null&&n._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}getBaseProp(e){return this._props[e]}setProp(e,t){this._props[e]!==t&&(n.writeHook?.(this,e),this._props[e]=t,this._dirty.add(e),this.onChange?.(this,this._dirty))}deleteProp(e){e in this._props&&(n.writeHook?.(this,e),delete this._props[e],this._dirty.add(e),this.onChange?.(this,this._dirty))}setMany(e){let t=!1;for(let[r,i]of Object.entries(e))this._props[r]!==i&&(n.writeHook?.(this,r),this._props[r]=i,this._dirty.add(r),t=!0);t&&this.onChange?.(this,this._dirty)}setOverlayValue(e,t){this._overlay===null&&(this._overlay=new Map),this._overlay.set(e,t)}deleteOverlayValue(e){if(this._overlay===null)return!1;let t=this._overlay.delete(e);return this._overlay.size===0&&(this._overlay=null),t}getOverlayValue(e){return this._overlay?.get(e)}hasOverlayValue(e){return this._overlay?.has(e)??!1}overlayKeys(){return this._overlay?[...this._overlay.keys()]:[]}clearOverlay(){if(this._overlay===null)return[];let e=[...this._overlay.keys()];return this._overlay=null,e}get hasOverlay(){return this._overlay!==null}getDirtyKeys(){return this._dirty}clearDirty(){this._dirty.clear()}isDirty(){return this._dirty.size>0}getProps(){return this._props}snapshotProps(){return structuredClone(this._props)}restoreProps(e){this._props=structuredClone(e);for(let t of Object.keys(this._props))this._dirty.add(t);this.onChange?.(this,this._dirty)}getPropStamp(e){return this._propTimestamps.get(e)??null}stampProp(e,t,r){this._propTimestamps.set(e,{ts:t,clientId:r})}stampProps(e,t,r){let i={ts:t,clientId:r};for(let s of e)this._propTimestamps.set(s,i)}getPropStampsForKeys(e){let t={};for(let r of e){let i=this._propTimestamps.get(r);i&&(t[r]=i.ts)}return t}setPropIfWins(e,t,r,i){let s=this._propTimestamps.get(e),o=s?.ts??0,a=s?.clientId??"";return r>o||r===o&&i>a?(t===null?delete this._props[e]:this._props[e]=t,this._propTimestamps.set(e,{ts:r,clientId:i}),this._dirty.add(e),!0):!1}snapshotPropTimestamps(){return new Map(this._propTimestamps)}restorePropTimestamps(e){this._propTimestamps=new Map(e)}toSerialized(){return{id:this.id,type:this.type,state:{...this._props}}}static fromSerialized(e){return rt(e.id,e.type,e.state,"verbatim")}static create(e,t,r){return rt(e,t,r,"authoring")}};var Fu=5e3,Eu=1e4;function Ou(n){return n===null||n.size===0?"":[...n.entries()].sort((e,t)=>t[1].count-e[1].count).slice(0,5).map(([e,t])=>`${e.type}#${e.id} x${t.count} keys=[${[...t.keys].join(",")}]`).join("; ")}var Nn=class n{static _pendingGraphs=new Set;static flushAllPending(){if(n._pendingGraphs.size!==0)for(let e of[...n._pendingGraphs])e.flushBatched()}static get pendingGraphCount(){return n._pendingGraphs.size}root;_nodesById=new Map;_batchDepth=0;_batchDirtyNodes=new Map;_draining=!1;_changeListeners=[];_structureListeners=[];constructor(){this.root=rt("__root__","document"),this._nodesById.set(this.root.id,this.root)}onNodeChange(e){return this._changeListeners.push(e),()=>{let t=this._changeListeners.indexOf(e);t>=0&&this._changeListeners.splice(t,1)}}onStructureChange(e){return this._structureListeners.push(e),()=>{let t=this._structureListeners.indexOf(e);t>=0&&this._structureListeners.splice(t,1)}}addNode(e,t,r){let i=t??this.root;r!==void 0&&r>=0&&r<i.children.length?i.children.splice(r,0,e):i.children.push(e),e.parent=i,this._nodesById.set(e.id,e),e.onChange=this._handleNodeChange.bind(this),this._emitStructure("add",e,null,i)}removeNode(e){let t=this._nodesById.get(e);if(!t||t===this.root)return null;let r=t.parent,i=null;if(r){let s=r.children.indexOf(t);i={parentId:r===this.root?null:r.id,index:s},s>=0&&r.children.splice(s,1)}return t.parent=null,t.onChange=null,this._nodesById.delete(e),this._batchDirtyNodes.delete(t),this._removeDescendants(t),this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this),this._emitStructure("remove",t,r,null,i),t}getNode(e){return this._nodesById.get(e)??null}moveNode(e,t,r){let i=this._nodesById.get(e);if(!i||i===this.root)return;let s=i.parent,o=null;if(s){let a=s.children.indexOf(i);o={parentId:s===this.root?null:s.id,index:a},a>=0&&s.children.splice(a,1)}r!==void 0&&r>=0&&r<t.children.length?t.children.splice(r,0,i):t.children.push(i),i.parent=t,this._emitStructure("move",i,s,t,o)}moveNodeToParentId(e,t,r){let i=t?this._nodesById.get(t):this.root;i&&this.moveNode(e,i,r)}getChildren(e){let t=e?this._nodesById.get(e):this.root;return t?[...t.children]:[]}getRootShapes(){return[...this.root.children]}getParentId(e){let t=this._nodesById.get(e);return!t||!t.parent||t.parent===this.root?null:t.parent.id}getSiblingIndex(e){let t=this._nodesById.get(e);return!t||!t.parent?-1:t.parent.children.indexOf(t)}getAncestorIds(e){let t=[],r=this.getParentId(e);for(;r;)t.push(r),r=this.getParentId(r);return t}isAncestor(e,t){if(e===t)return!1;let r=this.getParentId(t);for(;r;){if(r===e)return!0;r=this.getParentId(r)}return!1}isDocumentRootNode(e){let t=this._nodesById.get(e);return!!t&&t!==this.root&&t.getProp("isRootSvg")===!0}contains(e,t){if(e===t)return!1;if(this.isDocumentRootNode(e)){let r=this._nodesById.get(t);return!!r&&r!==this.root&&!this.isDocumentRootNode(t)}return this.isAncestor(e,t)}getDepth(e){let t=this._nodesById.get(e);if(!t||t===this.root)return-1;let r=0,i=t.parent;for(;i&&i!==this.root;)r++,i=i.parent;return r}getAllNodes(){let e=[];for(let t of this._nodesById.values())t!==this.root&&e.push(t);return e}getDirtyNodes(){let e=[];for(let t of this._nodesById.values())t.isDirty()&&e.push(t);return e}clearAllDirty(){for(let e of this._nodesById.values())e.clearDirty()}beginBatch(){this._batchDepth++}commitBatch(){this._batchDepth=Math.max(0,this._batchDepth-1),this._batchDepth===0&&this._drainBatched()}flushBatched(){this._batchDirtyNodes.size>0&&this._drainBatched()}get hasPendingBatched(){return this._batchDirtyNodes.size>0}get isBatching(){return this._batchDepth>0}get isDraining(){return this._draining}dispose(){n._pendingGraphs.delete(this),this._batchDirtyNodes.clear(),this._changeListeners.length=0,this._structureListeners.length=0}notifyNodeChanged(e,t){this._handleNodeChange(e,t)}_handleNodeChange(e,t){if(this._batchDepth>0){let r=this._batchDirtyNodes.get(e);r||(r=new Set,this._batchDirtyNodes.set(e,r),n._pendingGraphs.add(this));for(let i of t)r.add(i);return}this._fireChangeListeners(e,t)}_drainBatched(){if(this._draining)return;this._draining=!0;let e=0,t=null;try{for(;this._batchDirtyNodes.size>0;){if(++e>Eu){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",Ou(t)),this._batchDirtyNodes.clear();break}let[r,i]=this._batchDirtyNodes.entries().next().value;if(this._batchDirtyNodes.delete(r),this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this),e>Fu){t===null&&(t=new Map);let s=t.get(r);if(s){s.count++;for(let o of i)s.keys.add(o)}else t.set(r,{count:1,keys:new Set(i)})}this._fireChangeListeners(r,i)}}finally{this._draining=!1,this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this)}}_fireChangeListeners(e,t){let r=[...this._changeListeners];for(let i of r)i(e,t)}_emitStructure(e,t,r,i,s=null){let o=[...this._structureListeners];for(let a of o)a(e,t,r,i,s)}_removeDescendants(e){for(let t of e.children)t.onChange=null,this._nodesById.delete(t.id),this._batchDirtyNodes.delete(t),this._removeDescendants(t)}serializeShapes(){let e=[],t=r=>{for(let i of r)i.type!=="document"&&i.type!=="group"&&i.getProp("structural")!==!0&&e.push(i.toSerialized()),i.children.length>0&&t(i.children)};return t(this.root.children),e}static fromShapes(e){let t=new n;for(let r of e){let i=Be.fromSerialized(r);t.addNode(i)}return t}};var G=["updatedAt","clientId"];function z(n,e,t){n.push({path:e,message:t})}function Ka(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function U(n,e,t){return Ka(n)?n:(z(t,e,"must be an object"),null)}function I(n,e,t,r=[],i,s=!0){let o=new Set([...s?["type"]:[],...t,...r]);for(let a of t)Object.hasOwn(n,a)||z(i,`${e}.${a}`,"is required");for(let a of Object.keys(n))o.has(a)||z(i,`${e}.${a}`,"is not allowed")}function A(n,e,t,r=!1){return typeof n!="string"||!r&&n.length===0?(z(t,e,r?"must be a string":"must be a non-empty string"),!1):!0}function oe(n,e,t,r){return typeof n!="number"||!Number.isFinite(n)?(z(t,e,"must be a finite number"),!1):r!==void 0&&n<r?(z(t,e,`must be at least ${r}`),!1):!0}function we(n,e,t,r=0){return oe(n,e,t,r)?Number.isInteger(n)?!0:(z(t,e,"must be an integer"),!1):!1}function $t(n,e,t){return typeof n!="boolean"?(z(t,e,"must be a boolean"),!1):!0}function Q(n,e,t,r,i=!1){n[e]!==void 0&&A(n[e],`${t}.${e}`,r,i)}function es(n,e,t,r,i){n[e]!==void 0&&oe(n[e],`${t}.${e}`,r,i)}function se(n,e,t,r,i=0){n[e]!==void 0&&we(n[e],`${t}.${e}`,r,i)}function Bn(n,e,t,r){n[e]!==void 0&&$t(n[e],`${t}.${e}`,r)}function it(n,e,t){return Array.isArray(n)?(n.forEach((r,i)=>A(r,`${e}[${i}]`,t)),!0):(z(t,e,"must be an array"),!1)}function X(n,e,t,r){return Array.isArray(n)?(n.forEach((i,s)=>r(i,`${e}[${s}]`,t)),!0):(z(t,e,"must be an array"),!1)}function ie(n,e,t){let r=[{value:n,path:e,depth:0}],i=0;for(;r.length>0;){let s=r.pop();if(i++,i>25e4){z(t,e,"exceeds the 250000-node validation limit");return}if(s.depth>64){z(t,s.path,"exceeds the 64-level nesting limit");continue}let o=s.value;if(!(o===null||typeof o=="string"||typeof o=="boolean")){if(typeof o=="number"){Number.isFinite(o)||z(t,s.path,"must be a finite JSON number");continue}if(Array.isArray(o)){o.forEach((a,l)=>r.push({value:a,path:`${s.path}[${l}]`,depth:s.depth+1}));continue}if(Ka(o)){for(let[a,l]of Object.entries(o))r.push({value:l,path:`${s.path}.${a}`,depth:s.depth+1});continue}z(t,s.path,"must be JSON-serializable")}}}function V(n,e,t){es(n,"updatedAt",e,t,0),Q(n,"clientId",e,t)}function zn(n,e,t){let r=U(n,e,t);if(r)for(let[i,s]of Object.entries(r))A(s,`${e}.${i}`,t,!0)}function jt(n,e,t,r=0){if(r>64){z(t,e,"exceeds the 64-level shape nesting limit");return}let i=U(n,e,t);if(!i)return;I(i,e,["id","type","state"],[],t),A(i.id,`${e}.id`,t),A(i.type,`${e}.type`,t);let s=U(i.state,`${e}.state`,t);s&&(Object.hasOwn(s,"extra")&&z(t,`${e}.state.extra`,"is an at-rest field and is not allowed in operations"),ie(s,`${e}.state`,t),s.children!==void 0&&X(s.children,`${e}.state.children`,t,(o,a,l)=>jt(o,a,l,r+1)))}function Lu(n,e,t){let r=U(n,e,t);r&&(Object.hasOwn(r,"extra")&&z(t,`${e}.extra`,"is an at-rest field and is not allowed in operations"),ie(r,e,t),r.children!==void 0&&X(r.children,`${e}.children`,t,(i,s,o)=>jt(i,s,o)))}function ts(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),Q(r,"pluginId",e,t),Q(r,"pluginData",e,t,!0),r.attributes!==void 0&&zn(r.attributes,`${e}.attributes`,t),ie(r,e,t))}function Ea(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.type!=="clip"&&r.type!=="mask"&&z(t,`${e}.type`,'must be "clip" or "mask"'),r.clipShapeIds!==void 0&&it(r.clipShapeIds,`${e}.clipShapeIds`,t),r.clipShapeId!==void 0&&Q(r,"clipShapeId",e,t),r.clipShapeIds===void 0&&r.clipShapeId===void 0&&z(t,`${e}.clipShapeIds`,"or clipShapeId is required"),it(r.contentShapeIds,`${e}.contentShapeIds`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),ie(r,e,t))}function Oa(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t);let i=r.orientation==="horizontal"||r.orientation==="vertical",s=r.axis==="x"||r.axis==="y";!i&&!s&&z(t,`${e}.orientation`,'must be "horizontal" or "vertical" (legacy axis "x" or "y" is also accepted)'),oe(r.position,`${e}.position`,t),i&&oe(r.controlPointOffset,`${e}.controlPointOffset`,t),Q(r,"color",e,t,!0),es(r,"opacity",e,t),ie(r,e,t)}function La(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t);let i=r.type==="distance"||r.type==="angle",s=["startX","startY","endX","endY"].every(o=>typeof r[o]=="number"&&Number.isFinite(r[o]));i?(X(r.points,`${e}.points`,t,(o,a,l)=>{let c=U(o,a,l);c&&(oe(c.x,`${a}.x`,l),oe(c.y,`${a}.y`,l))}),$t(r.visible,`${e}.visible`,t),we(r.snapDivisions,`${e}.snapDivisions`,t,1)):s||z(t,e,"must be a current or legacy measurement payload"),Q(r,"color",e,t,!0),es(r,"opacity",e,t),ie(r,e,t)}var Na=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawDescription","rawHtmlMetadata","coordinatePrecision"];function Ba(n,e,t,r){let i=U(n,e,t);if(!i)return;I(i,e,r?[]:["title","description","author","keywords","license","licenseUrl","language","customMetadata"],r?Na:Na.slice(8),t,!1);for(let o of["title","description","author","license","licenseUrl","language"])(!r||i[o]!==void 0)&&A(i[o],`${e}.${o}`,t,!0);(!r||i.keywords!==void 0)&&it(i.keywords,`${e}.keywords`,t),(!r||i.customMetadata!==void 0)&&zn(i.customMetadata,`${e}.customMetadata`,t),Q(i,"rawMetadata",e,t,!0),Q(i,"rawDescription",e,t,!0),Q(i,"rawHtmlMetadata",e,t,!0),se(i,"coordinatePrecision",e,t)}function za(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.source!=="inline"&&r.source!=="external"&&z(t,`${e}.source`,'must be "inline" or "external"'),A(r.content,`${e}.content`,t,!0),A(r.type,`${e}.type`,t,!0),Q(r,"svgId",e,t,!0),Q(r,"href",e,t,!0),Bn(r,"async",e,t),Bn(r,"defer",e,t),r.customAttrs!==void 0&&zn(r.customAttrs,`${e}.customAttrs`,t),ie(r,e,t))}function Ga(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.css,`${e}.css`,t,!0),$t(r.preserved,`${e}.preserved`,t),Q(r,"svgId",e,t,!0),Q(r,"type",e,t,!0),Q(r,"media",e,t,!0),r.customAttrs!==void 0&&zn(r.customAttrs,`${e}.customAttrs`,t),ie(r,e,t))}function Va(n,e,t){let r=U(n,e,t);if(r){if(A(r.name,`${e}.name`,t),["string","color","number"].includes(String(r.type))||z(t,`${e}.type`,'must be "string", "color", or "number"'),A(r.defaultValue,`${e}.defaultValue`,t,!0),Q(r,"label",e,t,!0),Q(r,"description",e,t,!0),r.mode!==void 0&&r.mode!=="live"&&r.mode!=="stamped"&&z(t,`${e}.mode`,'must be "live" or "stamped"'),r.source!==void 0){let i=U(r.source,`${e}.source`,t);i&&i.kind!=="user"&&z(t,`${e}.source.kind`,'must be "user"')}ie(r,e,t)}}function Ua(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.filename,`${e}.filename`,t,!0),A(r.format,`${e}.format`,t),ie(r,e,t))}function Nu(n,e,t){let r=U(n,e,t);r&&(we(r.glyphId,`${e}.glyphId`,t),Array.isArray(r.codepoints)?r.codepoints.forEach((i,s)=>we(i,`${e}.codepoints[${s}]`,t)):z(t,`${e}.codepoints`,"must be an array"),A(r.svgDocument,`${e}.svgDocument`,t,!0),Q(r,"glyphName",e,t,!0),se(r,"advanceWidth",e,t),Q(r,"sourceFamily",e,t,!0),se(r,"sourceGlyphId",e,t),Q(r,"label",e,t,!0),ie(r,e,t))}function Wa(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.name,`${e}.name`,t,!0),A(r.svgContent,`${e}.svgContent`,t,!0),oe(r.width,`${e}.width`,t,0),oe(r.height,`${e}.height`,t,0),ie(r,e,t))}function Ha(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"].includes(String(r.type))||z(t,`${e}.type`,"is not a supported paint-server type"),A(r.markup,`${e}.markup`,t),Bn(r,"passthrough",e,t),ie(r,e,t))}function ja(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t),A(r.name,`${e}.name`,t,!0);let i=r.kind;if(["symbol","marker","linear-gradient","radial-gradient","pattern","filter"].includes(String(i))||z(t,`${e}.kind`,"is not a supported library kind"),(i==="symbol"||i==="marker")&&(X(r.shapes,`${e}.shapes`,t,jt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ts)),i==="symbol"&&A(r.viewBox,`${e}.viewBox`,t,!0),i==="marker"){for(let s of["refX","refY","markerWidth","markerHeight"])oe(r[s],`${e}.${s}`,t);r.markerUnits!=="strokeWidth"&&r.markerUnits!=="userSpaceOnUse"&&z(t,`${e}.markerUnits`,'must be "strokeWidth" or "userSpaceOnUse"'),r.orient!=="auto"&&r.orient!=="auto-start-reverse"&&!(typeof r.orient=="number"&&Number.isFinite(r.orient))&&z(t,`${e}.orient`,"must be an orientation keyword or finite number")}(i==="linear-gradient"||i==="radial-gradient")&&U(r.gradient,`${e}.gradient`,t),i==="pattern"&&U(r.pattern,`${e}.pattern`,t),i==="filter"&&X(r.filters,`${e}.filters`,t,(s,o,a)=>{U(s,o,a)}),ie(r,e,t)}function Bu(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),Q(r,"viewBox",e,t,!0),r.shapes!==void 0&&X(r.shapes,`${e}.shapes`,t,jt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ts),ie(r,e,t))}function Xa(n,e,t,r){let i=U(n,e,t);i&&((r||i.id!==void 0)&&A(i.id,`${e}.id`,t),oe(i.time,`${e}.time`,t,0),typeof i.value!="string"&&!(typeof i.value=="number"&&Number.isFinite(i.value))&&!(Array.isArray(i.value)&&i.value.every(s=>typeof s=="number"&&Number.isFinite(s)))&&z(t,`${e}.value`,"must be a string, finite number, or finite number array"),A(i.easing,`${e}.easing`,t),ie(i,e,t))}function Ya(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.shapeId,`${e}.shapeId`,t),A(r.property,`${e}.property`,t),$t(r.enabled,`${e}.enabled`,t),Bn(r,"locked",e,t),X(r.keyframes,`${e}.keyframes`,t,(i,s,o)=>Xa(i,s,o,!1)),ie(r,e,t))}function zu(n,e,t){let r=U(n,e,t);r&&(oe(r.duration,`${e}.duration`,t,0),$t(r.loop,`${e}.loop`,t),oe(r.playbackSpeed,`${e}.playbackSpeed`,t,0),X(r.tracks,`${e}.tracks`,t,Ya))}function Gu(n,e,t){let r=U(n,e,t);if(!r)return;we(r.start,`${e}.start`,t),we(r.end,`${e}.end`,t),typeof r.start=="number"&&typeof r.end=="number"&&r.end<=r.start&&z(t,`${e}.end`,"must be greater than start");let i=U(r.style,`${e}.style`,t);i&&Object.keys(i).length===0&&z(t,`${e}.style`,"must not be empty"),ie(r,e,t)}function Vu(n,e,t){let r=U(n,e,t);r&&(I(r,e,["start","deleteCount","insert"],[],t,!1),we(r.start,`${e}.start`,t),we(r.deleteCount,`${e}.deleteCount`,t),A(r.insert,`${e}.insert`,t,!0))}var qa={"shape:add":(n,e,t)=>{I(n,e,["shape"],[],t),jt(n.shape,`${e}.shape`,t)},"shape:update":(n,e,t)=>{if(I(n,e,["id","state"],["propTimestamps","clientId","textSplices","baseSeq"],t),A(n.id,`${e}.id`,t),Lu(n.state,`${e}.state`,t),n.propTimestamps!==void 0){let r=U(n.propTimestamps,`${e}.propTimestamps`,t);if(r)for(let[i,s]of Object.entries(r))oe(s,`${e}.propTimestamps.${i}`,t,0)}Q(n,"clientId",e,t),n.textSplices!==void 0&&X(n.textSplices,`${e}.textSplices`,t,Vu),se(n,"baseSeq",e,t)},"shape:remove":(n,e,t)=>{I(n,e,["id"],[],t),A(n.id,`${e}.id`,t)},"text:format":(n,e,t)=>{I(n,e,["id","ranges"],["baseSeq",...G],t),A(n.id,`${e}.id`,t),X(n.ranges,`${e}.ranges`,t,Gu),se(n,"baseSeq",e,t),V(n,e,t)},"scene:move":(n,e,t)=>{I(n,e,["id","parentId","index"],G,t),A(n.id,`${e}.id`,t),n.parentId!==null&&A(n.parentId,`${e}.parentId`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"scene:place":(n,e,t)=>{I(n,e,["id","parentId","orderKey"],G,t),A(n.id,`${e}.id`,t),n.parentId!==null&&A(n.parentId,`${e}.parentId`,t),A(n.orderKey,`${e}.orderKey`,t),V(n,e,t)},"shapes:reorder":(n,e,t)=>{I(n,e,["ids"],[],t),it(n.ids,`${e}.ids`,t)},"groups:set":(n,e,t)=>{I(n,e,["groups"],[],t),X(n.groups,`${e}.groups`,t,ts)},"clipmasks:set":(n,e,t)=>{I(n,e,["clipMaskGroups"],[],t),X(n.clipMaskGroups,`${e}.clipMaskGroups`,t,Ea)},"clipMask:upsert":(n,e,t)=>{I(n,e,["clipMaskGroup"],["index",...G],t),Ea(n.clipMaskGroup,`${e}.clipMaskGroup`,t),se(n,"index",e,t),V(n,e,t)},"clipMask:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"guides:set":(n,e,t)=>{I(n,e,["guides"],[],t),X(n.guides,`${e}.guides`,t,Oa)},"guide:upsert":(n,e,t)=>{I(n,e,["guide"],["index",...G],t),Oa(n.guide,`${e}.guide`,t),se(n,"index",e,t),V(n,e,t)},"guide:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"guide:move":(n,e,t)=>{I(n,e,["id","index"],G,t),A(n.id,`${e}.id`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"measurements:set":(n,e,t)=>{I(n,e,["measurements"],[],t),X(n.measurements,`${e}.measurements`,t,La)},"measurement:upsert":(n,e,t)=>{I(n,e,["measurement"],["index",...G],t),La(n.measurement,`${e}.measurement`,t),se(n,"index",e,t),V(n,e,t)},"measurement:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"measurement:move":(n,e,t)=>{I(n,e,["id","index"],G,t),A(n.id,`${e}.id`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"metadata:set":(n,e,t)=>{I(n,e,["metadata"],[],t),Ba(n.metadata,`${e}.metadata`,t,!1)},"metadata:patch":(n,e,t)=>{I(n,e,["patch"],["removeKeys",...G],t),Ba(n.patch,`${e}.patch`,t,!0),n.removeKeys!==void 0&&it(n.removeKeys,`${e}.removeKeys`,t),V(n,e,t)},"documentScripts:set":(n,e,t)=>{I(n,e,["documentScripts"],[],t),X(n.documentScripts,`${e}.documentScripts`,t,za)},"documentScript:upsert":(n,e,t)=>{I(n,e,["documentScript"],["index",...G],t),za(n.documentScript,`${e}.documentScript`,t),se(n,"index",e,t),V(n,e,t)},"documentScript:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"documentStyles:set":(n,e,t)=>{I(n,e,["documentStyles"],[],t),X(n.documentStyles,`${e}.documentStyles`,t,Ga)},"documentStyle:upsert":(n,e,t)=>{I(n,e,["documentStyle"],["index",...G],t),Ga(n.documentStyle,`${e}.documentStyle`,t),se(n,"index",e,t),V(n,e,t)},"documentStyle:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"templateVariables:set":(n,e,t)=>{I(n,e,["templateVariables"],G,t),X(n.templateVariables,`${e}.templateVariables`,t,Va),V(n,e,t)},"templateVariable:upsert":(n,e,t)=>{I(n,e,["templateVariable"],["index",...G],t),Va(n.templateVariable,`${e}.templateVariable`,t),se(n,"index",e,t),V(n,e,t)},"templateVariable:remove":(n,e,t)=>{I(n,e,["name"],G,t),A(n.name,`${e}.name`,t),V(n,e,t)},"exportItems:set":(n,e,t)=>{I(n,e,["exportItems"],G,t),X(n.exportItems,`${e}.exportItems`,t,Ua),V(n,e,t)},"exportItem:upsert":(n,e,t)=>{I(n,e,["exportItem"],["index",...G],t),Ua(n.exportItem,`${e}.exportItem`,t),se(n,"index",e,t),V(n,e,t)},"exportItem:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"colorGlyphLibrary:set":(n,e,t)=>{if(I(n,e,["colorGlyphLibrary"],G,t),n.colorGlyphLibrary!==null){let r=U(n.colorGlyphLibrary,`${e}.colorGlyphLibrary`,t);r&&(r.version!==1&&z(t,`${e}.colorGlyphLibrary.version`,"must be 1"),X(r.entries,`${e}.colorGlyphLibrary.entries`,t,Nu),ie(r,`${e}.colorGlyphLibrary`,t))}V(n,e,t)},"animation:set":(n,e,t)=>{I(n,e,["animationTimeline"],[],t),n.animationTimeline!==void 0&&zu(n.animationTimeline,`${e}.animationTimeline`,t)},"animation:config":(n,e,t)=>{I(n,e,["config"],G,t);let r=U(n.config,`${e}.config`,t);r&&(I(r,`${e}.config`,["duration","loop","playbackSpeed"],[],t,!1),oe(r.duration,`${e}.config.duration`,t,0),$t(r.loop,`${e}.config.loop`,t),oe(r.playbackSpeed,`${e}.config.playbackSpeed`,t,0)),V(n,e,t)},"animation:clear":(n,e,t)=>{I(n,e,[],G,t),V(n,e,t)},"animationTrack:upsert":(n,e,t)=>{I(n,e,["track"],["index",...G],t),Ya(n.track,`${e}.track`,t),se(n,"index",e,t),V(n,e,t)},"animationTrack:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"animationKeyframe:upsert":(n,e,t)=>{I(n,e,["trackId","keyframe"],G,t),A(n.trackId,`${e}.trackId`,t),Xa(n.keyframe,`${e}.keyframe`,t,!0),V(n,e,t)},"animationKeyframe:remove":(n,e,t)=>{I(n,e,["trackId","keyframeId"],G,t),A(n.trackId,`${e}.trackId`,t),A(n.keyframeId,`${e}.keyframeId`,t),V(n,e,t)},"symbols:set":(n,e,t)=>{I(n,e,["symbols"],[],t),X(n.symbols,`${e}.symbols`,t,Bu)},"customPatterns:set":(n,e,t)=>{I(n,e,["customPatterns"],[],t),X(n.customPatterns,`${e}.customPatterns`,t,Wa)},"customPattern:upsert":(n,e,t)=>{I(n,e,["customPattern"],["index",...G],t),Wa(n.customPattern,`${e}.customPattern`,t),se(n,"index",e,t),V(n,e,t)},"customPattern:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"library:set":(n,e,t)=>{I(n,e,["library"],[],t),X(n.library,`${e}.library`,t,ja)},"library:upsert":(n,e,t)=>{I(n,e,["def"],["index",...G],t),ja(n.def,`${e}.def`,t),se(n,"index",e,t),V(n,e,t)},"library:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"rawPaintServerDefs:set":(n,e,t)=>{I(n,e,["rawPaintServerDefs"],[],t),it(n.rawPaintServerDefs,`${e}.rawPaintServerDefs`,t)},"paintServerDefs:set":(n,e,t)=>{I(n,e,["paintServerDefs"],[],t),X(n.paintServerDefs,`${e}.paintServerDefs`,t,Ha)},"paintServerDef:upsert":(n,e,t)=>{I(n,e,["paintServerDef"],["index",...G],t),Ha(n.paintServerDef,`${e}.paintServerDef`,t),se(n,"index",e,t),V(n,e,t)},"paintServerDef:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"presence:cursor":(n,e,t)=>{I(n,e,["position"],[],t);let r=U(n.position,`${e}.position`,t);r&&(I(r,`${e}.position`,["x","y"],[],t,!1),oe(r.x,`${e}.position.x`,t),oe(r.y,`${e}.position.y`,t))},"presence:selection":(n,e,t)=>{I(n,e,["shapeIds"],[],t),it(n.shapeIds,`${e}.shapeIds`,t)}},Uu=new Set(Object.keys(qa)),Za=new Set(["presence:cursor","presence:selection"]);function Gn(n,e="operation"){let t=[],r=U(n,e,t);return r?!A(r.type,`${e}.type`,t)||!Uu.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&z(t,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:t}):(qa[r.type](r,e,t),t.length===0?{valid:!0,value:r}:{valid:!1,issues:t}):{valid:!1,issues:t}}function Ja(n,e={}){let t=[];if(!Array.isArray(n))return{valid:!1,issues:[{path:"ops",message:"must be an array"}]};let r=e.minItems??1,i=e.maxItems??5e3;(n.length<r||n.length>i)&&z(t,"ops",`must contain ${r}-${i} operations`);let s=[];return n.forEach((o,a)=>{let l=Gn(o,`ops[${a}]`);if(!l.valid){t.push(...l.issues);return}if(Za.has(l.value.type)){z(t,`ops[${a}].type`,"presence operations are not document operations");return}s.push(l.value)}),t.length===0?{valid:!0,value:s}:{valid:!1,issues:t}}function Qa(n){let e=Gn(n,"op");return e.valid?Za.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function eo(n){return n.slice(0,5).map(({path:e,message:t})=>`${e} ${t}`).join("; ")}function Vn(n,e,t,r){let i=e[t],s=typeof i=="string"?i:"",o=(n??[]).filter(l=>l[t]!==s),a=typeof r=="number"&&Number.isFinite(r)?Math.max(0,Math.min(r,o.length)):o.length;return o.splice(a,0,e),o}function Un(n,e,t){return(n??[]).filter(r=>r[e]!==t)}function ge(n,e,t){return Vn(n,e,"id",t)}function ye(n,e){return Un(n,"id",e)}function Wn(n,e,t){return Vn(n,e,"name",t)}function Hn(n,e){return Un(n,"name",e)}function to(n,e){if(n===e)return null;let t=0,r=Math.min(n.length,e.length);for(;t<r&&n.charCodeAt(t)===e.charCodeAt(t);)t++;let i=0,s=Math.min(n.length,e.length)-t;for(;i<s&&n.charCodeAt(n.length-1-i)===e.charCodeAt(e.length-1-i);)i++;return{start:t,deleteCount:n.length-t-i,insert:e.slice(t,e.length-i)}}function no(n,e){return n.slice(0,e.start)+e.insert+n.slice(e.start+e.deleteCount)}function Kt(n,e){let t=e.start,r=e.start+e.deleteCount,i=e.insert.length-e.deleteCount,s=n.start,o=n.start+n.deleteCount;return r<=s?{start:s+i,deleteCount:n.deleteCount,insert:n.insert}:t>=o?{start:s,deleteCount:n.deleteCount,insert:n.insert}:t<=s&&r>=o?{start:t+e.insert.length,deleteCount:0,insert:n.insert}:t>=s&&r<=o?{start:s,deleteCount:n.deleteCount+i,insert:n.insert}:t<s?{start:t+e.insert.length,deleteCount:n.deleteCount-(r-s),insert:n.insert}:{start:s,deleteCount:t-s,insert:n.insert}}var Xt=Object.freeze({fontFamily:"Arial",fontSize:16,fontWeight:"normal",fontStyle:"normal",fontVariant:"",fontVariantLigatures:"",fontVariantPosition:"",fontVariantCaps:"",fontVariantNumeric:"",fontVariantEastAsian:"",textDecoration:Object.freeze({underline:!1,strikethrough:!1,overline:!1}),textTransform:"none",baselineShift:"baseline",dominantBaseline:"auto",writingMode:"horizontal-tb",whiteSpace:"pre-wrap",direction:"ltr",unicodeBidi:"normal",textAnchor:"start",letterSpacing:0,wordSpacing:0,lineHeight:1.2,fontVariationSettings:Object.freeze({}),fill:"#000000",fillOpacity:1,stroke:"none",strokeWidth:0,strokeOpacity:1}),vt=Object.keys(Xt);function Ge(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ze(n){return typeof n=="string"?n:void 0}function le(n){if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n=="string"&&n.trim()!==""){let e=Number.parseFloat(n);return Number.isFinite(e)?e:void 0}}function Xe(n){return e=>typeof e=="string"&&n.includes(e)?e:void 0}function Wu(n){return n==="normal"||n==="bold"?n:le(n)}function Hu(n){return n==="baseline"||n==="super"||n==="sub"?n:le(n)}function io(n){if(typeof n=="string"){let t=n.toLowerCase();return{underline:t.includes("underline"),strikethrough:t.includes("line-through")||t.includes("strikethrough"),overline:t.includes("overline")}}if(!Ge(n))return;let e={};return typeof n.underline=="boolean"&&(e.underline=n.underline),typeof n.strikethrough=="boolean"&&(e.strikethrough=n.strikethrough),typeof n.overline=="boolean"&&(e.overline=n.overline),e}function so(n){if(!Ge(n))return;let e={};for(let[t,r]of Object.entries(n)){let i=le(r);i!==void 0&&(e[t]=i)}return e}var ao={fontFamily:ze,fontSize:le,fontWeight:Wu,fontStyle:Xe(["normal","italic","oblique"]),fontVariant:ze,fontVariantLigatures:ze,fontVariantPosition:ze,fontVariantCaps:ze,fontVariantNumeric:ze,fontVariantEastAsian:ze,textTransform:Xe(["none","capitalize","uppercase","lowercase"]),baselineShift:Hu,dominantBaseline:Xe(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:Xe(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:Xe(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:Xe(["ltr","rtl"]),unicodeBidi:Xe(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:Xe(["start","middle","end"]),letterSpacing:le,wordSpacing:le,lineHeight:le,fill:ze,fillOpacity:le,stroke:ze,strokeWidth:le,strokeOpacity:le};function jn(n,e){return{...n,...e,textDecoration:{...n.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??n.fontVariationSettings}}}function rs(n,e){let t=Object.keys(n);return t.length!==Object.keys(e).length?!1:t.every(r=>Object.prototype.hasOwnProperty.call(e,r)&&n[r]===e[r])}function Yn(n,e){for(let t of vt)if(t==="textDecoration"){if(n.textDecoration.underline!==e.textDecoration.underline||n.textDecoration.strikethrough!==e.textDecoration.strikethrough||n.textDecoration.overline!==e.textDecoration.overline)return!1}else if(t==="fontVariationSettings"){if(!rs(n.fontVariationSettings,e.fontVariationSettings))return!1}else if(n[t]!==e[t])return!1;return!0}function qn(n,e){let t=Object.keys(n).sort(),r=Object.keys(e).sort();if(t.length!==r.length||t.some((i,s)=>i!==r[s]))return!1;for(let i of t)if(i==="textDecoration"){let s=n.textDecoration??{},o=e.textDecoration??{},a=new Set([...Object.keys(s),...Object.keys(o)]);for(let l of a){let c=l;if(s[c]!==o[c])return!1}}else if(i==="fontVariationSettings"){if(!rs(n.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let s=i;if(n[s]!==e[s])return!1}return!0}function Kn(n,e){let t={};for(let i of vt)i==="textDecoration"||i==="fontVariationSettings"||n[i]!==e[i]&&(t[i]=n[i]);let r={};return n.textDecoration.underline!==e.textDecoration.underline&&(r.underline=n.textDecoration.underline),n.textDecoration.strikethrough!==e.textDecoration.strikethrough&&(r.strikethrough=n.textDecoration.strikethrough),n.textDecoration.overline!==e.textDecoration.overline&&(r.overline=n.textDecoration.overline),Object.keys(r).length>0&&(t.textDecoration=r),rs(n.fontVariationSettings,e.fontVariationSettings)||(t.fontVariationSettings={...n.fontVariationSettings}),t}function Ce(n,e=Xt){let t=Ge(n)?n:{},r={...e};for(let i of vt){if(i==="textDecoration"||i==="fontVariationSettings")continue;let s=ao[i](t[i]);s!==void 0&&(r[i]=s)}return r.textDecoration={...e.textDecoration,...io(t.textDecoration)??{}},r.fontVariationSettings={...so(t.fontVariationSettings)??e.fontVariationSettings},r}function Yt(n){let e=Ge(n)?n:{},t={};for(let r of vt){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=ao[r](e[r]);i!==void 0&&(t[r]=i)}if(e.textDecoration!==void 0){let r=io(e.textDecoration);r&&Object.keys(r).length>0&&(t.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=so(e.fontVariationSettings);r&&(t.fontVariationSettings=r)}return t}function is(n){let e=[],t=0;for(;;){let r=n.indexOf(`
2
- `,t);if(r===-1)return e.push({text:n.slice(t),start:t,end:n.length}),e;e.push({text:n.slice(t,r),start:t,end:r}),t=r+1}}function ju(n,e,t){return n.start===n.end?t&&n.start===e:n.start<=e&&e<n.end}function ns(n,e,t,r){let i=n;for(let s of e)ju(s,t,r)&&(i=jn(i,s.style));return i===n?jn(n,{}):i}function oo(n,e,t={}){let r=Ce(n.baseStyle),i=typeof n.text=="string"?n.text:"";return ns(r,ss(n.runs,i.length),e,t.collapsed===!0)}function st(n,e=Xt){let t=Ge(n)?n:{},r=Ce(t.baseStyle,e),i=typeof t.text=="string"?t.text:"";return{text:i,runs:ss(t.runs,i.length),baseStyle:r,lineHeight:le(t.lineHeight)??r.lineHeight}}function ss(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ge(r))continue;let i=le(r.start),s=le(r.end);if(i===void 0||s===void 0)continue;let o=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(s),0),e);o>a||t.push({start:o,end:a,style:Yt(r.style)})}return t}function Ve(n){let e=typeof n.text=="string"?n.text:"",t=Ce(n.baseStyle),r=ss(n.runs,e.length),i=le(n.lineHeight)??t.lineHeight;return{lines:is(e).map(o=>{if(o.text.length===0)return{segments:[{text:"",style:ns(t,r,o.start,!0)}]};let a=new Set([o.start,o.end]);for(let f of r)f.start!==f.end&&(f.start>o.start&&f.start<o.end&&a.add(f.start),f.end>o.start&&f.end<o.end&&a.add(f.end));let l=[...a].sort((f,d)=>f-d),c=[];for(let f=0;f<l.length-1;f++){let d=l[f],p=l[f+1],m=ns(t,r,d,!1),h=c[c.length-1];h&&Yn(h.style,m)?h.text+=e.slice(d,p):c.push({text:e.slice(d,p),style:m})}return{segments:c}}),baseStyle:t,lineHeight:i}}function at(n){let e=Ce(n?.baseStyle),t=le(n?.lineHeight)??e.lineHeight,r=Array.isArray(n?.lines)?n.lines:[],i=r.length>0?r:[{segments:[]}],s=[],o=[],a=0;for(let f=0;f<i.length;f++){f>0&&(s.push(`
3
- `),a+=1);let d=i[f]?.segments,p=Array.isArray(d)?d:[],m=a;for(let h of p){let g=typeof h?.text=="string"?h.text:"";if(g.length===0)continue;let b=Ce(h?.style,e),$=Kn(b,e);Object.keys($).length>0&&o.push({start:a,end:a+g.length,style:$}),s.push(g),a+=g.length}if(a===m){let h=Ce(p[0]?.style,e),g=Kn(h,e);Object.keys(g).length>0&&o.push({start:m,end:m,style:g})}}let l=s.join(""),c=[];for(let f of o){let d=c[c.length-1];d!==void 0&&d.start!==d.end&&f.start!==f.end&&(d.end===f.start||d.end+1===f.start&&l.charAt(d.end)===`
4
- `)&&qn(d.style,f.style)&&d?d.end=f.end:c.push({start:f.start,end:f.end,style:f.style})}return{text:l,runs:c,baseStyle:e,lineHeight:t}}function Zn(n){let e=n.richTextRuns;if(Ge(e))return st(e);let t=n.richTextData;return Ge(t)&&Array.isArray(t.lines)&&t.lines.length>0?at(t):null}function Xn(n){let e=new Set;for(let t of Object.keys(n))if(t==="textDecoration")for(let r of Object.keys(n.textDecoration??{}))e.add(`textDecoration.${r}`);else e.add(t);return e}function Ku(n,e){if(n.start===n.end||e.start>=e.end||n.start<e.start||n.end>e.end)return!1;let t=Xn(e.style);for(let r of Xn(n.style))if(!t.has(r))return!1;return!0}function qt(n,e){let t=[...n];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(t=t.filter(i=>!Ku(i,r)),t.push({start:r.start,end:r.end,style:r.style}));return t}function Jn(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ge(r))continue;let i=le(r.start),s=le(r.end);if(i===void 0||s===void 0)continue;let o=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(s),0),e);if(o>=a)continue;let l=Yt(r.style);Object.keys(l).length!==0&&t.push({start:o,end:a,style:l})}return t}function lo(n,e){let t=[];for(let r of n){let i=Kt({start:r.start,deleteCount:r.end-r.start,insert:""},e),s=i.start,o=s+i.deleteCount;s>=o||t.push({start:s,end:o,style:r.style})}return t}function ro(n,e){return n.start===e.start&&n.end===e.end&&qn(n.style,e.style)}function uo(n,e){if(n.text!==e.text||n.lineHeight!==e.lineHeight||!Yn(Ce(n.baseStyle),Ce(e.baseStyle)))return null;let t=Array.isArray(n.runs)?n.runs:[],r=Array.isArray(e.runs)?e.runs:[],i=0,s=0;for(;s<r.length;){let l=-1;for(let c=i;c<t.length;c++)if(ro(t[c],r[s])){l=c;break}if(l===-1)break;i=l+1,s++}let o=r.slice(s);if(o.length===0)return null;for(let l of o)if(l.start>=l.end||Object.keys(l.style).length===0)return null;let a=qt(t,o);if(a.length!==r.length)return null;for(let l=0;l<a.length;l++)if(!ro(a[l],r[l]))return null;return o.map(l=>({start:l.start,end:l.end,style:Yt(l.style)}))}function Xu(n,e){let t=e===0||n.charAt(e-1)===`
5
- `,r=e===n.length||n.charAt(e)===`
6
- `;return t&&r}function co(n,e,t){let r=[];for(let i of n){let s=i.start===i.end,o=Kt({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=o.start,l=o.start+o.deleteCount;a===l&&(!s||!Xu(t,a))||r.push({start:a,end:l,style:i.style})}return r}function Ue(n,e=n.id){return{kind:"pattern",id:e,name:n.name??e,pattern:{type:"pattern",svgContent:n.svgContent,width:n.width,height:n.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function Zt(n){if(n.builtIn)return!1;let e=n.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function as(n){let e=(n.viewBox??"").trim().split(/[\s,]+/).filter(s=>s.length>0).map(Number),t=e.length===4&&e.every(s=>Number.isFinite(s)),r=t&&e[2]>0?e[2]:n.width??10,i=t&&e[3]>0?e[3]:n.height??10;return{width:r,height:i}}function kt(n){if(!Zt(n))return null;let{width:e,height:t}=as(n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:e,height:t}}function Pe(n){let e=[...n].sort((i,s)=>i.index-s.index);if(!e.some(i=>i.orderKey))return e;let t=On(e.length),r=new Map;return e.forEach((i,s)=>{r.set(i.id,i.orderKey??t[s])}),e.sort((i,s)=>{let o=Ut(r.get(i.id)??"",r.get(s.id)??"");return o!==0?o:i.id<s.id?-1:i.id>s.id?1:0})}var Yu=/^structural:(clip|mask):(.+):(group|path|content)$/;function fo(n,e){let t=`structural:${n}:${e}`;return{group:`${t}:group`,path:`${t}:path`,content:`${t}:content`}}function po(n,e){for(let t of n){e.add(t.id);let r=t.state.children;Array.isArray(r)&&po(r,e)}}function mo(n,e=null){let t=[];return n.forEach((r,i)=>{t.push({id:r.id,parentId:e,index:i});let s=r.state.children;Array.isArray(s)&&t.push(...mo(s,r.id))}),t}function Qn(n){let e=n.sceneTree&&n.sceneTree.length>0?n.sceneTree:mo(n.shapes),t=new Map(e.map(S=>[S.id,S])),r=new Map;for(let S of e){let x=r.get(S.parentId)??[];x.push(S),r.set(S.parentId,x)}for(let[S,x]of r)r.set(S,Pe(x));let i=S=>Yu.test(S),s=new Set(e.filter(S=>!i(S.id)).map(S=>S.id)),o=new Set;po(n.shapes,o);let a=new Map,l=new Set,c=(S,x)=>{let v=[];for(let w of r.get(S)??[]){if(!i(w.id)){l.has(w.id)||(l.add(w.id),v.push(w.id));continue}if(x.has(w.id))continue;let T=new Set(x);T.add(w.id),v.push(...c(w.id,T))}return v},f=[null,...s];for(let S of f){let x=c(S,new Set);x.length>0&&a.set(S,x)}for(let S of s){if(l.has(S))continue;let x=t.get(S)?.parentId??null,v=x!==null&&s.has(x)?x:null,w=a.get(v)??[];w.push(S),a.set(v,w),l.add(S)}let d=S=>{for(let[x,v]of a){let w=v.indexOf(S);if(w>=0)return{parentId:x,index:w}}return null},p=S=>{for(let x of a.values()){let v=x.indexOf(S);v>=0&&x.splice(v,1)}},m=n.clipMaskGroups??[],h=new Map(m.map(S=>[fo(S.type,S.id).content,S])),g=(S,x=new Set)=>{if(x.has(S.id))return Number.MAX_SAFE_INTEGER;let v=S.parentId?h.get(S.parentId):void 0;if(!v)return 0;let w=new Set(x);return w.add(S.id),1+g(v,w)},b=[...m].sort((S,x)=>g(S)-g(x)||(S.siblingIndex??0)-(x.siblingIndex??0)),$=new Map;for(let S of b){let x=(S.clipShapeIds.length>0?S.clipShapeIds:S.clipShapeId?[S.clipShapeId]:[]).filter(L=>o.has(L)),v=S.contentShapeIds.filter(L=>o.has(L));if(v.length===0||x.length===0&&!S.rawDefinition)continue;let w=[...v,...x].map(d).filter(L=>L!==null),T=w[0]?.parentId??null,P=w.length>0?Math.min(...w.map(L=>L.index)):void 0,R=S.parentId===null||s.has(S.parentId)||h.has(S.parentId)?S.parentId:T;for(let L of[...x,...v])p(L);let M=fo(S.type,S.id),N=a.get(R)??[],B=S.siblingIndex??P??N.length,D=Math.min(Math.max(0,B),N.length);N.splice(D,0,M.group),a.set(R,N),a.set(M.group,[M.path,M.content]),a.set(M.path,[...x]),a.set(M.content,[...v]),$.set(M.group,{id:M.group,parentId:R,index:0}),$.set(M.path,{id:M.path,parentId:M.group,index:0}),$.set(M.content,{id:M.content,parentId:M.group,index:1})}let k=[];for(let[S,x]of a)x.forEach((v,w)=>{let T=$.get(v);if(T){k.push({...T,parentId:S,index:w});return}let P=t.get(v);P&&P.parentId===S?k.push({...P,index:w}):k.push({id:v,parentId:S,index:w})});n.sceneTree=k}function $e(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function os(n){return $e(n)&&typeof n.updatedAt=="number"&&Number.isSafeInteger(n.updatedAt)&&n.updatedAt>=0&&typeof n.clientId=="string"}function ot(n,e){return{updatedAt:typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:0,clientId:e??""}}function Jt(n,e){return os(e)?n.updatedAt>e.updatedAt||n.updatedAt===e.updatedAt&&n.clientId>=e.clientId:!0}function ho(n){return $e(n.collaborationState)||(n.collaborationState={}),n.collaborationState}function go(n,e){let t=ho(n);$e(t.shapeProps)||(t.shapeProps={});let r=t.shapeProps;return $e(r[e])||(r[e]={}),r[e]}function Qt(n,e){let t=n.collaborationState?.shapeProps;if(!$e(t))return{};let r=t[e];return $e(r)?r:{}}function yo(n,e,t,r){if(t.length===0)return;let i=go(n,e);for(let s of t)Jt(r,i[s])&&(i[s]=r)}function ls(n,e){let t=n.collaborationState?.shapeProps;if($e(t)){for(let r of e)delete t[r];qu(n)}}function qu(n){let e=n.collaborationState;if($e(e)){for(let t of["shapeProps","resources"]){let r=e[t];$e(r)&&Object.keys(r).length===0&&delete e[t]}Object.keys(e).length===0&&delete n.collaborationState}}function us(n){switch(n.type){case"guide:upsert":return`guide:${n.guide.id}`;case"guide:remove":case"guide:move":return`guide:${n.id}`;case"measurement:upsert":return`measurement:${n.measurement.id}`;case"measurement:remove":case"measurement:move":return`measurement:${n.id}`;case"metadata:patch":return"metadata:document";case"documentScript:upsert":return`documentScript:${n.documentScript.id}`;case"documentScript:remove":return`documentScript:${n.id}`;case"documentStyle:upsert":return`documentStyle:${n.documentStyle.id}`;case"documentStyle:remove":return`documentStyle:${n.id}`;case"templateVariable:upsert":return`templateVariable:${n.templateVariable.name}`;case"templateVariable:remove":return`templateVariable:${n.name}`;case"exportItem:upsert":return`exportItem:${n.exportItem.id}`;case"exportItem:remove":return`exportItem:${n.id}`;case"colorGlyphLibrary:set":return"colorGlyphLibrary";case"animation:config":case"animation:clear":case"animationTrack:upsert":case"animationTrack:remove":return"animation:timeline";case"animationKeyframe:upsert":return`animationKeyframe:${n.trackId}:${n.keyframe.id}`;case"animationKeyframe:remove":return`animationKeyframe:${n.trackId}:${n.keyframeId}`;case"clipMask:upsert":return`clipMask:${n.clipMaskGroup.id}`;case"clipMask:remove":return`clipMask:${n.id}`;case"library:upsert":return`library:${n.def.id}`;case"library:remove":return`library:${n.id}`;case"customPattern:upsert":return`customPattern:${n.customPattern.id}`;case"customPattern:remove":return`customPattern:${n.id}`;case"paintServerDef:upsert":return`paintServerDef:${n.paintServerDef.id}`;case"paintServerDef:remove":return`paintServerDef:${n.id}`;default:return null}}function bo(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){if(!t)return null;let a=Qt(n,e.id),l={},c={},f=[];for(let[p,m]of Object.entries(e.state)){let h=ot(e.propTimestamps[p],e.clientId);Jt(h,a[p])&&(l[p]=m,c[p]=h.updatedAt,f.push([p,h]))}if(f.length===0)return null;let d=go(n,e.id);for(let[p,m]of f)d[p]=m;return{...e,state:l,propTimestamps:c}}let r=us(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=ot(e.updatedAt,e.clientId),s=ho(n);$e(s.resources)||(s.resources={});let o=s.resources;return Jt(i,o[r])?(o[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function So(n){let e=0,t=n.collaborationState?.shapeProps;if($e(t)){for(let i of Object.values(t))if($e(i))for(let s of Object.values(i))os(s)&&(e=Math.max(e,s.updatedAt))}let r=n.collaborationState?.resources;if($e(r))for(let i of Object.values(r))os(i)&&(e=Math.max(e,i.updatedAt));for(let i of n.sceneTree??[])typeof i.updatedAt=="number"&&Number.isSafeInteger(i.updatedAt)&&i.updatedAt>=0&&(e=Math.max(e,i.updatedAt));return e}function xo(n,e){let t=Object.keys(e.state);if(t.length===0)return;let r=Qt(n,e.id),i=0;for(let o of t){let a=ot(e.propTimestamps?.[o],e.clientId);i=Math.max(i,r[o]?.updatedAt??0,a.updatedAt)}let s=i+1;e.propTimestamps=Object.fromEntries(t.map(o=>[o,s]))}function lt(n){n.symbols!==void 0&&(n.symbols=(n.library??[]).filter(e=>e.kind==="symbol").map(({kind:e,...t})=>t)),n.customPatterns!==void 0&&(n.customPatterns=(n.library??[]).filter(e=>e.kind==="pattern").map(e=>kt(e)).filter(e=>e!==null))}function Po(n,e=null){let t=[];return n.forEach((r,i)=>{t.push({id:r.id,parentId:e,index:i});let s=r.state.children;Array.isArray(s)&&t.push(...Po(s,r.id))}),t}function pe(n,e){if(n===e)return!0;let t=n??$o,r=e??$o;if(t.length!==r.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==r[i])return!1;return!0}var $o=[];function en(n){return n.sceneTree&&n.sceneTree.length>0?n.sceneTree:Po(n.shapes)}function Zu(n,e){let t=n,r=new Set(n.map(o=>o.id)),i=(o,a,l)=>{r.has(o.id)||(t=ds(t,{id:o.id,parentId:a,index:l}),r.add(o.id)),wt(o)?.forEach((f,d)=>i(f,o.id,d))},s=t.filter(o=>o.parentId===null).length;return i(e,null,s),t}function _o(n){let e=new Map;for(let r of n){let i=e.get(r.parentId)??[];i.push(r),e.set(r.parentId,i)}let t=[];for(let r of e.values())Pe(r).forEach((i,s)=>t.push({...i,index:s}));return t}function tn(n,e){let t=n.filter(l=>l.parentId===e);if(t.every(l=>l.orderKey))return n;let r=Pe(t),i=new Map,s=[],o=null,a=l=>{if(s.length===0)return;let c=En(o,l,s.length);s.forEach((f,d)=>i.set(f.id,c[d])),s=[]};for(let l of r)l.orderKey?(a(l.orderKey),o=l.orderKey):s.push(l);return a(null),n.map(l=>i.has(l.id)?{...l,orderKey:i.get(l.id)}:l)}function ds(n,e){let t,r=[],i=[],s=!1;for(let l of n){if(l.id===e.id){if(t=l,!fs(e,t))return n;continue}l.parentId===e.parentId?(r.push(l),l.orderKey&&(s=!0)):i.push(l)}if(s){let l=tn([...i,...r],e.parentId),c=Pe(l.filter(h=>h.parentId===e.parentId)),f=Math.min(Math.max(0,e.index),c.length),d=f>0?c[f-1].orderKey??null:null,p=f<c.length?c[f].orderKey??null:null,m=d!==null&&p!==null&&d>=p?d:bt(d,p);return[...i,...c,{...e,orderKey:m}]}let o=r.sort((l,c)=>l.index-c.index).map((l,c)=>({...l,index:c})),a=Math.min(Math.max(0,e.index),o.length);return[...i,...o,{...e,index:a-.5}]}function er(n,e,t){let r=n?[...n]:[],i=r.find(s=>s.id===e);return i?ge(r,i,t):r}function Ju(n){n.keyframes.sort((e,t)=>{if(e.time!==t.time)return e.time-t.time;let r=e.id??"",i=t.id??"";return r<i?-1:r>i?1:0})}function ms(n,e){let t=n.keyframes.findIndex(r=>r.id===e.id);t>=0?n.keyframes[t]=e:n.keyframes.push(e),Ju(n)}function hs(n,e){n.keyframes=n.keyframes.filter(t=>t.id!==e)}function vo(n,e){let t=n.animationTimeline?.tracks;return Array.isArray(t)?t.find(r=>r.id===e)??null:null}function fs(n,e){let t=n.updatedAt??0,r=e.updatedAt??0;return t!==r?t>r:(n.clientId??"")>=(e.clientId??"")}function wt(n){let e=n.state.children;return Array.isArray(e)?e:void 0}var cs=new Set(["group","hyperlink","switch","container","svg"]);function Ro(n,e,t,r){for(let i of n){t.set(i.id,e),r.set(i.id,i);let s=wt(i);s&&Ro(s,i.id,t,r)}}function gs(n){let e=n.sceneTree;if(!e||e.length===0)return;let t=new Map,r=new Map;if(Ro(n.shapes,null,t,r),r.size===0)return;for(let d of r.values())delete d.state.groupId;let i=new Map;for(let d of e){let p=i.get(d.parentId)??[];p.push(d),i.set(d.parentId,p)}let s=new Map,o=(d,p)=>{let m=s.get(d);m?m.push(p):s.set(d,[p])},a=new Set,l=new Set,c=(d,p)=>{for(let m of Pe(i.get(d)??[])){if(l.has(m.id))continue;l.add(m.id);let h=r.get(m.id);if(!h){c(m.id,p);continue}o(p,h),a.add(h.id),cs.has(h.type)&&c(m.id,h.id)}};if(c(null,null),a.size===0)return;let f=d=>{let p=t.get(d)??null,m=new Set;for(;p!==null&&!m.has(p);){m.add(p);let h=r.get(p);if(h&&cs.has(h.type))return p;p=t.get(p)??null}return null};for(let[d,p]of r)a.has(d)||o(f(d),p);for(let[d,p]of r){if(!cs.has(p.type))continue;let m=p.state,h=s.get(d);h&&h.length>0?m.children=h:"children"in m&&delete m.children}n.shapes=s.get(null)??[]}function Qu(n){let e=`structural:${n.type}:${n.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Tt(n){let e=n.clipMaskGroups;if(!e||e.length===0)return;let t=n.sceneTree;if(!t||t.length===0)return;let r=new Set(t.map(o=>o.id)),i=new Map;for(let o of t){if(o.parentId===null)continue;let a=i.get(o.parentId);a?a.push(o):i.set(o.parentId,[o])}let s=o=>Pe(i.get(o)??[]).map(a=>a.id).filter(a=>!a.startsWith("structural:"));n.clipMaskGroups=e.map(o=>{let a=Qu(o);if(!r.has(a.group))return o;let l=r.has(a.path)?s(a.path):o.clipShapeIds,c=r.has(a.content)?s(a.content):o.contentShapeIds;if(ko(l,o.clipShapeIds)&&ko(c,o.contentShapeIds))return o;let f={...o,clipShapeIds:l,contentShapeIds:c};return(f.clipShapeId!==void 0||l.length>0)&&(f.clipShapeId=l[0]),f})}function ko(n,e){return!e||n.length!==e.length?!1:n.every((t,r)=>t===e[r])}function ys(n,e){e.add(n.id);let t=wt(n);if(t)for(let r of t)ys(r,e)}function ps(n,e){for(let t of n){e.set(t.id,t);let r=wt(t);r&&ps(r,e)}}var tr=class{constructor(e,t){this.snapshot=e;this.indexed=t}snapshot;indexed;shapeIndex=null;inlineProjectionPending=!1;sceneTreeNormalizePending=!1;memoId=null;memoShape=null;findShape(e){if(this.memoId===e)return this.memoShape;let t;return this.indexed?(this.shapeIndex===null&&(this.shapeIndex=new Map,ps(this.snapshot.shapes,this.shapeIndex)),t=this.shapeIndex.get(e)??null):t=ct(this.snapshot.shapes,e),this.memoId=e,this.memoShape=t,t}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&ps([e],this.shapeIndex)}noteShapesRemoved(){this.shapeIndex=null,this.memoId=null,this.memoShape=null}requestInlineProjection(){this.inlineProjectionPending=!0}requestSceneTreeNormalize(){this.sceneTreeNormalizePending=!0}settle(){if(this.sceneTreeNormalizePending){this.sceneTreeNormalizePending=!1;let e=this.snapshot.sceneTree;e&&e.length>0&&(this.snapshot.sceneTree=_o(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,gs(this.snapshot))}};function ct(n,e){for(let t of n){if(t.id===e)return t;let r=wt(t);if(!r)continue;let i=ct(r,e);if(i)return i}return null}function ut(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ec(n){let e=n.richTextRuns;return!ut(e)||typeof e.text!="string"?null:st(e)}function tc(n,e){let t=n.state;"extra"in t&&Ne(t);let r=new Set;for(let[i,s]of Object.entries(e))s===null?r.add(i):t[i]=s;if(r.size>0){let i={};for(let[s,o]of Object.entries(t))r.has(s)||(i[s]=o);n.state=i}}function Ao(n,e,t){let r=[];for(let i of n){if(i.id===e){ys(i,t);continue}let s=wt(i);if(s){let o=Ao(s,e,t),a=i.state;o.length>0?a.children=o:delete a.children}r.push(i)}return r}function Io(n,e){let t=n.snapshot,r=t,i=bo(t,e,e.type!=="shape:update"||n.findShape(e.id)!==null);if(i===null)return null;let s=i,o=s;switch(s.type){case"shape:add":{if(!(n.findShape(s.shape.id)!==null)){let l=en(r),c=Ht(structuredClone(s.shape));r.shapes.push(c),r.sceneTree=Zu(l,c),n.noteShapesAdded(c),n.requestSceneTreeNormalize(),n.requestInlineProjection();let f=new Set;ys(c,f),ls(t,f)}break}case"shape:update":{let a=n.findShape(s.id);if(!a)return null;tc(a,s.state);break}case"text:format":{let a=n.findShape(s.id);if(!a)return null;let l=a.state;"extra"in l&&Ne(l);let c=ec(l);if(!c)return null;let f=Jn(s.ranges,c.text.length);if(f.length===0)return null;let d={...c,runs:qt(c.runs,f)};l.richTextRuns=d;let p=["richTextRuns"];if(ut(l.richTextData)&&(l.richTextData=Ve(d),p.push("richTextData")),s.updatedAt!==void 0){let m=ot(s.updatedAt,s.clientId),h=Qt(t,s.id);if(p.some(b=>!Jt(m,h?.[b]))){let b=Math.max(0,...p.map($=>h?.[$]?.updatedAt??0));m={updatedAt:Math.max(m.updatedAt,b)+1,clientId:m.clientId},o={...s,updatedAt:m.updatedAt,clientId:m.clientId}}yo(t,s.id,p,m)}break}case"shape:remove":{let a=new Set,l=Ao(r.shapes,s.id,a),c=a.size>0;c||a.add(s.id);let f=en(r),d=f.filter(p=>!a.has(p.id));if(!c&&d.length===f.length)return null;r.shapes=l,r.sceneTree=d,n.noteShapesRemoved(),ls(t,a),Tt(r);break}case"scene:move":{let a=en(r),l=a.find(d=>d.id===s.id),c=s.updatedAt===void 0?void 0:ot(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:s.index,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!fs(f,l))return null;r.sceneTree=ds(a,f),n.requestSceneTreeNormalize(),c&&(o={...s,...c}),n.requestInlineProjection(),Tt(r);break}case"scene:place":{if(!Vt(s.orderKey))return null;let a=en(r),l=a.find(p=>p.id===s.id),c=s.updatedAt===void 0?void 0:ot(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:l?.index??Number.MAX_SAFE_INTEGER,orderKey:s.orderKey,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!fs(f,l))return null;let d=tn(a,s.parentId);r.sceneTree=[...d.filter(p=>p.id!==s.id),f],n.requestSceneTreeNormalize(),n.requestInlineProjection(),Tt(r),c&&(o={...s,...c});break}case"shapes:reorder":{let a=en(r);s.ids.forEach((l,c)=>{a.some(f=>f.id===l&&f.parentId===null)&&(a=ds(a,{id:l,parentId:null,index:c}))}),r.sceneTree=a,n.requestSceneTreeNormalize(),n.requestInlineProjection(),Tt(r);break}case"groups:set":r.groups=s.groups;break;case"clipmasks:set":r.clipMaskGroups=s.clipMaskGroups,Qn(r);break;case"clipMask:upsert":r.clipMaskGroups=ge(r.clipMaskGroups,s.clipMaskGroup,s.index),Qn(r);break;case"clipMask:remove":{let a=ye(r.clipMaskGroups,s.id);if(pe(r.clipMaskGroups,a))return null;r.clipMaskGroups=a,Qn(r);break}case"guides:set":r.guides=s.guides;break;case"guide:upsert":r.guides=ge(r.guides,s.guide,s.index);break;case"guide:remove":{let a=ye(r.guides,s.id);if(pe(r.guides,a))return null;r.guides=a;break}case"guide:move":{let a=er(r.guides,s.id,s.index);if(pe(r.guides,a))return null;r.guides=a;break}case"measurements:set":r.measurements=s.measurements;break;case"measurement:upsert":r.measurements=ge(r.measurements,s.measurement,s.index);break;case"measurement:remove":{let a=ye(r.measurements,s.id);if(pe(r.measurements,a))return null;r.measurements=a;break}case"measurement:move":{let a=er(r.measurements,s.id,s.index);if(pe(r.measurements,a))return null;r.measurements=a;break}case"metadata:set":r.documentMetadata=s.metadata;break;case"metadata:patch":{let a=Object.fromEntries(Object.entries({...r.documentMetadata??{},...s.patch}).filter(([l])=>!(s.removeKeys??[]).includes(l)));r.documentMetadata=a;break}case"documentScripts:set":r.documentScripts=s.documentScripts;break;case"documentScript:upsert":r.documentScripts=ge(r.documentScripts,s.documentScript,s.index);break;case"documentScript:remove":{let a=ye(r.documentScripts,s.id);if(pe(r.documentScripts,a))return null;r.documentScripts=a;break}case"documentStyles:set":r.documentStyles=s.documentStyles;break;case"documentStyle:upsert":r.documentStyles=ge(r.documentStyles,s.documentStyle,s.index);break;case"documentStyle:remove":{let a=ye(r.documentStyles,s.id);if(pe(r.documentStyles,a))return null;r.documentStyles=a;break}case"templateVariables:set":r.templateVariables=s.templateVariables;break;case"templateVariable:upsert":r.templateVariables=Wn(r.templateVariables,s.templateVariable,s.index);break;case"templateVariable:remove":{let a=Hn(r.templateVariables,s.name);if(pe(r.templateVariables,a))return null;r.templateVariables=a;break}case"exportItems:set":r.exportItems=s.exportItems;break;case"exportItem:upsert":r.exportItems=ge(r.exportItems,s.exportItem,s.index);break;case"exportItem:remove":{let a=ye(r.exportItems,s.id);if(pe(r.exportItems,a))return null;r.exportItems=a;break}case"colorGlyphLibrary:set":s.colorGlyphLibrary===null?delete r.colorGlyphLibrary:r.colorGlyphLibrary=s.colorGlyphLibrary;break;case"animation:set":r.animationTimeline=s.animationTimeline;break;case"animation:config":r.animationTimeline={duration:s.config.duration,loop:s.config.loop,playbackSpeed:s.config.playbackSpeed,tracks:Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[]};break;case"animation:clear":delete r.animationTimeline;break;case"animationTrack:upsert":r.animationTimeline={duration:typeof r.animationTimeline?.duration=="number"?r.animationTimeline.duration:0,loop:typeof r.animationTimeline?.loop=="boolean"?r.animationTimeline.loop:!1,playbackSpeed:typeof r.animationTimeline?.playbackSpeed=="number"?r.animationTimeline.playbackSpeed:1,tracks:ge(Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],s.track,s.index)};break;case"animationTrack:remove":{let a=Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],l=ye(a,s.id);if(pe(a,l)&&!r.animationTimeline)return null;l.length>0&&r.animationTimeline?r.animationTimeline={...r.animationTimeline,tracks:l}:delete r.animationTimeline;break}case"animationKeyframe:upsert":{let a=vo(r,s.trackId);if(!a)return null;ms(a,structuredClone(s.keyframe));break}case"animationKeyframe:remove":{let a=vo(r,s.trackId);if(!a)return null;let l=a.keyframes;if(hs(a,s.keyframeId),pe(l,a.keyframes))return null;break}case"symbols:set":{r.symbols=s.symbols;let a=s.symbols.map(c=>({...c,kind:"symbol"})),l=(r.library??[]).filter(c=>c.kind!=="symbol");r.library=[...a,...l],lt(r);break}case"customPatterns:set":r.customPatterns=s.customPatterns;{let a=new Set(s.customPatterns.map(c=>c.id)),l=(r.library??[]).filter(c=>!a.has(c.id)&&(c.kind!=="pattern"||!Zt(c)));r.library=[...l,...s.customPatterns.map(c=>Ue(c))]}lt(r);break;case"customPattern:upsert":{r.customPatterns=ge(r.customPatterns,s.customPattern,s.index);let a=Ue(s.customPattern),l=[...r.library??[]],c=l.findIndex(f=>f.id===a.id);c>=0?l[c]=a:l.push(a),r.library=l,lt(r);break}case"customPattern:remove":{let a=ye(r.customPatterns,s.id),l=ye(r.library,s.id);if(pe(r.customPatterns,a)&&pe(r.library,l))return null;r.customPatterns=a,r.library=l,lt(r);break}case"library:set":r.library=s.library,lt(r);break;case"library:upsert":r.library=ge(r.library,s.def,s.index),lt(r);break;case"library:remove":{let a=ye(r.library,s.id);if(pe(r.library,a))return null;r.library=a,lt(r);break}case"rawPaintServerDefs:set":r.rawPaintServerDefs=s.rawPaintServerDefs,delete r.paintServerDefs;break;case"paintServerDefs:set":r.paintServerDefs=s.paintServerDefs,r.rawPaintServerDefs=s.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:upsert":r.paintServerDefs=ge(r.paintServerDefs,s.paintServerDef,s.index),r.rawPaintServerDefs=r.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:remove":{let a=ye(r.paintServerDefs,s.id);if(pe(r.paintServerDefs,a))return null;r.paintServerDefs=a,r.rawPaintServerDefs=a.map(l=>l.markup);break}case"presence:cursor":case"presence:selection":break;default:{let a=s;return null}}return o}function Mo(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){let r=t?.type==="shape:update"?new Set(Object.keys(t.state)):new Set,i=Object.keys(e.state).filter(s=>!r.has(s));return To(n,e.id,i)}if(e.type==="text:format"&&t?.type==="text:format"){if(!(t.updatedAt!==e.updatedAt||t.clientId!==e.clientId))return[];let i=ct(n.shapes,e.id)?.state,s=i&&ut(Co(i,"richTextData"))?["richTextRuns","richTextData"]:["richTextRuns"];return To(n,e.id,s)}return[]}function Co(n,e){if(e in n)return n[e];let t=n.extra;return ut(t)?t[e]:void 0}function nc(n,e){if(e in n)return!0;let t=n.extra;return ut(t)&&e in t}function To(n,e,t){if(t.length===0)return[];let r=ct(n.shapes,e);if(!r)return[];let i=r.state,s=Qt(n,e),o=new Map;for(let l of t){let c=s[l];if(!c)continue;let f=o.get(c.clientId);f?f.push(l):o.set(c.clientId,[l])}let a=[];for(let[l,c]of o){let f={},d={};for(let p of c)f[p]=nc(i,p)?structuredClone(Co(i,p)):null,d[p]=s[p].updatedAt;a.push({type:"shape:update",id:e,state:f,propTimestamps:d,clientId:l})}return a}function Do(n,e){let t=new tr(n,!1),r=Io(t,e);return t.settle(),r}function bs(n,e){let t=new tr(n,e.length>1),r=[];for(let i of e){let s=Io(t,i);s&&r.push(s)}return t.settle(),r}function Ss(n,e){let t=structuredClone(n);return{snapshot:t,acceptedOps:bs(t,e)}}function Fo(n,e){return Ss(n,e).snapshot}function Eo(n){if(!n||n.length===0||n.every(t=>t.orderKey))return n;let e=n;for(let t of new Set(n.map(r=>r.parentId)))e=tn(e,t);return _o(e)}function Oo(n,e){if(!n.some(r=>r.type==="scene:place"))return n;let t=new Map((e??[]).map(r=>[r.id,r]));return n.map(r=>{if(r.type!=="scene:place")return r;let i=t.get(r.id);return{type:"scene:move",id:r.id,parentId:i?.parentId??r.parentId,index:i?.index??0,updatedAt:r.updatedAt,clientId:r.clientId}})}function Lo(n,e){if(!n.some(i=>i.type==="animationKeyframe:upsert"||i.type==="animationKeyframe:remove"))return n;let t=Array.isArray(e?.tracks)?e.tracks:[],r=[];for(let i of n){if(i.type!=="animationKeyframe:upsert"&&i.type!=="animationKeyframe:remove"){r.push(i);continue}let s=t.findIndex(o=>o.id===i.trackId);s!==-1&&r.push({type:"animationTrack:upsert",track:structuredClone(t[s]),index:s,updatedAt:i.updatedAt,clientId:i.clientId})}return r}function No(n,e){if(!n.some(r=>r.type==="text:format"))return n;let t=[];for(let r of n){if(r.type!=="text:format"){t.push(r);continue}let i=ct(e,r.id);if(!i)continue;let s=i.state.richTextRuns;if(!ut(s))continue;let o={richTextRuns:structuredClone(s)},a=i.state.richTextData;ut(a)&&(o.richTextData=structuredClone(a)),t.push({type:"shape:update",id:r.id,state:o,...typeof r.updatedAt=="number"?{propTimestamps:Object.fromEntries(Object.keys(o).map(l=>[l,r.updatedAt]))}:{},...r.clientId!==void 0?{clientId:r.clientId}:{}})}return t}function Bo(n,e){if(!n.some(r=>r.type==="guide:move"||r.type==="measurement:move"))return n;let t=[];for(let r of n)if(r.type==="guide:move"){let i=e.guides??[],s=i.findIndex(o=>o.id===r.id);if(s===-1)continue;t.push({type:"guide:upsert",guide:structuredClone(i[s]),index:s,updatedAt:r.updatedAt,clientId:r.clientId})}else if(r.type==="measurement:move"){let i=e.measurements??[],s=i.findIndex(o=>o.id===r.id);if(s===-1)continue;t.push({type:"measurement:upsert",measurement:structuredClone(i[s]),index:s,updatedAt:r.updatedAt,clientId:r.clientId})}else t.push(r);return t}var zo=6,wo=new Set(["templateVariables:set","templateVariable:upsert","templateVariable:remove","exportItems:set","exportItem:upsert","exportItem:remove","colorGlyphLibrary:set"]);function Go(n){return n.some(e=>wo.has(e.type))?n.filter(e=>!wo.has(e.type)):n}var rn=Object.freeze([1,0,0,1,0,0]);function We(n,e,t,r,i,s){return[n,e,t,r,i,s]}function rr(n){return We(n[0]??1,n[1]??0,n[2]??0,n[3]??1,n[4]??0,n[5]??0)}function Ye(n){return[n[0],n[1],n[2],n[3],n[4],n[5]]}function _t(n){return Array.isArray(n)&&n.length>=6&&n.slice(0,6).every(Number.isFinite)}function $s(n,e=1e-9){return Math.abs((n[0]??1)-1)<=e&&Math.abs(n[1]??0)<=e&&Math.abs(n[2]??0)<=e&&Math.abs((n[3]??1)-1)<=e&&Math.abs(n[4]??0)<=e&&Math.abs(n[5]??0)<=e}function rc(n,e,t=1e-9){for(let r=0;r<6;r++)if(Math.abs(n[r]-e[r])>t)return!1;return!0}function ne(n,e){return We(n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5])}function ic(n){let e=n[0]*n[3]-n[2]*n[1];if(Math.abs(e)<1e-10)return null;let t=1/e;return We(n[3]*t,-n[1]*t,-n[2]*t,n[0]*t,(n[2]*n[5]-n[3]*n[4])*t,(n[1]*n[4]-n[0]*n[5])*t)}function sc(n,e){return{x:n[0]*e.x+n[2]*e.y+n[4],y:n[1]*e.x+n[3]*e.y+n[5]}}function ac(n,e){return{x:n[0]*e.x+n[2]*e.y,y:n[1]*e.x+n[3]*e.y}}function _e(n,e=0){return We(1,0,0,1,n,e)}function sn(n,e=n){return We(n,0,0,e,0,0)}function Rt(n){let e=n*Math.PI/180,t=Math.cos(e),r=Math.sin(e);return We(t,r,-r,t,0,0)}function an(n){return We(1,0,Math.tan(n*Math.PI/180),1,0,0)}function on(n){return We(1,Math.tan(n*Math.PI/180),0,1,0,0)}function vs(n,e){return ne(ne(_e(n.x,n.y),e),_e(-n.x,-n.y))}var oc=9,lc=10,uc=12,cc=13,dc=32,Vo=43,fc=44,Uo=45,pc=46,mc=48,hc=57,gc=40,yc=41,bc=69,Sc=101,xc=0,$c=1,Ho=2,vc=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function kc(n){return n===dc||n===oc||n===lc||n===cc||n===uc}function nr(n){return n>=mc&&n<=hc}function Tc(n){let e=n>=65&&n<=90,t=n>=97&&n<=122;return e||t||nr(n)}function Pt(n){for(;n.pos<n.src.length&&kc(n.src.charCodeAt(n.pos));)n.pos++}function jo(n){let e=n.pos;return Pt(n),n.src.charCodeAt(n.pos)===fc?(n.pos++,Pt(n),Ho):n.pos>e?$c:xc}function Wo(n){let e=n.src,t=n.pos,r=t,i=e.charCodeAt(r);(i===Vo||i===Uo)&&r++;let s=!1;for(;r<e.length&&nr(e.charCodeAt(r));)r++,s=!0;if(e.charCodeAt(r)===pc){let l=r+1;for(;l<e.length&&nr(e.charCodeAt(l));)l++;l>r+1&&(r=l,s=!0)}if(!s)return null;let o=e.charCodeAt(r);if(o===Sc||o===bc){let l=r+1,c=e.charCodeAt(l);(c===Vo||c===Uo)&&l++;let f=l;for(;f<e.length&&nr(e.charCodeAt(f));)f++;f>l&&(r=f)}let a=Number(e.slice(t,r));return Number.isFinite(a)?(n.pos=r,a):null}function wc(n,e){switch(n){case"matrix":return rr(e);case"translate":return _e(e[0],e[1]??0);case"scale":return sn(e[0],e[1]??e[0]);case"rotate":return e.length===3?vs({x:e[1],y:e[2]},Rt(e[0])):Rt(e[0]);case"skewX":return an(e[0]);case"skewY":return on(e[0]);default:return null}}function Pc(n){let e=n.src,t=n.pos;for(;n.pos<e.length&&Tc(e.charCodeAt(n.pos));)n.pos++;if(n.pos===t)return null;let r=e.slice(t,n.pos),i=vc.get(r);if(!i||(Pt(n),e.charCodeAt(n.pos)!==gc))return null;n.pos++,Pt(n);let s=i[i.length-1],o=Wo(n);if(o===null)return null;let a=[o];for(;;){let l=n.pos;jo(n);let c=Wo(n);if(c===null){n.pos=l;break}if(a.push(c),a.length>s)return null}return Pt(n),e.charCodeAt(n.pos)!==yc||(n.pos++,!i.includes(a.length))?null:wc(r,a)}function _c(n){let e={src:n,pos:0};if(Pt(e),e.pos>=n.length)return rn;let t=rn;for(;;){let r=Pc(e);if(r===null)return null;t=ne(t,r);let i=jo(e);if(e.pos>=n.length)return i===Ho?null:t}}var Rc=2048,nn=new Map;function Ko(n){if(!n)return rn;let e=nn.get(n);if(e!==void 0)return e;let t=_c(n),r=t===null?null:Object.freeze(t);if(nn.size>=Rc){let i=nn.keys().next().value;i!==void 0&&nn.delete(i)}return nn.set(n,r),r}function ir(n){return Ko(n)??rn}function Ac(n){let e=n[0],t=n[1],r=n[2],i=n[3],s=Math.sqrt(e*e+t*t);if(s<1e-12)return{rotation:0,scaleX:0,scaleY:Math.sqrt(r*r+i*i),skewX:0};let o=Math.atan2(t,e),l=(e*i-t*r)/s,c=l!==0?(e*r+t*i)/(s*s):0,f=Math.atan(c),d=180/Math.PI;return{rotation:o*d,scaleX:s,scaleY:l,skewX:f*d}}function xs(n){return!_t(n)||$s(n)?null:`matrix(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]})`}function ln(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=n.rotation??0,o=n.skewX??0,a=n.skewY??0,l=n.scaleX??1,c=n.scaleY??1,f=_e(t,r);if(i)return ne(f,ir(i));if(s===0&&o===0&&a===0&&l===1&&c===1)return f;let d=n.customPivot??e;if(!d)return f;let p=ne(ne(ne(Rt(s),sn(l,c)),an(o)),on(a));return ne(f,vs(d,p))}function At(n,e){let t=xs(n.transformMatrix);return t||(xs(Ye(ln(n,e)))??null)}function ks(n,e){let t=n.ancestorTransform;if(!_t(t)){delete n.ancestorTransform;return}if($s(t)){delete n.ancestorTransform;return}let r=_t(n.transformMatrix)?rr(n.transformMatrix):ln(n,e);n.transformMatrix=Ye(ne(rr(t),r)),delete n.ancestorTransform}function Ts(n,e,t){let r=At(n,{x:e,y:t});return r?`${r} translate(${e}, ${t})`:`translate(${e}, ${t})`}function qo(n){let e=n.customPivot;if(e)return e;let t=n.x,r=n.y,i=n.width,s=n.height;if(typeof t=="number"&&typeof r=="number"&&typeof i=="number"&&typeof s=="number")return{x:t+i/2,y:r+s/2};let o=n.radius;if(typeof t=="number"&&typeof r=="number"&&typeof o=="number")return{x:t,y:r};let a=n.cx,l=n.cy;if(typeof a=="number"&&typeof l=="number")return{x:a,y:l};let c=n.x1,f=n.y1,d=n.x2,p=n.y2;if(typeof c=="number"&&typeof f=="number"&&typeof d=="number"&&typeof p=="number")return{x:(c+d)/2,y:(f+p)/2};let m=n.pathPoints;if(m?.[0])return{x:m[0].x,y:m[0].y};let h=n.polylinePoints;if(h?.[0])return{x:h[0].x,y:h[0].y}}function un(n){if(Array.isArray(n))for(let e of n){let t=e.state;ks(t,qo(t));let r=e.state.children;un(r)}}function Ic(n){un(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){un(e.shapes);for(let t of Object.values(e.variants??{}))un(t)}else e.kind==="marker"&&un(e.shapes);return n.schemaVersion=3,n}function ws(n){let e=n;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 Mc(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=_e(t,r);if(i)return Ye(ne(s,ir(i)));let o=n.rotation??0,a=n.skewX??0,l=n.skewY??0;if(o!==0||a!==0||l!==0){let d=ws(n.customPivot)??e??ws(n.scaleAnchor);d&&(s=ne(s,_e(d.x,d.y)),o!==0&&(s=ne(s,Rt(o))),a!==0&&(s=ne(s,an(a))),l!==0&&(s=ne(s,on(l))),s=ne(s,_e(-d.x,-d.y)))}let c=n.scaleX??1,f=n.scaleY??1;if(c!==1||f!==1){let d=ws(n.scaleAnchor)??e;d&&(s=ne(s,_e(d.x,d.y)),s=ne(s,sn(c,f)),s=ne(s,_e(-d.x,-d.y)))}return Ye(s)}function cn(n){if(Array.isArray(n))for(let e of n){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!_t(t.transformMatrix)&&(t.transformMatrix=Mc(t,qo(t))),delete t.scaleAnchor);let r=e.state.children;cn(r)}}function Cc(n){cn(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){cn(e.shapes);for(let t of Object.values(e.variants??{}))cn(t)}else e.kind==="marker"&&cn(e.shapes);return n.schemaVersion=4,n}function Dc(n){let e=Array.isArray(n.library)?[...n.library]:[],t=new Set(e.map(l=>l.id));if(Array.isArray(n.symbols))for(let l of n.symbols)!l||t.has(l.id)||(e.push({...l,kind:"symbol"}),t.add(l.id));if(Array.isArray(n.markers))for(let l of n.markers)!l||t.has(l.id)||(e.push({...l,kind:"marker"}),t.add(l.id));let r=new Map,i=(l,c)=>{let{id:f,sourceId:d,...p}=l,m=JSON.stringify({kind:c,...p}),h=r.get(m);if(h)return h;let g=t.has(l.id)?`grd-${sr()}`:l.id;t.add(g),r.set(m,g);let b=c==="linear-gradient"?{kind:"linear-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:Xo(l)}:{kind:"radial-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:Xo(l)};return e.push(b),g},s=new Map;if(Array.isArray(n.customPatterns))for(let l of n.customPatterns){if(!l)continue;let c=t.has(l.id)?`pat-${sr()}`:l.id;t.add(c),s.set(l.id,c),e.push(Ue(l,c))}let o=l=>{if(l.customPatternId){let $=s.get(l.customPatternId);if($)return $}let{id:c,sourceId:f,customPatternId:d,...p}=l,m=JSON.stringify({kind:"pattern",...p}),h=r.get(m);if(h)return h;let g=t.has(l.id)?`pat-${sr()}`:l.id;t.add(g),r.set(m,g);let b={kind:"pattern",id:g,name:l.sourceId??g,sourceId:l.sourceId,pattern:p};return e.push(b),g};for(let l of n.shapes??[]){let c=l.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 p=c.filters;if(Array.isArray(p)&&p.length>0){let m=a(p,c,l.id);c.filterLibraryIds=[m]}}return n.library=e,n;function a(l,c,f){let d={filters:l,colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight},p=JSON.stringify({kind:"filter",...d}),m=r.get(p);if(m)return m;let h=`filter-${f}`,g=t.has(h)?`flt-${sr()}`:h;t.add(g),r.set(p,g);let b={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(b),g}}function Xo(n){let{id:e,sourceId:t,...r}=n;return r}var Ps=0;function sr(){return Ps=Ps+1&65535,`${Date.now().toString(36)}-${Ps.toString(36)}`}function Fc(n){let e=t=>{if(Array.isArray(t))for(let r of t)nt(r)};e(n.shapes);for(let t of n.library??[])if(t.kind==="symbol"){e(t.shapes);for(let r of Object.values(t.variants??{}))e(r)}else t.kind==="marker"&&e(t.shapes);return n.schemaVersion=5,n}function Yo(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n;if(e.richTextRuns!==void 0&&e.richTextRuns!==null)return;let t=e.richTextData;!t||typeof t!="object"||Array.isArray(t)||Array.isArray(t.lines)&&(e.richTextRuns=at(t))}function Zo(n){if(!n?.state||typeof n.state!="object")return;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)Zo(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))Yo(i);Yo(e)}function Ec(n){let e=t=>{if(Array.isArray(t))for(let r of t)Zo(r)};e(n.shapes);for(let t of n.library??[])if(t.kind==="symbol"){e(t.shapes);for(let r of Object.values(t.variants??{}))e(r)}else t.kind==="marker"&&e(t.shapes);return n.schemaVersion=6,n}var _s=Object.freeze({1:Dc,2:Ic,3:Cc,4:Fc,5:Ec});function Oc(n){let e=n.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function ar(n,e=_s){let t=JSON.parse(JSON.stringify(n)),r=Oc(t);if(r>xe)return t;if(r===xe)return t.schemaVersion=xe,t;for(;r<xe;){let i=e[r];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${r} \u2192 ${r+1}. Cannot safely upgrade this document to version ${xe}.`);t=i(t),r+=1}return t.schemaVersion=xe,t}function dt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}async function As(n,e,t,r){let i=n[e];typeof i=="string"&&(n[e]=await r(i,t))}async function Rs(n,e){dt(n)&&await As(n,"svgContent","svgMarkup",e)}async function or(n,e){if(!dt(n))return;await As(n,"href","href",e),await Rs(n.fillGradient,e),await Rs(n.strokeGradient,e);let t=n.children;if(Array.isArray(t))for(let r of t)dt(r)&&await or(r.state,e)}async function Jo(n,e){if(!dt(n))return;let t=n.shapes;if(Array.isArray(t))for(let s of t)dt(s)&&await or(s.state,e);let r=n.library;if(Array.isArray(r))for(let s of r)dt(s)&&s.kind==="pattern"&&await Rs(s.pattern,e);let i=n.customPatterns;if(Array.isArray(i))for(let s of i)dt(s)&&await As(s,"svgContent","svgMarkup",e)}var Lc=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function dn(n){let e=[],t=[];if(n==null||typeof n!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:t};let r=n;if(r.schemaVersion!==void 0&&(typeof r.schemaVersion!="number"||!Number.isInteger(r.schemaVersion)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):r.schemaVersion>xe&&t.push({path:"schemaVersion",message:`schemaVersion ${r.schemaVersion} is newer than supported (${xe})`,severity:"warning"})),!Array.isArray(r.shapes))e.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;r.shapes.forEach((s,o)=>{Vc(s,`shapes[${o}]`,e,t,i)})}if(!Array.isArray(r.viewboxes))e.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;r.viewboxes.forEach((s,o)=>{Hc(s,`viewboxes[${o}]`,e,t,i)})}if(r.guides!==void 0&&(Array.isArray(r.guides)?r.guides.forEach((i,s)=>{jc(i,`guides[${s}]`,e,t)}):e.push({path:"guides",message:"guides must be an array",severity:"error"})),r.groups!==void 0&&(Array.isArray(r.groups)?r.groups.forEach((i,s)=>{Kc(i,`groups[${s}]`,e)}):e.push({path:"groups",message:"groups must be an array",severity:"error"})),r.sceneTree!==void 0)if(!Array.isArray(r.sceneTree))e.push({path:"sceneTree",message:"sceneTree must be an array",severity:"error"});else{let i=Nc(r.shapes),s=new Set;r.sceneTree.forEach((o,a)=>{Bc(o,`sceneTree[${a}]`,e,t,i,s)})}if(r.clipMaskGroups!==void 0&&(Array.isArray(r.clipMaskGroups)?r.clipMaskGroups.forEach((i,s)=>{Xc(i,`clipMaskGroups[${s}]`,e)}):e.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),r.paintServerDefs!==void 0)if(!Array.isArray(r.paintServerDefs))e.push({path:"paintServerDefs",message:"paintServerDefs must be an array",severity:"error"});else{let i=new Set;r.paintServerDefs.forEach((s,o)=>{Gc(s,`paintServerDefs[${o}]`,e,i)})}return r.measurements!==void 0&&(Array.isArray(r.measurements)||e.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:e.length===0,errors:e,warnings:t}}function Nc(n){let e=new Set;if(!Array.isArray(n))return e;let t=r=>{if(r===null||typeof r!="object")return;let i=r;typeof i.id=="string"&&i.id.length>0&&e.add(i.id);let o=i.state?.children;if(Array.isArray(o))for(let a of o)t(a)};for(let r of n)t(r);return e}function Qo(n){return n.startsWith("structural:")}function Bc(n,e,t,r,i,s){if(n===null||typeof n!="object"){t.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let o=n;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"}):(s.has(o.id)&&t.push({path:`${e}.id`,message:`Duplicate scene tree id: "${o.id}"`,severity:"error"}),s.add(o.id),!i.has(o.id)&&!Qo(o.id)&&r.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)&&!Qo(o.parentId)&&r.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 zc=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Gc(n,e,t,r){if(n===null||typeof n!="object"){t.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=n;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"}):r.has(i.id)?t.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):r.add(i.id),(typeof i.type!="string"||!zc.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"}),i.passthrough!==void 0&&typeof i.passthrough!="boolean"&&t.push({path:`${e}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"})}function Vc(n,e,t,r,i){if(n===null||typeof n!="object"){t.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}let s=n;typeof s.id!="string"||s.id.length===0?t.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(s.id)?t.push({path:`${e}.id`,message:`Duplicate shape id: "${s.id}"`,severity:"error"}):i.add(s.id),typeof s.type!="string"?t.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):Lc.has(s.type)||r.push({path:`${e}.type`,message:`Unknown shape type: "${s.type}"`,severity:"warning"}),s.state===void 0||s.state===null||typeof s.state!="object"?t.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"}):Wc(s.state,`${e}.state`,t,r)}var Uc=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function el(n){return typeof n=="number"?isFinite(n):typeof n=="string"?Uc.test(n):!1}function Wc(n,e,t,r){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)n[o]!==void 0&&!el(n[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of Bt){let a=n[o];if(a!=null){if(o==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(l=>typeof l=="number"&&Number.isFinite(l)))&&t.push({path:`${e}.${o}`,message:`${o} must be a 6-element finite affine matrix`,severity:"error"});continue}el(a)||t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"})}}let s=["width","height","radius","fontSize"];for(let o of s){let a=n[o];typeof a=="number"&&a<=0&&r.push({path:`${e}.${o}`,message:`${o} should be positive (got ${a})`,severity:"warning"})}}function Hc(n,e,t,r,i){if(n===null||typeof n!="object"){t.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let s=n;typeof s.id!="string"||s.id.length===0?t.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(s.id)?t.push({path:`${e}.id`,message:`Duplicate viewbox id: "${s.id}"`,severity:"error"}):i.add(s.id);for(let o of["x","y","width","height"])(typeof s[o]!="number"||!isFinite(s[o]))&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof s.width=="number"&&s.width<=0&&t.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof s.height=="number"&&s.height<=0&&t.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function jc(n,e,t,r){if(n===null||typeof n!="object"){t.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let i=n;(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 Kc(n,e,t){if(n===null||typeof n!="object"){t.push({path:e,message:"Group must be a non-null object",severity:"error"});return}let r=n;(typeof r.id!="string"||r.id.length===0)&&t.push({path:`${e}.id`,message:"Group id must be a non-empty string",severity:"error"}),r.parentId!==null&&typeof r.parentId!="string"&&t.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function Xc(n,e,t){if(n===null||typeof n!="object"){t.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let r=n;(typeof r.id!="string"||r.id.length===0)&&t.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),r.type!=="clip"&&r.type!=="mask"&&t.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof r.clipShapeId!="string"||r.clipShapeId.length===0)&&t.push({path:`${e}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(r.contentShapeIds)||t.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function _(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function lr(n={}){let e={schemaVersion:xe,shapes:n.shapes?n.shapes.map(t=>({...t})):[],viewboxes:n.viewboxes?n.viewboxes.map(t=>({...t})):[]};return n.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...n.metadata}),e}function tl(n){let{type:e,id:t,...r}=n,i={};for(let[s,o]of Object.entries(r))o!==void 0&&(i[s]=o);return{id:t??_(),type:e,state:i}}function fn(n,e,t,r,i){return{id:i??_(),x:n,y:e,width:t,height:r}}var Yc=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function ur(n,e={}){let{indent:t=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=dn(n);if(!a.valid){let l=a.errors.map(c=>` ${c.path}: ${c.message}`).join(`
7
- `);throw new Error(`Invalid document:
8
- ${l}`)}}let s={};for(let a of Yc){let l=n[a];if(l!==void 0)switch(a){case"shapes":s[a]=l.map(c=>Zc(nt(structuredClone(c))));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":s[a]=Array.isArray(l)&&typeof l[0]=="string"?l:qc(l).map(ft);break;case"documentMetadata":s[a]=ft(l);break;case"animationTimeline":s[a]=ft(l);break;case"colorGlyphLibrary":s[a]=ft(l);break;default:s[a]=l}}let o=JSON.stringify(s,null,t);return r?o+`
9
- `:o}function cr(n,e={}){let{validate:t=!0,migrate:r=!0}=e,i;try{i=JSON.parse(n)}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 s=i;if(r&&(s=ar(s)),t){let o=dn(s);if(!o.valid){let a=o.errors.map(l=>` ${l.path}: ${l.message}`).join(`
1
+ "use strict";var Mp=Object.defineProperty;var Kw=Object.getOwnPropertyDescriptor;var Xw=Object.getOwnPropertyNames;var Yw=Object.prototype.hasOwnProperty;var qw=(t,e)=>{for(var n in e)Mp(t,n,{get:e[n],enumerable:!0})},Zw=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xw(e))!Yw.call(t,i)&&i!==n&&Mp(t,i,{get:()=>e[i],enumerable:!(r=Kw(e,i))||r.enumerable});return t};var Jw=t=>Zw(Mp({},"__esModule",{value:!0}),t);var n_={};qw(n_,{ANIMATION_MANAGER_INTERPOLATION_POLICY:()=>Zl,Arrow:()=>hp,Audio:()=>$p,BROWSER_SVG_EXTENSION_URIS:()=>Sb,BUILTIN_MARKER_ID_MAP:()=>wa,CANONICAL_NORMALIZATION_FAULT_POINTS:()=>HI,CC_NS:()=>Fr,COLLAB_PROTOCOL_VERSION:()=>Vy,COMMON_PROP_DEFAULTS:()=>Je,COMMON_TRANSFORM_NODE_DEFAULTS:()=>_p,CURRENT_SCHEMA_VERSION:()=>_t,CanonicalDocument:()=>oi,Circle:()=>rp,Cloud:()=>bp,Container:()=>wp,ContainerShapeBuilder:()=>Kr,Cross:()=>pp,DC_NS:()=>Wt,DEFAULT_COORDINATE_PRECISION:()=>ba,DEFAULT_RICH_TEXT_STYLE:()=>Qr,DOCUMENT_FIELDS:()=>wt,DOCUMENT_FIELD_LIVE_AUTHORITY:()=>Cc,DOCUMENT_INGEST_POLICIES:()=>xa,DOCUMENT_SECTION_ORDER:()=>Zd,DocumentBuilder:()=>ep,DocumentModel:()=>vr,DocumentSession:()=>Ac,EASING_CURVES:()=>Xr,EasingType:()=>Kn,Ellipse:()=>ip,Gear:()=>gp,HEADLESS_SVG_STYLE_ENVIRONMENT:()=>cg,Heart:()=>yp,Hyperlink:()=>xp,IDENTITY_AFFINE:()=>_e,INGEST_APPLY_STAGES:()=>nb,INGEST_DIAGNOSTIC_CODES:()=>WS,INGEST_DOCUMENT_ROOT_IDENTITY:()=>zs,INGEST_FEATURES:()=>Ds,INGEST_FEATURE_CAPABILITIES:()=>bl,INGEST_PLAN_VERSION:()=>hi,INGRESS_INTENTS:()=>qi,INLINE_CHILD_CONTAINER_TYPES:()=>cs,ImageShape:()=>Ep,IngestApplicationError:()=>Gs,KNOWN_METADATA_PREFIXES:()=>ra,KNOWN_STATE_KEYS:()=>Bp,LIBRARY_ASSEMBLY_KIND_ORDER:()=>$c,LIBRARY_EMIT_ORDER:()=>Yg,Lightning:()=>Sp,Line:()=>ap,LinearGradientBuilder:()=>Ja,MARKER_HEIGHT:()=>su,MARKER_VIEWBOX:()=>Ia,MARKER_WIDTH:()=>ou,MATHML_EXTENSION_URI:()=>qf,MAX_COORDINATE_PRECISION:()=>tu,MIGRATIONS:()=>wg,NGon:()=>dp,NON_WIRE_PROP_KEYS:()=>Lh,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>Ko,NestedSvg:()=>Pp,NodeSchemaRegistry:()=>Jo,PAINT_SERVER_PASSTHROUGH_ATTR:()=>ps,PRESENTATION_SEMANTICS:()=>na,PUZZLE_DEFAULTS:()=>Th,Path:()=>Np,PathCurveType:()=>Op,PathPointType:()=>Oh,PatternBuilder:()=>ec,Polyline:()=>Ap,RDF_NS:()=>wi,RENDER_DIAGNOSTIC_CODES:()=>ru,RENDER_FEATURES:()=>Qx,RENDER_FEATURE_CAPABILITIES:()=>eI,RENDER_TARGETS:()=>iI,RICH_TEXT_STYLE_KEYS:()=>Li,RadialGradientBuilder:()=>Qa,Rectangle:()=>op,Ring:()=>fp,SAXES_SVG_XML_PARSER_HOST:()=>Hf,SERIALIZED_SHAPE_STATE_KEYS:()=>Dp,SHAPE_ENVELOPE_KEYS:()=>oI,SHAPE_TRANSFORM_STATE_KEYS:()=>zp,SVGSKETCH_NS:()=>_r,SVGSKETCH_PATH_EXTENSIONS:()=>vS,SVG_CONDITIONAL_PROCESSING_ATTRIBUTES:()=>Rl,SVG_IMPORT_CAPABILITY_OWNERS:()=>Jf,SVG_NAMESPACE:()=>K,SVG_NS:()=>nx,SVG_PRESENTATION_PROPERTIES:()=>js,SceneGraph:()=>yr,SceneNode:()=>Yt,ShapeBuilder:()=>ht,ShapeReference:()=>Tp,SpeechBubble:()=>vp,Spiral:()=>mp,Square:()=>sp,Star:()=>up,SvgImportError:()=>Ma,SvgXmlParserHostError:()=>Zi,Switch:()=>Ip,TYPED_FIELD_PREDICATES:()=>ia,Text:()=>cp,TextLayoutEngine:()=>ka,Timeline:()=>np,Track:()=>tp,Triangle:()=>lp,VARIANT_INTERPOLATION_POLICY:()=>Ws,Video:()=>Cp,View:()=>kp,XHTML_EXTENSION_URI:()=>Yf,addSmilPointsValues:()=>Es,affine:()=>ft,affineFromArray:()=>bs,affineToArray:()=>tt,almostEqualAffine:()=>s0,animationBackwardsFillTrack:()=>uf,animationCycleDuration:()=>cf,animationTrackActiveEnd:()=>df,animationTrackDocumentBegin:()=>lf,applyAffineToPoint:()=>We,applyAffineToVector:()=>Fc,applyClipMaskGroupDelta:()=>Qn,applyClipMaskPlanToShapes:()=>yh,applyCssAnimationLonghandOverrides:()=>mf,applyGuideDeltaOp:()=>ts,applyIngestPlan:()=>rb,applyMeasurementDeltaOp:()=>ns,applyMetadataDeltaOp:()=>ly,applyOpToSnapshot:()=>Tc,applyOpsInPlace:()=>tf,applyOpsToSnapshot:()=>By,applyOpsToSnapshotWithAccepted:()=>nf,applyRichTextFormat:()=>os,applyTextSplice:()=>uy,applyTextTransform:()=>jr,applyTimingFunctionToKeyframe:()=>sf,arcEndpointToCenter:()=>Ns,areTracksTimingEquivalent:()=>fh,around:()=>yf,assembleLibraryDefs:()=>rf,assembleSvgFromPlan:()=>bh,assertIngestFeatureRegistry:()=>qS,assertIngestPolicyRegistry:()=>Ng,assertSvgImportCapabilityOwners:()=>wb,buildCompoundTransformValues:()=>Au,buildFreshMetadataBlock:()=>Pd,buildGuideDeltaOps:()=>sy,buildManagedChildren:()=>Rd,buildManagedDescription:()=>Bm,buildMeasurementDeltaOps:()=>ay,buildMetadataDeltaOps:()=>cy,buildRenderPlan:()=>Sn,buildSmilKeyframeData:()=>mr,buildSmilKeyframes:()=>Pn,buildSvgDestinationIdentityIndex:()=>HN,buildSvgIngestPlan:()=>UI,buildSymbolMaterializationPlan:()=>Fu,canonicalPolygonTransformString:()=>bf,canonicalTransformMatrix:()=>un,canonicalTransformString:()=>bt,classifySvgExternalAssetUrl:()=>Lr,clipMaskDefinitionFromGroup:()=>Ic,clipMaskDefinitionsFromGroups:()=>On,clipMaskGroupDefId:()=>Wa,clipMaskGroupDefinitionId:()=>At,clipMaskGroupIsRawBacked:()=>xc,clipMaskGroupWithDefinition:()=>ni,clipMaskOwnedDefIds:()=>ju,collaborationResourceKey:()=>Xp,collectDocumentEnvelopeLibraryReferenceIds:()=>fu,collectFontFamiliesFromPlan:()=>nh,collectMarkerReferences:()=>yi,collectReferencedLibraryDefs:()=>$a,collectReferencedMarkerIds:()=>tb,collectSvgFragmentLibraryReferenceIds:()=>Xg,collectUnknownDocumentFields:()=>Jd,compareOrderKeys:()=>Zo,composeDecomposedTransformMatrix:()=>ks,computeArrowVertices:()=>Kc,computeCloudPath:()=>Zc,computeCrossVertices:()=>Wc,computeDashArray:()=>rl,computeFlowchartBoxPath:()=>nl,computeGearPath:()=>el,computeGearVertices:()=>Pf,computeHeartPath:()=>qc,computeLightningVertices:()=>Yc,computePolygonVertices:()=>$s,computeRectanglePath:()=>tl,computeRingPath:()=>Jc,computeSpeechBubbleVertices:()=>Xc,computeSpiralPath:()=>Qc,computeSplinePath:()=>kr,computeStarVertices:()=>Hc,containerTransformNeedsContentPivot:()=>Lt,createDocument:()=>ho,createSceneNode:()=>qr,createShape:()=>Tx,createSvgDestinationIdAllocator:()=>WN,createSvgPathMetrics:()=>aw,createTextLayoutKey:()=>uO,createTextLayoutProduct:()=>pO,createViewbox:()=>Pi,createWordSearchPrimitiveMask:()=>Ww,cssAnimationFillField:()=>hf,cssNamedColorToRgb:()=>ao,cubicBezierExtent1D:()=>cl,cubicBezierToEasingFields:()=>Ec,customPatternDefToLibraryDef:()=>ko,declaredRichTextDeltaKeys:()=>yc,decodeCssEscapes:()=>Gi,decomposeAffine2D:()=>Is,defaultVariableMode:()=>ek,deriveRichTextFormatRanges:()=>Sy,deriveSegments:()=>bc,deriveTextSplice:()=>dy,documentObjectBounds:()=>Vx,ellipticalArcBounds:()=>$f,emptyDocumentMetadata:()=>Nc,escXml:()=>fe,evaluateParsedTimingFunction:()=>af,evaluateSvgConditionalProcessing:()=>bb,extractVariables:()=>eu,filterAttr:()=>Yv,filterChainExtendsBounds:()=>Am,filterDefinitionEnvelope:()=>gd,filterReferenceValue:()=>ta,finalizeRenderPlan:()=>Su,findShapeById:()=>us,fingerprintIngestSource:()=>_s,flattenShapeStateTree:()=>lc,flattenStateExtra:()=>hr,flattenUnknownDocumentFields:()=>Co,foldSchemaV2AncestorTransformIntoMatrix:()=>Sf,forEachLibraryRefInState:()=>eb,forEachMarkerRefInState:()=>JS,forEachReachableShape:()=>Bs,forEachShapeInLibraryDefs:()=>vl,formatOperationValidationIssues:()=>ry,formatSmilKeySpline:()=>Pu,formatSmilKeyTime:()=>Tt,freezeIngestPlan:()=>Fs,freezeSiblingOrderKeys:()=>ds,generateCode:()=>Qu,generateCodeWithDiagnostics:()=>Ph,generateCssCode:()=>Ju,generateD3Code:()=>Zu,generateId:()=>J,generatePatternSvgContent:()=>ud,generatePuzzlePieces:()=>Tw,generateReactCode:()=>Xu,generateSudokuPuzzle:()=>_w,generateSvgCode:()=>Wu,generateVueCode:()=>Yu,generateWordSearch:()=>Hw,getBuiltInMarkerDefs:()=>sI,getEasingCubicBezier:()=>Qw,getEffectivePrecision:()=>nu,getIngestFeatureCapability:()=>YS,getIngestFieldPolicy:()=>Vs,getKeyframeCubicBezier:()=>dh,getLicenseLabel:()=>Lm,getLicenseUrl:()=>Fm,getMarkerDescriptors:()=>$i,getPatternElements:()=>Qs,getShapeGeometryKernel:()=>Xi,getSmilAdditive:()=>Fa,getSmilBeginValue:()=>Ni,getSmilFillMode:()=>Wr,getSmilMotionKeyPoints:()=>$u,getSmilRepeatCount:()=>Cu,getSmilSetBeginValue:()=>Ru,getSmilTrackDuration:()=>fr,getSvgPropertySemantics:()=>$r,getSvgSourceAttribute:()=>C,getSvgSourceHref:()=>Le,getWordSearchDirections:()=>Eh,hasAnyTypedMetadataField:()=>kd,hasSvgSourceAttribute:()=>mt,importSvg:()=>wu,importSvgWithDiagnostics:()=>ch,indexLibraryDefinitions:()=>yo,initialOrderKeys:()=>sc,injectClipMaskReference:()=>Hu,injectDomTargetAnimationElements:()=>Du,inspectCssTransformValue:()=>If,interpolateAngle:()=>hm,interpolateCharOffsetArray:()=>hv,interpolateColor:()=>ym,interpolateDasharrayLists:()=>t$,interpolateGradient:()=>yv,interpolateNumericArray:()=>ql,interpolatePathData:()=>QC,interpolatePlainObject:()=>Sv,interpolatePointArray:()=>mv,interpolatePolylinePoints:()=>e$,interpolateShapeTrees:()=>bv,interpolateSplinePointArray:()=>gv,invertAffine:()=>a0,isColorValue:()=>ZC,isCssNamedColor:()=>Yl,isDefaultKeyPoints:()=>Tu,isDefaultKeyTimes:()=>Da,isFiniteAffineArray:()=>ir,isGradientLike:()=>gm,isIdentityAffine:()=>Et,isIdentityLinearSplines:()=>ph,isIndefiniteSetTrack:()=>za,isNumericArray:()=>cr,isReusablePatternTile:()=>hg,isSetSequenceTrack:()=>_a,isSvgPresentationProperty:()=>El,isValidOrderKey:()=>qo,keyBetween:()=>Mi,keysBetween:()=>oc,layoutText:()=>lI,legacyEndpointMarkerId:()=>Ls,lerpNumber:()=>Ee,linearGradient:()=>bw,linearGradientEnvelope:()=>fd,lintWordSearchOptions:()=>Mh,mapAnimationTrackTime:()=>Kk,matchCubicBezierToPreset:()=>Zy,materializeSceneTreeOrderKeys:()=>Gy,matrixTransformPart:()=>ws,maxCollaborationTimestamp:()=>Ry,mergeRichTextStyle:()=>Fi,migrateSnapshot:()=>To,migrateV11toV12:()=>Ig,migrateV6toV7:()=>xg,migrateViewboxSidecarToViews:()=>Po,motionPathD:()=>Ya,moveResourceById:()=>_i,multiplyAffine:()=>ge,mutateSvgClipMaskDefinitionMarkup:()=>vx,nodeSchemas:()=>ue,normalizeClipMaskGroups:()=>vn,normalizePaintServerDef:()=>ms,normalizeRichTextRuns:()=>ei,normalizeRichTextStyle:()=>Mn,normalizeRichTextStyleDelta:()=>is,normalizeSmilPointsValue:()=>FS,normalizeSnapshotStructure:()=>XI,normalizeSnapshotToCanonicalDocument:()=>YI,orderSiblings:()=>ut,parseColor:()=>Ks,parseCssAnimationShorthand:()=>Oc,parseCssTimingFunction:()=>si,parseCssTransformOrigin:()=>Ts,parseDocument:()=>qd,parseDocumentWithDiagnostics:()=>Tg,parseInterpolationNumbers:()=>JC,parsePreserveAspectRatio:()=>Ji,parseSmilAdditive:()=>ml,parseSmilClockValue:()=>nr,parseSmilDuration:()=>gl,parseSmilFillField:()=>Mf,parseSmilKeySplines:()=>sr,parseSmilKeyTimes:()=>or,parseSmilRepeatSettings:()=>Ef,parseSmilValues:()=>Pr,parseSvgAbsoluteLength:()=>Ut,parseSvgLength:()=>Pe,parseSvgLengthList:()=>ci,parseSvgLengthToken:()=>pt,parseSvgPathData:()=>kn,parseSvgRootFrame:()=>Il,parseSvgSourceDocument:()=>tn,parseSvgStyleAttribute:()=>Yb,parseSvgTransformList:()=>Ht,parseSvgViewBox:()=>nt,parseVariableArgs:()=>nI,parseWordSearchWords:()=>jw,partitionShapeStateTree:()=>cc,partitionStateExtra:()=>Qo,partitionUnknownDocumentFields:()=>$o,pathCommandStructuresMatch:()=>fv,pathDataBounds:()=>fn,pattern:()=>xw,patternDefinitionEnvelope:()=>pd,patternLibraryDefToCustomPatternDef:()=>Wd,patternTileSize:()=>yg,pickCssAnimationListItem:()=>hs,planClipMaskGroups:()=>Uu,planSnapshotExternalEffects:()=>Px,planSvgAnimations:()=>Hl,planSvgAuthoredAttributes:()=>Fl,planSvgClipMasks:()=>ed,planSvgConditionalProcessing:()=>Cl,planSvgContainerHierarchy:()=>Tl,planSvgEmbeddedFrames:()=>Pl,planSvgExternalEffects:()=>Ld,planSvgFilters:()=>ld,planSvgGradients:()=>nd,planSvgImport:()=>ca,planSvgLeafGeometry:()=>Xl,planSvgMarkers:()=>td,planSvgMetadata:()=>Nd,planSvgPaintServerDefinitions:()=>od,planSvgPatterns:()=>rd,planSvgResourceDependencies:()=>_l,planSvgScripts:()=>dd,planSvgSourceIdentifiers:()=>$l,planSvgStyleCascade:()=>jl,planSvgSymbolUses:()=>Dl,planSvgUseOccurrences:()=>Al,planSvgViews:()=>wl,planTransformFusion:()=>Nu,planVariantTransitionsCss:()=>gw,planVariantTransitionsSmil:()=>mw,planVariantTransitionsWaapi:()=>hw,prepareSvgAuthorCssForLiveProjection:()=>aa,prepareSvgExternalAssetUrlForLiveProjection:()=>Jm,prepareSvgMarkupForLiveProjection:()=>Sx,prepareSvgXmlSource:()=>jf,preserveAspectRatioAlignFactor:()=>Wf,projectCssTransformStops:()=>Rs,projectPresentation:()=>fo,projectPresentationEntry:()=>Id,projectSceneTreeOntoClipMaskGroups:()=>ls,projectSceneTreeOntoShapes:()=>ii,projectSvgAnimationPlan:()=>zf,projectSvgAnimationTimeline:()=>Ms,projectSvgCustomProperties:()=>Vl,projectSvgImportToIngestPlan:()=>ah,projectSvgImportToSnapshot:()=>Iu,promoteManagedDescription:()=>Gm,promoteRebasedShapeUpdateClock:()=>Cy,pruneAndWrapSubtree:()=>Ka,quadraticBezierExtent1D:()=>ll,radialGradient:()=>vw,radialGradientEnvelope:()=>md,rebaseRichTextFormatRanges:()=>yy,rebaseRichTextRuns:()=>by,reflectCubicBezier:()=>Oa,registeredShapeGeometryTypes:()=>zS,removeResourceById:()=>Ft,removeResourceByKey:()=>fc,removeResourceByName:()=>gc,removeTrackKeyframe:()=>Jp,renderAnimationElements:()=>Va,renderBuiltinMarkerDefs:()=>pu,renderCircle:()=>zg,renderDescriptiveElements:()=>$d,renderDocumentScripts:()=>Gu,renderDocumentStyles:()=>Bu,renderEllipse:()=>_g,renderFilterDefs:()=>Xv,renderFilterElement:()=>ea,renderFilterLibraryDef:()=>eh,renderFilterPrimitive:()=>Sd,renderFilterPrimitivesForType:()=>Mm,renderFlowchartBox:()=>Wg,renderForeignObject:()=>Ug,renderGradientDefs:()=>yI,renderImage:()=>jg,renderLibraryDef:()=>Ta,renderLibraryDefs:()=>Ca,renderLine:()=>Lg,renderLinearGradient:()=>Oo,renderLinearGradientLibraryDef:()=>Zg,renderMarkerLibraryDef:()=>qg,renderPaintServerDefs:()=>Vu,renderPatternLibraryDef:()=>Qg,renderPlanDefsBody:()=>Vt,renderPolygonShape:()=>Kg,renderPolyline:()=>Vg,renderRadialGradient:()=>Do,renderRadialGradientLibraryDef:()=>Jg,renderRectangle:()=>Fg,renderReferencedLibraryDefs:()=>xI,renderResolvedSymbolLibraryDef:()=>zo,renderShape:()=>on,renderShapeContextForLibrary:()=>Hn,renderSpline:()=>Gg,renderSvgPrimitiveChainFilter:()=>Em,renderSymbolInstance:()=>Hg,renderSymbolLibraryDef:()=>Ra,renderTemplateVariablesStyle:()=>Lu,renderText:()=>Bg,renderToSvg:()=>Vo,renderToSvgWithDiagnostics:()=>qa,replaceClipMaskDefinition:()=>wc,replaceClipMaskGroupsInSceneTree:()=>er,replaySceneTreePlacements:()=>jy,resolveContainerTransform:()=>So,resolveContainerTransformFromContentBounds:()=>da,resolveCssAnimationEasingType:()=>ff,resolveEmbeddedSvgTransform:()=>Gr,resolveEmbeddedSvgViewportFrameBounds:()=>Fx,resolveInlineContainerTransform:()=>Hd,resolveMetadataQName:()=>Td,resolveRichTextStyleAt:()=>hy,resolveShapeGeometry:()=>Qt,resolveShapeLocalObjectBounds:()=>wo,resolveShapeObjectBounds:()=>Io,resolveShapeReferenceTransform:()=>jd,resolveSvgGradientGeometry:()=>Pm,resolveSvgLengthToken:()=>rr,resolveSvgPatternTile:()=>Tm,resolveSvgViewport:()=>Qi,resolveSymbolInstanceContent:()=>fi,resolveSymbolInstanceShapes:()=>ES,resolveSymbolInstanceTransform:()=>Ud,resolveSymbolViewport:()=>bo,rewriteDocumentEmbeddedPayloads:()=>tI,rewriteIdReferencesInMarkup:()=>Na,rewriteShapeStateEmbeddedPayloads:()=>Xd,rewriteSvgResourceReferenceValue:()=>_b,richTextFontVariantCss:()=>Ao,richTextLineSpans:()=>Up,richTextRunsFromState:()=>ti,richTextStyleDelta:()=>hc,richTextStyleDeltasEqual:()=>Sc,richTextStylesEqual:()=>Zn,richTextTspanAttributes:()=>au,rootMetadataAttrs:()=>Cd,rootPaintServerDefId:()=>fs,rotateAffine:()=>ji,roundCoord:()=>An,roundMarkupCoordinates:()=>th,roundNumberString:()=>va,roundSerializedShape:()=>$g,roundSnapshot:()=>rI,runsFromSegments:()=>Jn,sanitizeRichTextFormatRanges:()=>vc,sanitizeXmlId:()=>Gn,scaleAffine:()=>li,scanCssFunctionTokens:()=>xn,scanCssLocalUrlTokens:()=>_n,senderCorrectionsForOp:()=>Ly,serializeSvgPathData:()=>sl,serializedPresentationReader:()=>Ii,shapeLocalObjectBounds:()=>As,shapeLocalObjectCenter:()=>pl,shapeObjectBoundsInSpace:()=>Bd,skewXAffine:()=>vs,skewYAffine:()=>xs,smilKeyframeAttributes:()=>La,snapshotBoundsView:()=>jn,solveCubicBezier:()=>uh,solveSudoku:()=>nc,splinePathBounds:()=>$S,splitCssAnimationList:()=>gs,splitCssTopLevel:()=>ai,splitCssTopLevelRanges:()=>zn,splitTopLevelElements:()=>Bo,stringifyDocument:()=>Yd,stripAnimationDeclarations:()=>ja,substituteString:()=>Qd,substituteVariables:()=>Sa,symbolDefinitionSemanticHash:()=>yu,symbolInstanceTargetId:()=>Wi,synthesizeCssAnimationShorthand:()=>gf,templateVariablesCss:()=>Ua,transformSplice:()=>rs,transformSvgPathData:()=>PS,translateAffine:()=>qe,translateSvgPathData:()=>kS,tryParseSvgTransformList:()=>Zt,upsertResourceById:()=>Nt,upsertResourceByKey:()=>pc,upsertResourceByName:()=>mc,upsertTrackKeyframe:()=>Zp,validateDocumentOperations:()=>ty,validateOperation:()=>uc,validatePresenceOperation:()=>ny,validateSnapshot:()=>Br,validateSudokuPuzzle:()=>zw,verticesToPath:()=>wn,visitShapeTree:()=>dn,visitSnapshotShapeTrees:()=>et});module.exports=Jw(n_);var Kn=(M=>(M.LINEAR="linear",M.EASE="ease",M.EASE_IN="ease-in",M.EASE_OUT="ease-out",M.EASE_IN_OUT="ease-in-out",M.EASE_IN_QUAD="ease-in-quad",M.EASE_OUT_QUAD="ease-out-quad",M.EASE_IN_OUT_QUAD="ease-in-out-quad",M.EASE_IN_CUBIC="ease-in-cubic",M.EASE_OUT_CUBIC="ease-out-cubic",M.EASE_IN_OUT_CUBIC="ease-in-out-cubic",M.EASE_IN_QUART="ease-in-quart",M.EASE_OUT_QUART="ease-out-quart",M.EASE_IN_OUT_QUART="ease-in-out-quart",M.EASE_IN_SINE="ease-in-sine",M.EASE_OUT_SINE="ease-out-sine",M.EASE_IN_OUT_SINE="ease-in-out-sine",M.EASE_IN_QUINT="ease-in-quint",M.EASE_OUT_QUINT="ease-out-quint",M.EASE_IN_OUT_QUINT="ease-in-out-quint",M.EASE_IN_EXPO="ease-in-expo",M.EASE_OUT_EXPO="ease-out-expo",M.EASE_IN_OUT_EXPO="ease-in-out-expo",M.EASE_IN_CIRC="ease-in-circ",M.EASE_OUT_CIRC="ease-out-circ",M.EASE_IN_OUT_CIRC="ease-in-out-circ",M.EASE_IN_BACK="ease-in-back",M.EASE_OUT_BACK="ease-out-back",M.EASE_IN_OUT_BACK="ease-in-out-back",M.CUSTOM_BEZIER="custom-bezier",M.LINEAR_FUNCTION="linear-function",M.STEPS="steps",M))(Kn||{}),Xr={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 Qw(t){let e=Xr[t];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var Op=(a=>(a.LINEAR="linear",a.QUADRATIC="quadratic",a.CUBIC="cubic",a.CATMULL_ROM="catmull-rom",a.ARC="arc",a.BASIS="basis",a.MIXED="mixed",a))(Op||{}),Oh=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(Oh||{});function ek(t){return t==="color"?"live":"stamped"}var Dp=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform","layerName","leadingComments","fillColor","borderColor","borderWidth","opacity","fillOpacity","strokeOpacity","locked","visible","fillType","fillGradient","strokeType","strokeGradient","fillRule","strokeLinejoin","strokeLinecap","strokeMiterlimit","lineStyle","dashLength","gapLength","dashOffset","strokeDasharray","colorInterpolation","filters","filterColorInterpolation","filterUnits","primitiveUnits","filterX","filterY","filterWidth","filterHeight","metadata","cssClipPath","cssMaskProperties","structural","displayMode","display","visibility","inheritFill","inheritStroke","preserveOpacity","preserveFillOpacity","preserveStrokeOpacity","fillLibraryId","strokeLibraryId","filterLibraryIds","fillRuleExplicit","paintOrder","vectorEffect","transformBox","pathLength","markerStart","markerMid","markerEnd","blendMode","shapeRendering","textRendering","imageRendering","colorRendering","systemLanguage","requiredExtensions","inlineStyle","authoredAttributes","bindings","scripts","lastSolidFillColor","lastSolidStrokeColor","connectionPoints","isRootSvg","x","y","width","height","rx","ry","cornerRadius","cornerShape","cornerMode","cornerRadiusTL","cornerRadiusTR","cornerRadiusBL","cornerRadiusBR","cornerShapeTL","cornerShapeTR","cornerShapeBL","cornerShapeBR","size","radius","cx","cy","shiftAngle","x1","y1","x2","y2","startEndpoint","endEndpoint","routingMode","sourceRef","targetRef","sourcePoint","targetPoint","waypoints","label","labelPosition","labelOffset","mermaidEdgeStyle","textX","textY","authoredTextPosition","authoredTextStructure","fontSize","text","fontFamily","fontWeight","fontStyle","fontVariant","fontVariantLigatures","fontVariantPosition","fontVariantCaps","fontVariantNumeric","fontVariantEastAsian","textDecoration","textTransform","baselineShift","dominantBaseline","writingMode","textAnchor","letterSpacing","wordSpacing","lineHeight","inlineSize","overflowWrap","whiteSpace","textDirection","unicodeBidi","useRichText","richTextRuns","charOffsets","fontVariationSettings","linePositions","textLength","lengthAdjust","shapeInsideRef","shapeInsideImportRefId","shapePadding","isTextPath","textPathPoints","textPathStartOffset","textPathStartOffsetUnit","textPathSide","textPathMethod","textPathSpacing","textPathLengthAdjust","textPathLength","textPathLengthUnit","textPathPathLength","textPathCurveType","textPathInlineFormat","textPathRefShapeId","textPathImportRefId","href","originalWidth","originalHeight","preserveAspectRatio","specPreserveAspectRatio","imageOpacity","pathPoints","pathArcParams","pathControlBounds","pathCurveType","pathClosed","pathTension","polylinePoints","polylineClosed","sides","arms","innerRadiusPercent","armWidthPercent","turns","thicknessPercent","spiralDirection","teeth","toothDepthPercent","holeRadiusPercent","headWidthPercent","headLengthPercent","shaftWidthPercent","tailAngleDeg","tailLengthPercent","tailWidthPercent","lobeRadiusPercent","cleftDepthPercent","boltSegments","boltJaggednessPercent","boltWidthPercent","cloudBumps","cloudPuffinessPercent","slantPercent","topWidthPercent","capHeightPercent","waveAmplitudePercent","symbolId","authoredUseGeometry","symbolOverrides","variantKey","instancePresentation","scaleContentToViewport","groupData","mediaKind","mediaMimeType","naturalDuration","begin","trimStart","trimEnd","volume","muted","loop","playbackRate","mediaOpacity","fadeInDuration","fadeOutDuration","posterHref","sourceRect","rawContent","hrefXlink","linkTarget","linkRel","linkDownload","linkPing","linkHreflang","linkType","linkReferrerPolicy","containerPresentation","targetShapeId","offsetX","offsetY","targetWidth","targetHeight","broken","switchSystemLanguage","switchRequiredExtensions","svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio","viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight","viewName","viewPreserveAspectRatio","viewZoomAndPan","viewTarget","children"],_t=13;var zp=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],Ko=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],_p={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Xn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ic=Xn.length,Yn=Xn[0],Dh=Xn[ic-1],_h=Xn[Math.floor(ic/2)],Fp=97,tk=122;function Ei(t){let e=Xn.indexOf(t);if(e===-1)throw new Error(`order-key: invalid digit '${t}'`);return e}function nk(t){let e=t.charCodeAt(0);if(e<Fp||e>tk)throw new Error(`order-key: invalid head '${t}'`);return e-Fp+1}function gr(t){if(t<1||t>26)throw new Error(`order-key: integer length ${t} out of range`);return String.fromCharCode(Fp+t-1)}function Xo(t){let e=nk(t[0]);if(t.length<1+e)throw new Error(`order-key: '${t}' shorter than its integer part`);let n=t.slice(1,1+e),r=t.slice(1+e);for(let i of n)Ei(i);for(let i of r)Ei(i);return{integer:n,fraction:r}}function rc(t){for(let e of t)if(e!==Yn)return!1;return!0}function qo(t){if(t.length===0)return!1;try{let{integer:e,fraction:n}=Xo(t);return!(n.endsWith(Yn)||rc(e)&&n.length===0||e.length>1&&e[0]===Yn)}catch{return!1}}function zh(t,e){if(!qo(t))throw new Error(`order-key: invalid ${e} '${t}'`)}function Zo(t,e){return t<e?-1:t>e?1:0}function rk(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=Ei(e[n]);if(r<ic-1){e[n]=Xn[r+1];for(let i=n+1;i<e.length;i++)e[i]=Yn;return e.join("")}}return null}function Lp(t){let{integer:e}=Xo(t),n=rk(e);if(n!==null)return gr(e.length)+n;let r="1"+Yn.repeat(e.length);return gr(r.length)+r}function ik(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=Ei(e[n]);if(r>0){e[n]=Xn[r-1];for(let i=n+1;i<e.length;i++)e[i]=Dh;return e.join("")}e[n]=Dh}throw new Error(`order-key: cannot decrement zero integer '${t}'`)}function ok(t){let e=0;for(;e<t.length-1&&t[e]===Yn;)e++;return t.slice(e)}function sk(t){let{integer:e,fraction:n}=Xo(t);if(!rc(e)){let r=ik(e);if(!rc(r)){let i=ok(r);return gr(i.length)+i}return gr(1)+Yn+_h}return gr(1)+Yn+Yo("",n)}function Yo(t,e){if(e!==null){if(e.length===0||t>=e)throw new Error(`order-key: fraction bounds out of order ('${t}' >= '${e}')`);let i=0;for(;i<e.length&&(t[i]??Yn)===e[i];)i++;if(i>0)return e.slice(0,i)+Yo(t.slice(i),e.slice(i))}let n=t.length>0?Ei(t[0]):0,r=e!==null?Ei(e[0]):ic;return r-n>1?Xn[Math.floor((n+r)/2)]:Xn[n]+Yo(t.slice(1),null)}function Mi(t,e){if(t!==null&&zh(t,"lower bound"),e!==null&&zh(e,"upper bound"),t!==null&&e!==null&&t>=e)throw new Error(`order-key: bounds out of order ('${t}' >= '${e}')`);if(t===null&&e===null)return gr(1)+"1";if(t===null)return sk(e);if(e===null)return Lp(t);let n=Xo(t),r=Xo(e),i=gr(n.integer.length)+n.integer,o=gr(r.integer.length)+r.integer;if(i===o)return i+Yo(n.fraction,r.fraction);let s=Lp(i+(rc(n.integer)?_h:""));return Zo(s,e)<0?s:i+Yo(n.fraction,null)}function oc(t,e,n){if(n<=0)return[];let r=[],i=t;for(let o=0;o<n;o++){let s=Mi(i,e);r.push(s),i=s}return r}function sc(t){if(t<=0)return[];let e=[],n=Mi(null,null);e.push(n);for(let r=1;r<t;r++)n=Lp(n),e.push(n);return e}var Jo=class{schemas=new Map;register(e,n){this.schemas.set(e,n)}get(e){return this.schemas.get(e)}typeIds(){return[...this.schemas.keys()]}getDefaults(e){let n=this.schemas.get(e);if(!n)return{};let r={};for(let i of Object.keys(n))r[i]=n[i].default;return r}validate(e,n,r){let i=this.schemas.get(e);if(!i)return r;let o=i[n];return o?.validate?o.validate(r):r}},he=t=>Math.max(0,t),Oi=t=>Math.max(0,Math.min(1,t)),ot=t=>Math.max(0,Math.min(100,t)),ak=t=>Math.max(1,t),ck=t=>Math.max(3,Math.min(100,Math.floor(t))),lk=t=>Math.max(3,Math.min(50,Math.floor(t))),dk=t=>Math.max(3,Math.min(30,Math.floor(t))),uk=t=>Math.max(1,Math.min(10,t));function pk(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,{default:n}]))}var fk=pk(_p),Je={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:Oi},fillOpacity:{default:1,validate:Oi},strokeOpacity:{default:1,validate:Oi},...fk,locked:{default:!1},visible:{default:!0},fillType:{default:"solid"},fillGradient:{default:null},strokeType:{default:"solid"},strokeGradient:{default:null},fillRule:{default:"nonzero"},strokeLinejoin:{default:"miter"},strokeLinecap:{default:"butt"},strokeMiterlimit:{default:4,validate:ak},lineStyle:{default:"solid"},dashLength:{default:8},gapLength:{default:4},dashOffset:{default:0},strokeDasharray:{default:null},colorInterpolation:{default:null},filters:{default:[]},filterColorInterpolation:{default:null},filterUnits:{default:null},primitiveUnits:{default:null},filterX:{default:null},filterY:{default:null},filterWidth:{default:null},filterHeight:{default:null},metadata:{default:null},cssClipPath:{default:null},cssMaskProperties:{default:null}},ln={...Je,cx:{default:0},cy:{default:0},radius:{default:50,validate:he},cornerRadius:{default:0,validate:he},shiftAngle:{default:0}},Di={...Je,x:{default:0},y:{default:0},width:{default:100,validate:he},height:{default:60,validate:he}},Fh={...Je,x:{default:0},y:{default:0},width:{default:0,validate:he},height:{default:0,validate:he},href:{default:""},mediaMimeType:{default:""},originalWidth:{default:0},originalHeight:{default:0},naturalDuration:{default:0},preserveAspectRatio:{default:!0},begin:{default:0},trimStart:{default:0},volume:{default:1,validate:Oi},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:Oi},fadeInDuration:{default:0,validate:he},fadeOutDuration:{default:0,validate:he},posterHref:{default:""},sourceRect:{default:null}},ue=new Jo;ue.register("rectangle",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:he},height:{default:100,validate:he},rx:{default:0,validate:he},ry:{default:0,validate:he},cornerRadius:{default:0,validate:he},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:he},cornerRadiusTR:{default:0,validate:he},cornerRadiusBL:{default:0,validate:he},cornerRadiusBR:{default:0,validate:he},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});ue.register("square",{...Je,x:{default:0},y:{default:0},size:{default:100,validate:he},width:{default:100,validate:he},height:{default:100,validate:he},rx:{default:0,validate:he},ry:{default:0,validate:he},cornerRadius:{default:0,validate:he},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:he},cornerRadiusTR:{default:0,validate:he},cornerRadiusBL:{default:0,validate:he},cornerRadiusBR:{default:0,validate:he},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});ue.register("circle",{...Je,x:{default:0},y:{default:0},radius:{default:50,validate:he}});ue.register("ellipse",{...Je,cx:{default:0},cy:{default:0},rx:{default:50,validate:he},ry:{default:30,validate:he}});ue.register("line",{...Je,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});ue.register("text",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:he},height:{default:0,validate:he},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},shapeInsideRef:{default:null},shapePadding:{default:0}});ue.register("image",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:he},height:{default:100,validate:he},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:Oi}});ue.register("path",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:he},height:{default:0,validate:he},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});ue.register("polyline",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:he},height:{default:0,validate:he},polylinePoints:{default:[]},polylineClosed:{default:!1}});ue.register("triangle",{...ln,sides:{default:3}});ue.register("ngon",{...ln,sides:{default:6,validate:ck}});ue.register("star",{...ln,arms:{default:5,validate:lk},innerRadiusPercent:{default:40,validate:ot}});ue.register("cross",{...ln,armWidthPercent:{default:30,validate:ot}});ue.register("ring",{...ln,innerRadiusPercent:{default:50,validate:ot}});ue.register("spiral",{...ln,turns:{default:3,validate:uk},thicknessPercent:{default:15,validate:ot},spiralDirection:{default:1}});ue.register("gear",{...ln,teeth:{default:8,validate:dk},toothDepthPercent:{default:25,validate:ot},holeRadiusPercent:{default:20,validate:ot}});ue.register("arrow",{...ln,headWidthPercent:{default:100,validate:ot},headLengthPercent:{default:40,validate:ot},shaftWidthPercent:{default:40,validate:ot}});ue.register("symbol-instance",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:he},height:{default:100,validate:he},symbolId:{default:""}});ue.register("group",{...Je});ue.register("container",{...Je});ue.register("cloud",{...ln,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:ot}});ue.register("heart",{...ln,lobeRadiusPercent:{default:50,validate:ot},cleftDepthPercent:{default:25,validate:ot}});ue.register("lightning",{...ln,boltSegments:{default:3},boltWidthPercent:{default:30,validate:ot},boltJaggednessPercent:{default:40,validate:ot}});ue.register("speechBubble",{...ln,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:ot},tailWidthPercent:{default:25,validate:ot}});ue.register("diamond",{...Di});ue.register("parallelogram",{...Di,slantPercent:{default:20,validate:ot}});ue.register("trapezoid",{...Di,topWidthPercent:{default:70,validate:ot}});ue.register("terminator",{...Di});ue.register("cylinder",{...Di,capHeightPercent:{default:15,validate:ot}});ue.register("document-shape",{...Di,waveAmplitudePercent:{default:15,validate:ot}});ue.register("hyperlink",{...Je,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});ue.register("switch",{...Je,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});ue.register("svg",{...Je});ue.register("view",{...Je,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:he},viewBoxHeight:{default:0,validate:he},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});ue.register("shape-reference",{...Je,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:he},targetHeight:{default:0,validate:he},broken:{default:!1}});ue.register("foreign-object",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:he},height:{default:0,validate:he},rawContent:{default:""}});ue.register("video",{...Fh,mediaKind:{default:"video"}});ue.register("audio",{...Fh,mediaKind:{default:"audio"}});ue.register("document",{});function Yr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function dn(t,e,n=""){if(!Yr(t))return;e.onShape?.(t,n);let r=t.state;if(!Yr(r))return;let i=r.children;if(Array.isArray(i)&&i.forEach((o,s)=>{dn(o,e,`${n}.state.children[${s}]`)}),e.onState){let o=r.symbolOverrides;if(Yr(o))for(let[s,a]of Object.entries(o))Yr(a)&&e.onState(a,`${n}.state.symbolOverrides[${s}]`);e.onState(r,`${n}.state`)}}function ac(t,e,n){Array.isArray(t)&&t.forEach((r,i)=>dn(r,e,`${n}[${i}]`))}function et(t,e){Yr(t)&&(ac(t.shapes,e,"shapes"),Array.isArray(t.library)&&t.library.forEach((n,r)=>{if(Yr(n))if(n.kind==="symbol"){if(ac(n.shapes,e,`library[${r}].shapes`),Yr(n.variants))for(let[i,o]of Object.entries(n.variants))ac(o,e,`library[${r}].variants[${i}]`)}else n.kind==="marker"&&ac(n.shapes,e,`library[${r}].shapes`)}))}function mk(){let t=new Set(Dp);for(let e of zp)t.add(e);for(let e of ue.typeIds())for(let n of Object.keys(ue.getDefaults(e)))t.add(n);return t.delete("scaleAnchor"),t.delete("extra"),t}var Bp=mk(),Lh=new Set(["scaleAnchor","displayAttr"]);function Qo(t){let e=t.extra&&typeof t.extra=="object"&&!Array.isArray(t.extra)?t.extra:void 0;for(let n of Object.keys(t)){if(n==="extra"||Bp.has(n))continue;let r=t[n];delete t[n],r!==void 0&&((e??={})[n]=r)}return e&&Object.keys(e).length>0?t.extra=e:delete t.extra,t}function cc(t){return dn(t,{onState:e=>{Qo(e)}}),t}function lc(t){return dn(t,{onState:e=>{hr(e)}}),t}function hr(t){let e=t.extra;if(!e||typeof e!="object"||Array.isArray(e))return delete t.extra,t;for(let[n,r]of Object.entries(e))n!=="extra"&&(n in t||(t[n]=r));return delete t.extra,t}function qr(t,e,n,r="verbatim"){if(r==="verbatim")return new Yt(t,e,n&&"extra"in n?hr({...n}):n);let i={...ue.getDefaults(e),...n},o=ue.get(e);if(o)for(let s of Object.keys(i)){let a=o[s];a?.validate&&i[s]!==void 0&&(i[s]=a.validate(i[s]))}return new Yt(t,e,i)}var Yt=class t{static writeHook=null;static _baseReadDepth=0;static withBaseProps(e){t._baseReadDepth++;try{return e()}finally{t._baseReadDepth--}}id;type;parent=null;children=[];onChange=null;_props;_dirty=new Set;_preservedSerializedState=null;_overlay=null;_propTimestamps=new Map;constructor(e,n,r){this.id=e,this.type=n,this._props=r?{...r}:{}}get(e){return this._overlay!==null&&t._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}set(e,n){this._props[e]!==n&&(this._preservedSerializedState=null,t.writeHook?.(this,e),this._props[e]=n,this._dirty.add(e),this.onChange?.(this,this._dirty))}getProp(e){return this._overlay!==null&&t._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}getBaseProp(e){return this._props[e]}setProp(e,n){this._props[e]!==n&&(this._preservedSerializedState=null,t.writeHook?.(this,e),this._props[e]=n,this._dirty.add(e),this.onChange?.(this,this._dirty))}deleteProp(e){e in this._props&&(this._preservedSerializedState=null,t.writeHook?.(this,e),delete this._props[e],this._dirty.add(e),this.onChange?.(this,this._dirty))}setMany(e){let n=!1;for(let[r,i]of Object.entries(e))this._props[r]!==i&&(this._preservedSerializedState=null,t.writeHook?.(this,r),this._props[r]=i,this._dirty.add(r),n=!0);n&&this.onChange?.(this,this._dirty)}setOverlayValue(e,n){this._overlay===null&&(this._overlay=new Map),this._overlay.set(e,n)}deleteOverlayValue(e){if(this._overlay===null)return!1;let n=this._overlay.delete(e);return this._overlay.size===0&&(this._overlay=null),n}getOverlayValue(e){return this._overlay?.get(e)}hasOverlayValue(e){return this._overlay?.has(e)??!1}overlayKeys(){return this._overlay?[...this._overlay.keys()]:[]}clearOverlay(){if(this._overlay===null)return[];let e=[...this._overlay.keys()];return this._overlay=null,e}get hasOverlay(){return this._overlay!==null}getDirtyKeys(){return this._dirty}clearDirty(){this._dirty.clear()}isDirty(){return this._dirty.size>0}getProps(){return this._props}snapshotProps(){return structuredClone(this._props)}restoreProps(e){this._preservedSerializedState=null,this._props=structuredClone(e);for(let n of Object.keys(this._props))this._dirty.add(n);this.onChange?.(this,this._dirty)}getPropStamp(e){return this._propTimestamps.get(e)??null}stampProp(e,n,r){this._propTimestamps.set(e,{ts:n,clientId:r})}stampProps(e,n,r){let i={ts:n,clientId:r};for(let o of e)this._propTimestamps.set(o,i)}getPropStampsForKeys(e){let n={};for(let r of e){let i=this._propTimestamps.get(r);i&&(n[r]=i.ts)}return n}snapshotPropTimestamps(){return new Map(this._propTimestamps)}restorePropTimestamps(e){this._propTimestamps=new Map(e)}preserveSerializedState(e){this._preservedSerializedState=structuredClone(e)}hasPreservedSerializedState(){return this._preservedSerializedState!==null}toSerialized(){return{id:this.id,type:this.type,state:this._preservedSerializedState?structuredClone(this._preservedSerializedState):{...this._props}}}static fromSerialized(e){return qr(e.id,e.type,structuredClone(e.state),"verbatim")}static create(e,n,r){return qr(e,n,r,"authoring")}};var gk=5e3,hk=1e4;function yk(t){return t===null||t.size===0?"":[...t.entries()].sort((e,n)=>n[1].count-e[1].count).slice(0,5).map(([e,n])=>`${e.type}#${e.id} x${n.count} keys=[${[...n.keys].join(",")}]`).join("; ")}var yr=class t{static _activeInstanceCount=0;static _createdInstanceCount=0;static _disposedInstanceCount=0;static _pendingGraphs=new Set;static flushAllPending(){if(t._pendingGraphs.size!==0)for(let e of[...t._pendingGraphs])e.flushBatched()}static get pendingGraphCount(){return t._pendingGraphs.size}static get activeInstanceCount(){return t._activeInstanceCount}static get createdInstanceCount(){return t._createdInstanceCount}static get disposedInstanceCount(){return t._disposedInstanceCount}root;_nodesById=new Map;_batchDepth=0;_batchDirtyNodes=new Map;_draining=!1;_changeListeners=[];_structureListeners=[];_disposed=!1;constructor(){t._activeInstanceCount++,t._createdInstanceCount++,this.root=qr("__root__","document"),this._nodesById.set(this.root.id,this.root)}onNodeChange(e){return this._disposed?()=>{}:(this._changeListeners.push(e),()=>{let n=this._changeListeners.indexOf(e);n>=0&&this._changeListeners.splice(n,1)})}onStructureChange(e){return this._disposed?()=>{}:(this._structureListeners.push(e),()=>{let n=this._structureListeners.indexOf(e);n>=0&&this._structureListeners.splice(n,1)})}addNode(e,n,r){if(this._disposed)return;let i=n??this.root;r!==void 0&&r>=0&&r<i.children.length?i.children.splice(r,0,e):i.children.push(e),e.parent=i,this._nodesById.set(e.id,e),e.onChange=this._handleNodeChange.bind(this),this._emitStructure("add",e,null,i)}removeNode(e){if(this._disposed)return null;let n=this._nodesById.get(e);if(!n||n===this.root)return null;let r=n.parent,i=null;if(r){let o=r.children.indexOf(n);i={parentId:r===this.root?null:r.id,index:o},o>=0&&r.children.splice(o,1)}return n.parent=null,n.onChange=null,this._nodesById.delete(e),this._batchDirtyNodes.delete(n),this._removeDescendants(n),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),this._emitStructure("remove",n,r,null,i),n}getNode(e){return this._nodesById.get(e)??null}moveNode(e,n,r){if(this._disposed)return;let i=this._nodesById.get(e);if(!i||i===this.root)return;if(n===i||this.isAncestor(e,n.id))throw new Error(`Cannot move scene node "${e}" below itself or one of its descendants.`);let o=i.parent,s=null;if(o){let a=o.children.indexOf(i);s={parentId:o===this.root?null:o.id,index:a},a>=0&&o.children.splice(a,1)}r!==void 0&&r>=0&&r<n.children.length?n.children.splice(r,0,i):n.children.push(i),i.parent=n,this._emitStructure("move",i,o,n,s)}moveNodeToParentId(e,n,r){if(this._disposed)return;let i=n?this._nodesById.get(n):this.root;i&&this.moveNode(e,i,r)}getChildren(e){let n=e?this._nodesById.get(e):this.root;return n?[...n.children]:[]}getRootShapes(){return[...this.root.children]}getParentId(e){let n=this._nodesById.get(e);return!n||!n.parent||n.parent===this.root?null:n.parent.id}getSiblingIndex(e){let n=this._nodesById.get(e);return!n||!n.parent?-1:n.parent.children.indexOf(n)}getAncestorIds(e){let n=[],r=new Set,i=this.getParentId(e);for(;i;){if(r.has(i))throw new Error(`Scene graph cycle detected while resolving ancestors of "${e}".`);r.add(i),n.push(i),i=this.getParentId(i)}return n}isAncestor(e,n){if(e===n)return!1;let r=new Set,i=this.getParentId(n);for(;i;){if(i===e)return!0;if(r.has(i))throw new Error(`Scene graph cycle detected while resolving ancestry of "${n}".`);r.add(i),i=this.getParentId(i)}return!1}isDocumentRootNode(e){let n=this._nodesById.get(e);return!!n&&n!==this.root&&n.getProp("isRootSvg")===!0}contains(e,n){if(e===n)return!1;if(this.isDocumentRootNode(e)){let r=this._nodesById.get(n);return!!r&&r!==this.root&&!this.isDocumentRootNode(n)}return this.isAncestor(e,n)}getDepth(e){let n=this._nodesById.get(e);if(!n||n===this.root)return-1;let r=0,i=n.parent;for(;i&&i!==this.root;)r++,i=i.parent;return r}getAllNodes(){let e=[];for(let n of this._nodesById.values())n!==this.root&&e.push(n);return e}getDirtyNodes(){let e=[];for(let n of this._nodesById.values())n.isDirty()&&e.push(n);return e}clearAllDirty(){for(let e of this._nodesById.values())e.clearDirty()}beginBatch(){this._disposed||this._batchDepth++}commitBatch(){this._disposed||(this._batchDepth=Math.max(0,this._batchDepth-1),this._batchDepth===0&&this._drainBatched())}flushBatched(){this._disposed||this._batchDirtyNodes.size>0&&this._drainBatched()}get hasPendingBatched(){return this._batchDirtyNodes.size>0}get isBatching(){return this._batchDepth>0}get isDraining(){return this._draining}get isDisposed(){return this._disposed}get listenerCount(){return this._changeListeners.length+this._structureListeners.length}dispose(){if(!this._disposed){this._disposed=!0,t._activeInstanceCount--,t._disposedInstanceCount++,t._pendingGraphs.delete(this),this._batchDirtyNodes.clear(),this._batchDepth=0,this._draining=!1,this._changeListeners.length=0,this._structureListeners.length=0;for(let e of this._nodesById.values())e.onChange=null}}notifyNodeChanged(e,n){this._disposed||this._handleNodeChange(e,n)}_handleNodeChange(e,n){if(!this._disposed){if(this._batchDepth>0){let r=this._batchDirtyNodes.get(e);r||(r=new Set,this._batchDirtyNodes.set(e,r),t._pendingGraphs.add(this));for(let i of n)r.add(i);return}this._fireChangeListeners(e,n)}}_drainBatched(){if(this._disposed||this._draining)return;this._draining=!0;let e=0,n=null;try{for(;this._batchDirtyNodes.size>0;){if(++e>hk){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",yk(n)),this._batchDirtyNodes.clear();break}let[r,i]=this._batchDirtyNodes.entries().next().value;if(this._batchDirtyNodes.delete(r),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),e>gk){n===null&&(n=new Map);let o=n.get(r);if(o){o.count++;for(let s of i)o.keys.add(s)}else n.set(r,{count:1,keys:new Set(i)})}this._fireChangeListeners(r,i)}}finally{this._draining=!1,this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this)}}_fireChangeListeners(e,n){if(this._disposed)return;let r=[...this._changeListeners];for(let i of r)i(e,n)}_emitStructure(e,n,r,i,o=null){if(this._disposed)return;let s=[...this._structureListeners];for(let a of s)a(e,n,r,i,o)}_removeDescendants(e){for(let n of e.children)n.onChange=null,this._nodesById.delete(n.id),this._batchDirtyNodes.delete(n),this._removeDescendants(n)}serializeShapes(){let e=[],n=r=>{for(let i of r)i.type!=="document"&&i.type!=="group"&&i.getProp("structural")!==!0&&e.push(i.toSerialized()),i.children.length>0&&n(i.children)};return n(this.root.children),e}static fromShapes(e){let n=new t;for(let r of e){let i=Yt.fromSerialized(r);n.addNode(i)}return n}clone(){let e=new t,n=(r,i)=>{for(let o of r.children){let s=o.toSerialized(),a=Yt.fromSerialized(s);o.hasPreservedSerializedState()&&a.preserveSerializedState(s.state),a.restorePropTimestamps(o.snapshotPropTimestamps()),e.addNode(a,i),n(o,a)}};return n(this.root,e.root),e}};var Ne=["updatedAt","clientId"];function pe(t,e,n){t.push({path:e,message:n})}function qh(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ke(t,e,n){return qh(t)?t:(pe(n,e,"must be an object"),null)}function le(t,e,n,r=[],i,o=!0){let s=new Set([...o?["type"]:[],...n,...r]);for(let a of n)Object.hasOwn(t,a)||pe(i,`${e}.${a}`,"is required");for(let a of Object.keys(t))s.has(a)||pe(i,`${e}.${a}`,"is not allowed")}function Q(t,e,n,r=!1){return typeof t!="string"||!r&&t.length===0?(pe(n,e,r?"must be a string":"must be a non-empty string"),!1):!0}function $t(t,e,n,r){return typeof t!="number"||!Number.isFinite(t)?(pe(n,e,"must be a finite number"),!1):r!==void 0&&t<r?(pe(n,e,`must be at least ${r}`),!1):!0}function bn(t,e,n,r=0){return $t(t,e,n,r)?Number.isInteger(t)?!0:(pe(n,e,"must be an integer"),!1):!1}function zi(t,e,n){return typeof t!="boolean"?(pe(n,e,"must be a boolean"),!1):!0}function Qe(t,e,n,r,i=!1){t[e]!==void 0&&Q(t[e],`${n}.${e}`,r,i)}function Zr(t,e,n,r,i){t[e]!==void 0&&$t(t[e],`${n}.${e}`,r,i)}function Ct(t,e,n,r,i=0){t[e]!==void 0&&bn(t[e],`${n}.${e}`,r,i)}function es(t,e,n,r){t[e]!==void 0&&zi(t[e],`${n}.${e}`,r)}function Jr(t,e,n){return Array.isArray(t)?(t.forEach((r,i)=>Q(r,`${e}[${i}]`,n)),!0):(pe(n,e,"must be an array"),!1)}function st(t,e,n,r){return Array.isArray(t)?(t.forEach((i,o)=>r(i,`${e}[${o}]`,n)),!0):(pe(n,e,"must be an array"),!1)}function yt(t,e,n){let r=[{value:t,path:e,depth:0}],i=0;for(;r.length>0;){let o=r.pop();if(i++,i>25e4){pe(n,e,"exceeds the 250000-node validation limit");return}if(o.depth>64){pe(n,o.path,"exceeds the 64-level nesting limit");continue}let s=o.value;if(!(s===null||typeof s=="string"||typeof s=="boolean")){if(typeof s=="number"){Number.isFinite(s)||pe(n,o.path,"must be a finite JSON number");continue}if(Array.isArray(s)){s.forEach((a,c)=>r.push({value:a,path:`${o.path}[${c}]`,depth:o.depth+1}));continue}if(qh(s)){for(let[a,c]of Object.entries(s))r.push({value:c,path:`${o.path}.${a}`,depth:o.depth+1});continue}pe(n,o.path,"must be JSON-serializable")}}}function Ae(t,e,n){Zr(t,"updatedAt",e,n,0),Qe(t,"clientId",e,n)}function Gp(t,e,n){let r=ke(t,e,n);if(r)for(let[i,o]of Object.entries(r))Q(o,`${e}.${i}`,n,!0)}function dc(t,e,n,r=0){if(r>64){pe(n,e,"exceeds the 64-level shape nesting limit");return}let i=ke(t,e,n);if(!i)return;le(i,e,["id","type","state"],[],n),Q(i.id,`${e}.id`,n),Q(i.type,`${e}.type`,n);let o=ke(i.state,`${e}.state`,n);o&&(Object.hasOwn(o,"extra")&&pe(n,`${e}.state.extra`,"is an at-rest field and is not allowed in operations"),yt(o,`${e}.state`,n),o.children!==void 0&&st(o.children,`${e}.state.children`,n,(s,a,c)=>dc(s,a,c,r+1)))}function Sk(t,e,n){let r=ke(t,e,n);r&&(Object.hasOwn(r,"extra")&&pe(n,`${e}.extra`,"is an at-rest field and is not allowed in operations"),yt(r,e,n),r.children!==void 0&&st(r.children,`${e}.children`,n,(i,o,s)=>dc(i,o,s)))}function bk(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.type!=="clip"&&r.type!=="mask"&&pe(n,`${e}.type`,'must be "clip" or "mask"'),Jr(r.clipShapeIds,`${e}.clipShapeIds`,n),Jr(r.contentShapeIds,`${e}.contentShapeIds`,n),r.parentId!==null&&Q(r.parentId,`${e}.parentId`,n),Ct(r,"siblingIndex",e,n),yt(r,e,n))}function Bh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&pe(n,`${e}.orientation`,'must be "horizontal" or "vertical"'),$t(r.position,`${e}.position`,n),$t(r.controlPointOffset,`${e}.controlPointOffset`,n),Qe(r,"color",e,n,!0),Zr(r,"opacity",e,n),yt(r,e,n))}function Gh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.type!=="distance"&&r.type!=="angle"&&pe(n,`${e}.type`,'must be "distance" or "angle"'),st(r.points,`${e}.points`,n,(i,o,s)=>{let a=ke(i,o,s);a&&($t(a.x,`${o}.x`,s),$t(a.y,`${o}.y`,s))}),zi(r.visible,`${e}.visible`,n),bn(r.snapDivisions,`${e}.snapDivisions`,n,1),Qe(r,"color",e,n,!0),Zr(r,"opacity",e,n),yt(r,e,n))}var Vh=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawMetadataAuthoritative","rawDescription","rawHtmlMetadata","descriptiveElements","coordinatePrecision"];function jh(t,e,n,r){let i=ke(t,e,n);if(!i)return;le(i,e,r?[]:["title","description","author","keywords","license","licenseUrl","language","customMetadata"],r?Vh:Vh.slice(8),n,!1);for(let s of["title","description","author","license","licenseUrl","language"])(!r||i[s]!==void 0)&&Q(i[s],`${e}.${s}`,n,!0);(!r||i.keywords!==void 0)&&Jr(i.keywords,`${e}.keywords`,n),(!r||i.customMetadata!==void 0)&&Gp(i.customMetadata,`${e}.customMetadata`,n),Qe(i,"rawMetadata",e,n,!0),es(i,"rawMetadataAuthoritative",e,n),Qe(i,"rawDescription",e,n,!0),Qe(i,"rawHtmlMetadata",e,n,!0),i.descriptiveElements!==void 0&&st(i.descriptiveElements,`${e}.descriptiveElements`,n,(s,a,c)=>{let l=ke(s,a,c);l&&(le(l,a,["kind","language","text","rawXml"],[],c,!1),l.kind!=="title"&&l.kind!=="desc"&&pe(c,`${a}.kind`,'must be "title" or "desc"'),l.language!==null&&Q(l.language,`${a}.language`,c,!0),Q(l.text,`${a}.text`,c,!0),Q(l.rawXml,`${a}.rawXml`,c,!0))}),Ct(i,"coordinatePrecision",e,n)}function Uh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.source!=="inline"&&r.source!=="external"&&pe(n,`${e}.source`,'must be "inline" or "external"'),Q(r.content,`${e}.content`,n,!0),Q(r.type,`${e}.type`,n,!0),Qe(r,"svgId",e,n,!0),Qe(r,"href",e,n,!0),es(r,"async",e,n),es(r,"defer",e,n),r.customAttrs!==void 0&&Gp(r.customAttrs,`${e}.customAttrs`,n),yt(r,e,n))}function Hh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.css,`${e}.css`,n,!0),zi(r.preserved,`${e}.preserved`,n),Qe(r,"svgId",e,n,!0),Qe(r,"type",e,n,!0),Qe(r,"media",e,n,!0),r.customAttrs!==void 0&&Gp(r.customAttrs,`${e}.customAttrs`,n),yt(r,e,n))}function Wh(t,e,n){let r=ke(t,e,n);if(r){if(Q(r.name,`${e}.name`,n),["string","color","number"].includes(String(r.type))||pe(n,`${e}.type`,'must be "string", "color", or "number"'),Q(r.defaultValue,`${e}.defaultValue`,n,!0),Qe(r,"label",e,n,!0),Qe(r,"description",e,n,!0),r.mode!==void 0&&r.mode!=="live"&&r.mode!=="stamped"&&pe(n,`${e}.mode`,'must be "live" or "stamped"'),r.source!==void 0){let i=ke(r.source,`${e}.source`,n);i&&i.kind!=="user"&&pe(n,`${e}.source.kind`,'must be "user"')}yt(r,e,n)}}function Kh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.filename,`${e}.filename`,n,!0),Q(r.format,`${e}.format`,n),yt(r,e,n))}function vk(t,e,n){let r=ke(t,e,n);r&&(bn(r.glyphId,`${e}.glyphId`,n),Array.isArray(r.codepoints)?r.codepoints.forEach((i,o)=>bn(i,`${e}.codepoints[${o}]`,n)):pe(n,`${e}.codepoints`,"must be an array"),Q(r.svgDocument,`${e}.svgDocument`,n,!0),Qe(r,"glyphName",e,n,!0),Ct(r,"advanceWidth",e,n),Qe(r,"sourceFamily",e,n,!0),Ct(r,"sourceGlyphId",e,n),Qe(r,"label",e,n,!0),yt(r,e,n))}function Xh(t,e,n){let r=ke(t,e,n);if(!r)return;Q(r.id,`${e}.id`,n);let i=["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"],o=r.role===void 0?"resource":String(r.role);o!=="resource"&&o!=="referenced-fragment"&&pe(n,`${e}.role`,"is not a supported raw SVG definition role");let s=String(r.type);(o==="resource"&&!i.includes(s)||o==="referenced-fragment"&&!/^[A-Za-z][\w.-]*$/u.test(s))&&pe(n,`${e}.type`,"is not a supported paint-server type"),Q(r.markup,`${e}.markup`,n),r.definitionChildIds!==void 0&&Jr(r.definitionChildIds,`${e}.definitionChildIds`,n),r.sourceDefinitionChildIds!==void 0&&Jr(r.sourceDefinitionChildIds,`${e}.sourceDefinitionChildIds`,n),Array.isArray(r.definitionChildIds)&&Array.isArray(r.sourceDefinitionChildIds)&&r.definitionChildIds.length!==r.sourceDefinitionChildIds.length&&pe(n,e,"definition child id arrays must have equal lengths"),es(r,"passthrough",e,n),yt(r,e,n)}function Yh(t,e,n){let r=ke(t,e,n);if(!r)return;Q(r.id,`${e}.id`,n),Q(r.name,`${e}.name`,n,!0),r.metadata!==void 0&&yt(r.metadata,`${e}.metadata`,n);let i=r.kind;if(["symbol","marker","linear-gradient","radial-gradient","pattern","filter"].includes(String(i))||pe(n,`${e}.kind`,"is not a supported library kind"),(i==="symbol"||i==="marker")&&st(r.shapes,`${e}.shapes`,n,dc),i==="symbol"){r.defKind!==void 0&&!["symbol","group","shape"].includes(String(r.defKind))&&pe(n,`${e}.defKind`,'must be "symbol", "group", or "shape"'),r.defKind==="shape"&&(!Array.isArray(r.shapes)||r.shapes.length!==1)&&pe(n,`${e}.shapes`,"must contain exactly one native root shape");for(let o of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])Qe(r,o,e,n,!0);if(r.rootAttributes!==void 0){let o=ke(r.rootAttributes,`${e}.rootAttributes`,n);if(o)for(let[s,a]of Object.entries(o))["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(s)&&pe(n,`${e}.rootAttributes.${s}`,"must use its typed symbol field"),Q(a,`${e}.rootAttributes.${s}`,n,!0)}for(let o of["wrapperAttrs","groups","overflow"])r[o]!==void 0&&pe(n,`${e}.${o}`,"is schema-v7 migration input only")}if(i==="marker"){Qe(r,"viewBox",e,n,!0),Qe(r,"preserveAspectRatio",e,n,!0);for(let o of["refX","refY","markerWidth","markerHeight"])$t(r[o],`${e}.${o}`,n);if(r.markerUnits!=="strokeWidth"&&r.markerUnits!=="userSpaceOnUse"&&pe(n,`${e}.markerUnits`,'must be "strokeWidth" or "userSpaceOnUse"'),r.orient!=="auto"&&r.orient!=="auto-start-reverse"&&!(typeof r.orient=="number"&&Number.isFinite(r.orient))&&pe(n,`${e}.orient`,"must be an orientation keyword or finite number"),r.authoredGeometry!==void 0){let o=ke(r.authoredGeometry,`${e}.authoredGeometry`,n);if(o)for(let s of["refX","refY","markerWidth","markerHeight","markerUnits","orient"])Qe(o,s,`${e}.authoredGeometry`,n,!0)}if(r.rootAttributes!==void 0){let o=ke(r.rootAttributes,`${e}.rootAttributes`,n);if(o)for(let[s,a]of Object.entries(o))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(s)&&pe(n,`${e}.rootAttributes.${s}`,"must use its typed marker field"),Q(a,`${e}.rootAttributes.${s}`,n,!0)}}if(i==="linear-gradient"||i==="radial-gradient"){let o=`${e}.gradient`,s=ke(r.gradient,o,n);if(s){let a=i==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let c of a)Zr(s,c,o,n);if(Zr(s,"fr",o,n),s.authoredGeometry!==void 0){let c=`${o}.authoredGeometry`,l=ke(s.authoredGeometry,c,n);if(l){let d=new Set(i==="linear-gradient"?["x1","y1","x2","y2","gradientTransform"]:["cx","cy","fx","fy","r","fr","gradientTransform"]);for(let[u,p]of Object.entries(l))d.has(u)?Q(p,`${c}.${u}`,n,!0):pe(n,`${c}.${u}`,"is not allowed")}}if(s.gradientTransform!==void 0){let c=s.gradientTransform;(!Array.isArray(c)||c.length!==6||!c.every(l=>typeof l=="number"&&Number.isFinite(l)))&&pe(n,`${o}.gradientTransform`,"must be a 6-element finite affine matrix")}st(s.stops,`${o}.stops`,n,(c,l,d)=>{let u=ke(c,l,d);u&&($t(u.offset,`${l}.offset`,d),Q(u.color,`${l}.color`,d,!0),Zr(u,"opacity",l,d))})}}if(i==="pattern"){let o=`${e}.pattern`,s=ke(r.pattern,o,n);if(s){for(let a of["x","y","width","height","scale","rotation","opacity"])Zr(s,a,o,n);s.patternUnits!==void 0&&s.patternUnits!=="userSpaceOnUse"&&s.patternUnits!=="objectBoundingBox"&&pe(n,`${o}.patternUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"'),s.patternContentUnits!==void 0&&s.patternContentUnits!=="userSpaceOnUse"&&s.patternContentUnits!=="objectBoundingBox"&&pe(n,`${o}.patternContentUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"');for(let a of["svgContent","patternTransform","viewBox","preserveAspectRatio"])Qe(s,a,o,n,!0);if(s.authoredGeometry!==void 0){let a=`${o}.authoredGeometry`,c=ke(s.authoredGeometry,a,n);if(c)for(let[l,d]of Object.entries(c))["x","y","width","height"].includes(l)?Q(d,`${a}.${l}`,n,!0):pe(n,`${a}.${l}`,"is not a supported authored pattern field")}}}i==="filter"&&st(r.filters,`${e}.filters`,n,(o,s,a)=>{ke(o,s,a)}),yt(r,e,n)}function Zh(t,e,n,r){let i=ke(t,e,n);i&&((r||i.id!==void 0)&&Q(i.id,`${e}.id`,n),$t(i.time,`${e}.time`,n,0),typeof i.value!="string"&&!(typeof i.value=="number"&&Number.isFinite(i.value))&&!(Array.isArray(i.value)&&i.value.every(o=>typeof o=="number"&&Number.isFinite(o)))&&pe(n,`${e}.value`,"must be a string, finite number, or finite number array"),Q(i.easing,`${e}.easing`,n),yt(i,e,n))}function Jh(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.shapeId,`${e}.shapeId`,n),Q(r.property,`${e}.property`,n),zi(r.enabled,`${e}.enabled`,n),es(r,"locked",e,n),st(r.keyframes,`${e}.keyframes`,n,(i,o,s)=>Zh(i,o,s,!0)),yt(r,e,n))}function xk(t,e,n){let r=ke(t,e,n);r&&($t(r.duration,`${e}.duration`,n,0),zi(r.loop,`${e}.loop`,n),$t(r.playbackSpeed,`${e}.playbackSpeed`,n,0),st(r.tracks,`${e}.tracks`,n,Jh))}function Ik(t,e,n){let r=ke(t,e,n);if(!r)return;bn(r.start,`${e}.start`,n),bn(r.end,`${e}.end`,n),typeof r.start=="number"&&typeof r.end=="number"&&r.end<=r.start&&pe(n,`${e}.end`,"must be greater than start");let i=ke(r.style,`${e}.style`,n);i&&Object.keys(i).length===0&&pe(n,`${e}.style`,"must not be empty"),yt(r,e,n)}function wk(t,e,n){let r=ke(t,e,n);r&&(le(r,e,["start","deleteCount","insert"],[],n,!1),bn(r.start,`${e}.start`,n),bn(r.deleteCount,`${e}.deleteCount`,n),Q(r.insert,`${e}.insert`,n,!0))}var Qh={"shape:add":(t,e,n)=>{le(t,e,["shape"],[],n),dc(t.shape,`${e}.shape`,n)},"shape:update":(t,e,n)=>{if(le(t,e,["id","state"],["propTimestamps","clientId","textSplices","baseSeq"],n),Q(t.id,`${e}.id`,n),Sk(t.state,`${e}.state`,n),t.propTimestamps!==void 0){let r=ke(t.propTimestamps,`${e}.propTimestamps`,n);if(r)for(let[i,o]of Object.entries(r))$t(o,`${e}.propTimestamps.${i}`,n,0)}Qe(t,"clientId",e,n),t.textSplices!==void 0&&st(t.textSplices,`${e}.textSplices`,n,wk),Ct(t,"baseSeq",e,n)},"shape:remove":(t,e,n)=>{le(t,e,["id"],[],n),Q(t.id,`${e}.id`,n)},"text:format":(t,e,n)=>{le(t,e,["id","ranges"],["baseSeq",...Ne],n),Q(t.id,`${e}.id`,n),st(t.ranges,`${e}.ranges`,n,Ik),Ct(t,"baseSeq",e,n),Ae(t,e,n)},"scene:move":(t,e,n)=>{le(t,e,["id","parentId","index"],Ne,n),Q(t.id,`${e}.id`,n),t.parentId!==null&&Q(t.parentId,`${e}.parentId`,n),bn(t.index,`${e}.index`,n),Ae(t,e,n)},"scene:place":(t,e,n)=>{le(t,e,["id","parentId","orderKey"],Ne,n),Q(t.id,`${e}.id`,n),t.parentId!==null&&Q(t.parentId,`${e}.parentId`,n),Q(t.orderKey,`${e}.orderKey`,n),Ae(t,e,n)},"clipMask:upsert":(t,e,n)=>{le(t,e,["clipMaskGroup"],["index",...Ne],n),bk(t.clipMaskGroup,`${e}.clipMaskGroup`,n),Ct(t,"index",e,n),Ae(t,e,n)},"clipMask:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"guides:set":(t,e,n)=>{le(t,e,["guides"],[],n),st(t.guides,`${e}.guides`,n,Bh)},"guide:upsert":(t,e,n)=>{le(t,e,["guide"],["index",...Ne],n),Bh(t.guide,`${e}.guide`,n),Ct(t,"index",e,n),Ae(t,e,n)},"guide:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"guide:move":(t,e,n)=>{le(t,e,["id","index"],Ne,n),Q(t.id,`${e}.id`,n),bn(t.index,`${e}.index`,n),Ae(t,e,n)},"measurements:set":(t,e,n)=>{le(t,e,["measurements"],[],n),st(t.measurements,`${e}.measurements`,n,Gh)},"measurement:upsert":(t,e,n)=>{le(t,e,["measurement"],["index",...Ne],n),Gh(t.measurement,`${e}.measurement`,n),Ct(t,"index",e,n),Ae(t,e,n)},"measurement:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"measurement:move":(t,e,n)=>{le(t,e,["id","index"],Ne,n),Q(t.id,`${e}.id`,n),bn(t.index,`${e}.index`,n),Ae(t,e,n)},"metadata:set":(t,e,n)=>{le(t,e,["metadata"],[],n),jh(t.metadata,`${e}.metadata`,n,!1)},"metadata:patch":(t,e,n)=>{le(t,e,["patch"],["removeKeys",...Ne],n),jh(t.patch,`${e}.patch`,n,!0),t.removeKeys!==void 0&&Jr(t.removeKeys,`${e}.removeKeys`,n),Ae(t,e,n)},"documentScripts:set":(t,e,n)=>{le(t,e,["documentScripts"],[],n),st(t.documentScripts,`${e}.documentScripts`,n,Uh)},"documentScript:upsert":(t,e,n)=>{le(t,e,["documentScript"],["index",...Ne],n),Uh(t.documentScript,`${e}.documentScript`,n),Ct(t,"index",e,n),Ae(t,e,n)},"documentScript:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"documentStyles:set":(t,e,n)=>{le(t,e,["documentStyles"],[],n),st(t.documentStyles,`${e}.documentStyles`,n,Hh)},"documentStyle:upsert":(t,e,n)=>{le(t,e,["documentStyle"],["index",...Ne],n),Hh(t.documentStyle,`${e}.documentStyle`,n),Ct(t,"index",e,n),Ae(t,e,n)},"documentStyle:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"templateVariables:set":(t,e,n)=>{le(t,e,["templateVariables"],Ne,n),st(t.templateVariables,`${e}.templateVariables`,n,Wh),Ae(t,e,n)},"templateVariable:upsert":(t,e,n)=>{le(t,e,["templateVariable"],["index",...Ne],n),Wh(t.templateVariable,`${e}.templateVariable`,n),Ct(t,"index",e,n),Ae(t,e,n)},"templateVariable:remove":(t,e,n)=>{le(t,e,["name"],Ne,n),Q(t.name,`${e}.name`,n),Ae(t,e,n)},"exportItems:set":(t,e,n)=>{le(t,e,["exportItems"],Ne,n),st(t.exportItems,`${e}.exportItems`,n,Kh),Ae(t,e,n)},"exportItem:upsert":(t,e,n)=>{le(t,e,["exportItem"],["index",...Ne],n),Kh(t.exportItem,`${e}.exportItem`,n),Ct(t,"index",e,n),Ae(t,e,n)},"exportItem:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"colorGlyphLibrary:set":(t,e,n)=>{if(le(t,e,["colorGlyphLibrary"],Ne,n),t.colorGlyphLibrary!==null){let r=ke(t.colorGlyphLibrary,`${e}.colorGlyphLibrary`,n);r&&(r.version!==1&&pe(n,`${e}.colorGlyphLibrary.version`,"must be 1"),st(r.entries,`${e}.colorGlyphLibrary.entries`,n,vk),yt(r,`${e}.colorGlyphLibrary`,n))}Ae(t,e,n)},"animation:set":(t,e,n)=>{le(t,e,["animationTimeline"],[],n),t.animationTimeline!==void 0&&xk(t.animationTimeline,`${e}.animationTimeline`,n)},"animation:config":(t,e,n)=>{le(t,e,["config"],Ne,n);let r=ke(t.config,`${e}.config`,n);r&&(le(r,`${e}.config`,["duration","loop","playbackSpeed"],[],n,!1),$t(r.duration,`${e}.config.duration`,n,0),zi(r.loop,`${e}.config.loop`,n),$t(r.playbackSpeed,`${e}.config.playbackSpeed`,n,0)),Ae(t,e,n)},"animation:clear":(t,e,n)=>{le(t,e,[],Ne,n),Ae(t,e,n)},"animationTrack:upsert":(t,e,n)=>{le(t,e,["track"],["index",...Ne],n),Jh(t.track,`${e}.track`,n),Ct(t,"index",e,n),Ae(t,e,n)},"animationTrack:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"animationKeyframe:upsert":(t,e,n)=>{le(t,e,["trackId","keyframe"],Ne,n),Q(t.trackId,`${e}.trackId`,n),Zh(t.keyframe,`${e}.keyframe`,n,!0),Ae(t,e,n)},"animationKeyframe:remove":(t,e,n)=>{le(t,e,["trackId","keyframeId"],Ne,n),Q(t.trackId,`${e}.trackId`,n),Q(t.keyframeId,`${e}.keyframeId`,n),Ae(t,e,n)},"library:set":(t,e,n)=>{le(t,e,["library"],[],n),st(t.library,`${e}.library`,n,Yh)},"library:upsert":(t,e,n)=>{le(t,e,["def"],["index",...Ne],n),Yh(t.def,`${e}.def`,n),Ct(t,"index",e,n),Ae(t,e,n)},"library:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"paintServerDefs:set":(t,e,n)=>{le(t,e,["paintServerDefs"],[],n),st(t.paintServerDefs,`${e}.paintServerDefs`,n,Xh)},"paintServerDef:upsert":(t,e,n)=>{le(t,e,["paintServerDef"],["index",...Ne],n),Xh(t.paintServerDef,`${e}.paintServerDef`,n),Ct(t,"index",e,n),Ae(t,e,n)},"paintServerDef:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"presence:cursor":(t,e,n)=>{le(t,e,["position"],[],n);let r=ke(t.position,`${e}.position`,n);r&&(le(r,`${e}.position`,["x","y"],[],n,!1),$t(r.x,`${e}.position.x`,n),$t(r.y,`${e}.position.y`,n))},"presence:selection":(t,e,n)=>{le(t,e,["shapeIds"],[],n),Jr(t.shapeIds,`${e}.shapeIds`,n)}},kk=new Set(Object.keys(Qh)),ey=new Set(["presence:cursor","presence:selection"]);function uc(t,e="operation"){let n=[],r=ke(t,e,n);return r?!Q(r.type,`${e}.type`,n)||!kk.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&pe(n,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:n}):(Qh[r.type](r,e,n),n.length===0?{valid:!0,value:r}:{valid:!1,issues:n}):{valid:!1,issues:n}}function ty(t,e={}){let n=[];if(!Array.isArray(t))return{valid:!1,issues:[{path:"ops",message:"must be an array"}]};let r=e.minItems??1,i=e.maxItems??5e3;(t.length<r||t.length>i)&&pe(n,"ops",`must contain ${r}-${i} operations`);let o=[];return t.forEach((s,a)=>{let c=uc(s,`ops[${a}]`);if(!c.valid){n.push(...c.issues);return}if(ey.has(c.value.type)){pe(n,`ops[${a}].type`,"presence operations are not document operations");return}o.push(c.value)}),n.length===0?{valid:!0,value:o}:{valid:!1,issues:n}}function ny(t){let e=uc(t,"op");return e.valid?ey.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function ry(t){return t.slice(0,5).map(({path:e,message:n})=>`${e} ${n}`).join("; ")}function pc(t,e,n,r){let i=e[n],o=typeof i=="string"?i:"",s=(t??[]).filter(c=>c[n]!==o),a=typeof r=="number"&&Number.isFinite(r)?Math.max(0,Math.min(r,s.length)):s.length;return s.splice(a,0,e),s}function fc(t,e,n){return(t??[]).filter(r=>r[e]!==n)}function Nt(t,e,n){return pc(t,e,"id",n)}function Ft(t,e){return fc(t,"id",e)}function mc(t,e,n){return pc(t,e,"name",n)}function gc(t,e){return fc(t,"name",e)}function iy(t,e){return JSON.stringify(t)===JSON.stringify(e)}function _i(t,e,n){let r=t?[...t]:[],i=r.find(o=>o.id===e);return i?Nt(r,i,n):r}function oy(t,e,n,r,i){let o=[],s=new Map(t.map(l=>[l.id,l])),a=new Set(e.map(l=>l.id)),c=[...t];for(let l of t)a.has(l.id)||(o.push(r(l.id)),c=Ft(c,l.id));return e.forEach((l,d)=>{let u=s.get(l.id);(!u||!iy(u,l))&&(o.push(n(l,d)),c=Nt(c,l,d))}),e.forEach((l,d)=>{c[d]?.id!==l.id&&(o.push(i(l.id,d)),c=_i(c,l.id,d))}),o}function sy(t,e){return oy(t,e,(n,r)=>({type:"guide:upsert",guide:n,index:r}),n=>({type:"guide:remove",id:n}),(n,r)=>({type:"guide:move",id:n,index:r}))}function ay(t,e){return oy(t,e,(n,r)=>({type:"measurement:upsert",measurement:n,index:r}),n=>({type:"measurement:remove",id:n}),(n,r)=>({type:"measurement:move",id:n,index:r}))}function cy(t,e){let n=t??{},r=e??{},i={},o=[];for(let[s,a]of Object.entries(r))iy(n[s],a)||(i[s]=a);for(let s of Object.keys(n))s in r||o.push(s);return Object.keys(i).length>0||o.length>0?[{type:"metadata:patch",patch:i,removeKeys:o.length>0?o:void 0}]:[]}function ts(t,e){switch(e.type){case"guide:upsert":return Nt(t,e.guide,e.index);case"guide:remove":return Ft(t,e.id);case"guide:move":return _i(t,e.id,e.index)}}function ns(t,e){switch(e.type){case"measurement:upsert":return Nt(t,e.measurement,e.index);case"measurement:remove":return Ft(t,e.id);case"measurement:move":return _i(t,e.id,e.index)}}function ly(t,e){let n=new Set(e.removeKeys??[]),r={};for(let[i,o]of Object.entries({...t??{},...e.patch}))n.has(i)||(r[i]=o);return r}function dy(t,e){if(t===e)return null;let n=0,r=Math.min(t.length,e.length);for(;n<r&&t.charCodeAt(n)===e.charCodeAt(n);)n++;let i=0,o=Math.min(t.length,e.length)-n;for(;i<o&&t.charCodeAt(t.length-1-i)===e.charCodeAt(e.length-1-i);)i++;return{start:n,deleteCount:t.length-n-i,insert:e.slice(n,e.length-i)}}function uy(t,e){return t.slice(0,e.start)+e.insert+t.slice(e.start+e.deleteCount)}function rs(t,e){let n=e.start,r=e.start+e.deleteCount,i=e.insert.length-e.deleteCount,o=t.start,s=t.start+t.deleteCount;return r<=o?{start:o+i,deleteCount:t.deleteCount,insert:t.insert}:n>=s?{start:o,deleteCount:t.deleteCount,insert:t.insert}:n<=o&&r>=s?{start:n+e.insert.length,deleteCount:0,insert:t.insert}:n>=o&&r<=s?{start:o,deleteCount:t.deleteCount+i,insert:t.insert}:n<o?{start:n+e.insert.length,deleteCount:t.deleteCount-(r-o),insert:t.insert}:{start:o,deleteCount:n-o,insert:t.insert}}var Qr=Object.freeze({fontFamily:"Arial",fontSize:16,fontWeight:"normal",fontStyle:"normal",fontVariant:"",fontVariantLigatures:"",fontVariantPosition:"",fontVariantCaps:"",fontVariantNumeric:"",fontVariantEastAsian:"",textDecoration:Object.freeze({underline:!1,strikethrough:!1,overline:!1}),textTransform:"none",baselineShift:"baseline",dominantBaseline:"auto",writingMode:"horizontal-tb",whiteSpace:"pre-wrap",direction:"ltr",unicodeBidi:"normal",textAnchor:"start",letterSpacing:0,wordSpacing:0,lineHeight:1.2,fontVariationSettings:Object.freeze({}),fill:"#000000",fillOpacity:1,stroke:"none",strokeWidth:0,strokeOpacity:1}),Li=Object.keys(Qr);function br(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function qn(t){return typeof t=="string"?t:void 0}function St(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&t.trim()!==""){let e=Number.parseFloat(t);return Number.isFinite(e)?e:void 0}}function Sr(t){return e=>typeof e=="string"&&t.includes(e)?e:void 0}function Pk(t){if(t==="normal"||t==="bold")return t;let e=St(t);return e===400?"normal":e===700?"bold":e}function Tk(t){return t==="baseline"||t==="super"||t==="sub"?t:St(t)}function fy(t){if(typeof t=="string"){let n=t.toLowerCase();return{underline:n.includes("underline"),strikethrough:n.includes("line-through")||n.includes("strikethrough"),overline:n.includes("overline")}}if(!br(t))return;let e={};return typeof t.underline=="boolean"&&(e.underline=t.underline),typeof t.strikethrough=="boolean"&&(e.strikethrough=t.strikethrough),typeof t.overline=="boolean"&&(e.overline=t.overline),e}function my(t){if(!br(t))return;let e={};for(let[n,r]of Object.entries(t)){let i=St(r);i!==void 0&&(e[n]=i)}return e}var gy={fontFamily:qn,fontSize:St,fontWeight:Pk,fontStyle:Sr(["normal","italic","oblique"]),fontVariant:qn,fontVariantLigatures:qn,fontVariantPosition:qn,fontVariantCaps:qn,fontVariantNumeric:qn,fontVariantEastAsian:qn,textTransform:Sr(["none","capitalize","uppercase","lowercase"]),baselineShift:Tk,dominantBaseline:Sr(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:Sr(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:Sr(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:Sr(["ltr","rtl"]),unicodeBidi:Sr(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:Sr(["start","middle","end"]),letterSpacing:St,wordSpacing:St,lineHeight:St,fill:qn,fillOpacity:St,stroke:qn,strokeWidth:St,strokeOpacity:St};function Fi(t,e){return{...t,...e,textDecoration:{...t.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??t.fontVariationSettings}}}function jp(t,e){let n=Object.keys(t);return n.length!==Object.keys(e).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(e,r)&&t[r]===e[r])}function Zn(t,e){for(let n of Li)if(n==="textDecoration"){if(t.textDecoration.underline!==e.textDecoration.underline||t.textDecoration.strikethrough!==e.textDecoration.strikethrough||t.textDecoration.overline!==e.textDecoration.overline)return!1}else if(n==="fontVariationSettings"){if(!jp(t.fontVariationSettings,e.fontVariationSettings))return!1}else if(t[n]!==e[n])return!1;return!0}function Sc(t,e){let n=Object.keys(t).sort(),r=Object.keys(e).sort();if(n.length!==r.length||n.some((i,o)=>i!==r[o]))return!1;for(let i of n)if(i==="textDecoration"){let o=t.textDecoration??{},s=e.textDecoration??{},a=new Set([...Object.keys(o),...Object.keys(s)]);for(let c of a){let l=c;if(o[l]!==s[l])return!1}}else if(i==="fontVariationSettings"){if(!jp(t.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let o=i;if(t[o]!==e[o])return!1}return!0}function hc(t,e){let n={};for(let i of Li)i==="textDecoration"||i==="fontVariationSettings"||t[i]!==e[i]&&(n[i]=t[i]);let r={};return t.textDecoration.underline!==e.textDecoration.underline&&(r.underline=t.textDecoration.underline),t.textDecoration.strikethrough!==e.textDecoration.strikethrough&&(r.strikethrough=t.textDecoration.strikethrough),t.textDecoration.overline!==e.textDecoration.overline&&(r.overline=t.textDecoration.overline),Object.keys(r).length>0&&(n.textDecoration=r),jp(t.fontVariationSettings,e.fontVariationSettings)||(n.fontVariationSettings={...t.fontVariationSettings}),n}function Mn(t,e=Qr){let n=br(t)?t:{},r={...e};for(let i of Li){if(i==="textDecoration"||i==="fontVariationSettings")continue;let o=gy[i](n[i]);o!==void 0&&(r[i]=o)}return r.textDecoration={...e.textDecoration,...fy(n.textDecoration)??{}},r.fontVariationSettings={...my(n.fontVariationSettings)??e.fontVariationSettings},r}function is(t){let e=br(t)?t:{},n={};for(let r of Li){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=gy[r](e[r]);i!==void 0&&(n[r]=i)}if(e.textDecoration!==void 0){let r=fy(e.textDecoration);r&&Object.keys(r).length>0&&(n.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=my(e.fontVariationSettings);r&&(n.fontVariationSettings=r)}return n}function Up(t){let e=[],n=0;for(;;){let r=t.indexOf(`
2
+ `,n);if(r===-1)return e.push({text:t.slice(n),start:n,end:t.length}),e;e.push({text:t.slice(n,r),start:n,end:r}),n=r+1}}function Rk(t,e,n){return t.start===t.end?n&&t.start===e:t.start<=e&&e<t.end}function Vp(t,e,n,r){let i=t;for(let o of e)Rk(o,n,r)&&(i=Fi(i,o.style));return i===t?Fi(t,{}):i}function hy(t,e,n={}){let r=Mn(t.baseStyle),i=typeof t.text=="string"?t.text:"";return Vp(r,Hp(t.runs,i.length),e,n.collapsed===!0)}function ei(t,e=Qr){let n=br(t)?t:{},r=Mn(n.baseStyle,e),i=typeof n.text=="string"?n.text:"";return{text:i,runs:Hp(n.runs,i.length),baseStyle:r,lineHeight:St(n.lineHeight)??r.lineHeight}}function Hp(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!br(r))continue;let i=St(r.start),o=St(r.end);if(i===void 0||o===void 0)continue;let s=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(o),0),e);s>a||n.push({start:s,end:a,style:is(r.style)})}return n}function bc(t){let e=typeof t.text=="string"?t.text:"",n=Mn(t.baseStyle),r=Hp(t.runs,e.length),i=St(t.lineHeight)??n.lineHeight;return{lines:Up(e).map(s=>{if(s.text.length===0)return{segments:[{text:"",style:Vp(n,r,s.start,!0)}]};let a=new Set([s.start,s.end]);for(let d of r)d.start!==d.end&&(d.start>s.start&&d.start<s.end&&a.add(d.start),d.end>s.start&&d.end<s.end&&a.add(d.end));let c=[...a].sort((d,u)=>d-u),l=[];for(let d=0;d<c.length-1;d++){let u=c[d],p=c[d+1],f=Vp(n,r,u,!1),m=l[l.length-1];m&&Zn(m.style,f)?m.text+=e.slice(u,p):l.push({text:e.slice(u,p),style:f})}return{segments:l}}),baseStyle:n,lineHeight:i}}function Jn(t){let e=Mn(t?.baseStyle),n=St(t?.lineHeight)??e.lineHeight,r=Array.isArray(t?.lines)?t.lines:[],i=r.length>0?r:[{segments:[]}],o=[],s=[],a=0;for(let d=0;d<i.length;d++){d>0&&(o.push(`
3
+ `),a+=1);let u=i[d]?.segments,p=Array.isArray(u)?u:[],f=a;for(let m of p){let g=typeof m?.text=="string"?m.text:"";if(g.length===0)continue;let h=Mn(m?.style,e),y=hc(h,e);Object.keys(y).length>0&&s.push({start:a,end:a+g.length,style:y}),o.push(g),a+=g.length}if(a===f){let m=Mn(p[0]?.style,e),g=hc(m,e);Object.keys(g).length>0&&s.push({start:f,end:f,style:g})}}let c=o.join(""),l=[];for(let d of s){let u=l[l.length-1];u!==void 0&&u.start!==u.end&&d.start!==d.end&&(u.end===d.start||u.end+1===d.start&&c.charAt(u.end)===`
4
+ `)&&Sc(u.style,d.style)&&u?u.end=d.end:l.push({start:d.start,end:d.end,style:d.style})}return{text:c,runs:l,baseStyle:e,lineHeight:n}}function ti(t){let e=t.richTextRuns;return br(e)?ei(e):null}function yc(t){let e=new Set;for(let n of Object.keys(t))if(n==="textDecoration")for(let r of Object.keys(t.textDecoration??{}))e.add(`textDecoration.${r}`);else e.add(n);return e}function Ck(t,e){if(t.start===t.end||e.start>=e.end||t.start<e.start||t.end>e.end)return!1;let n=yc(e.style);for(let r of yc(t.style))if(!n.has(r))return!1;return!0}function os(t,e){let n=[...t];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(n=n.filter(i=>!Ck(i,r)),n.push({start:r.start,end:r.end,style:r.style}));return n}function vc(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!br(r))continue;let i=St(r.start),o=St(r.end);if(i===void 0||o===void 0)continue;let s=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(o),0),e);if(s>=a)continue;let c=is(r.style);Object.keys(c).length!==0&&n.push({start:s,end:a,style:c})}return n}function yy(t,e){let n=[];for(let r of t){let i=rs({start:r.start,deleteCount:r.end-r.start,insert:""},e),o=i.start,s=o+i.deleteCount;o>=s||n.push({start:o,end:s,style:r.style})}return n}function py(t,e){return t.start===e.start&&t.end===e.end&&Sc(t.style,e.style)}function Sy(t,e){if(t.text!==e.text||t.lineHeight!==e.lineHeight||!Zn(Mn(t.baseStyle),Mn(e.baseStyle)))return null;let n=Array.isArray(t.runs)?t.runs:[],r=Array.isArray(e.runs)?e.runs:[],i=0,o=0;for(;o<r.length;){let c=-1;for(let l=i;l<n.length;l++)if(py(n[l],r[o])){c=l;break}if(c===-1)break;i=c+1,o++}let s=r.slice(o);if(s.length===0)return null;for(let c of s)if(c.start>=c.end||Object.keys(c.style).length===0)return null;let a=os(n,s);if(a.length!==r.length)return null;for(let c=0;c<a.length;c++)if(!py(a[c],r[c]))return null;return s.map(c=>({start:c.start,end:c.end,style:is(c.style)}))}function $k(t,e){let n=e===0||t.charAt(e-1)===`
5
+ `,r=e===t.length||t.charAt(e)===`
6
+ `;return n&&r}function by(t,e,n){let r=[];for(let i of t){let o=i.start===i.end,s=rs({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=s.start,c=s.start+s.deleteCount;a===c&&(!o||!$k(n,a))||r.push({start:a,end:c,style:i.style})}return r}function ut(t){let e=[...t].sort((i,o)=>i.index-o.index);if(!e.some(i=>i.orderKey))return e;let n=sc(e.length),r=new Map;return e.forEach((i,o)=>{r.set(i.id,i.orderKey??n[o])}),e.sort((i,o)=>{let s=Zo(r.get(i.id)??"",r.get(o.id)??"");return s!==0?s:i.id<o.id?-1:i.id>o.id?1:0})}function At(t){return t.definitionId??`${t.type}-${t.id}`}function xc(t){return t.rawDefinition!==void 0?!0:t.clipShapeIds.length===0}function Ic(t){let e=xc(t);return t.type==="clip"?{type:"clip",...t.clipPathUnits!==void 0?{clipPathUnits:t.clipPathUnits}:{},...!e&&t.clipRule!==void 0?{clipRule:t.clipRule}:{},...e&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}:{type:"mask",...t.maskUnits!==void 0?{maskUnits:t.maskUnits}:{},...t.maskContentUnits!==void 0?{maskContentUnits:t.maskContentUnits}:{},...t.maskType!==void 0?{maskType:t.maskType}:{},...t.maskBounds!==void 0?{maskBounds:structuredClone(t.maskBounds)}:{},...e&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}}function ni(t,e,n){let{clipPathUnits:r,clipRule:i,maskUnits:o,maskContentUnits:s,maskType:a,maskBounds:c,rawDefinition:l,...d}=structuredClone(t),u=e.rawDefinition!==void 0||xc(t);return t.type==="clip"?{...d,type:"clip",...e.clipPathUnits!==void 0?{clipPathUnits:e.clipPathUnits}:{},...!u&&e.clipRule!==void 0?{clipRule:e.clipRule}:{},...u&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}:{...d,type:"mask",...e.maskUnits!==void 0?{maskUnits:e.maskUnits}:{},...e.maskContentUnits!==void 0?{maskContentUnits:e.maskContentUnits}:{},...e.maskType!==void 0?{maskType:e.maskType}:{},...e.maskBounds!==void 0?{maskBounds:structuredClone(e.maskBounds)}:{},...u&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}}function On(t){let e=new Map;for(let n of t??[]){let r=At(n),i=Ic(n),o=e.get(r);i.rawDefinition===void 0&&o?.rawDefinition!==void 0&&(i.rawDefinition=o.rawDefinition),e.set(r,i)}return e}function vn(t){let e=structuredClone(t??[]),n=On(e),r=new Set;return e.map(i=>{let o=At(i),s=n.get(o)??Ic(i),a=s.rawDefinition!==void 0&&!r.has(o);return a&&r.add(o),ni(i,s,a)})}function Qn(t,e){let n=structuredClone(t??[]);if(e.type==="clipMask:remove"){let c=n.find(f=>f.id===e.id);if(!c)return vn(n);let l=At(c),d=On(n).get(l),u=n.filter(f=>f.id!==e.id),p=u.findIndex(f=>At(f)===l);return d&&p>=0&&(u[p]=ni(u[p],d,!0)),vn(u)}let r=n.findIndex(c=>c.id===e.clipMaskGroup.id),i=r>=0?n[r]:void 0,o=i?On(n).get(At(i)):void 0;r>=0&&n.splice(r,1);let s=Math.min(Math.max(0,e.index??n.length),n.length),a=structuredClone(e.clipMaskGroup);return o?.rawDefinition!==void 0&&a.rawDefinition===void 0&&At(i)===At(a)&&(a=ni(a,o,!0)),n.splice(s,0,a),vn(n)}function wc(t,e,n,r){if(!t.some(o=>o.id===e))throw new Error(`Unknown clip/mask group: ${e}`);let i=t.map(o=>o.id===e?ni({...o,definitionId:n},r,r.rawDefinition!==void 0):At(o)!==n?structuredClone(o):ni(o,r,!1));return vn(i)}var Nk=/^structural:(clip|mask):(.+):(group|path|content)$/;function vy(t,e){let n=`structural:${t}:${e}`;return{group:`${n}:group`,path:`${n}:path`,content:`${n}:content`}}function xy(t,e){for(let n of t){e.add(n.id);let r=n.state.children;Array.isArray(r)&&xy(r,e)}}function Iy(t,e=null){let n=[];return t.forEach((r,i)=>{n.push({id:r.id,parentId:e,index:i});let o=r.state.children;Array.isArray(o)&&n.push(...Iy(o,r.id))}),n}function er(t){let e=t.sceneTree&&t.sceneTree.length>0?t.sceneTree:Iy(t.shapes),n=new Map(e.map(I=>[I.id,I])),r=new Map;for(let I of e){let x=r.get(I.parentId)??[];x.push(I),r.set(I.parentId,x)}for(let[I,x]of r)r.set(I,ut(x));let i=I=>Nk.test(I),o=new Set(e.filter(I=>!i(I.id)).map(I=>I.id)),s=new Set;xy(t.shapes,s);let a=new Map,c=new Set,l=(I,x)=>{let k=[];for(let T of r.get(I)??[]){if(!i(T.id)){c.has(T.id)||(c.add(T.id),k.push(T.id));continue}if(x.has(T.id))continue;let w=new Set(x);w.add(T.id),k.push(...l(T.id,w))}return k},d=[null,...o];for(let I of d){let x=l(I,new Set);x.length>0&&a.set(I,x)}for(let I of o){if(c.has(I))continue;let x=n.get(I)?.parentId??null,k=x!==null&&o.has(x)?x:null,T=a.get(k)??[];T.push(I),a.set(k,T),c.add(I)}let u=I=>{for(let[x,k]of a){let T=k.indexOf(I);if(T>=0)return{parentId:x,index:T}}return null},p=I=>{for(let x of a.values()){let k=x.indexOf(I);k>=0&&x.splice(k,1)}},f=t.clipMaskGroups??[],m=On(f),g=new Map(f.map(I=>[vy(I.type,I.id).content,I])),h=(I,x=new Set)=>{if(x.has(I.id))return Number.MAX_SAFE_INTEGER;let k=I.parentId?g.get(I.parentId):void 0;if(!k)return 0;let T=new Set(x);return T.add(I.id),1+h(k,T)},y=[...f].sort((I,x)=>h(I)-h(x)||(I.siblingIndex??0)-(x.siblingIndex??0)),b=new Map;for(let I of y){let x=I.clipShapeIds.filter(M=>s.has(M)),k=I.contentShapeIds.filter(M=>s.has(M)),T=m.get(At(I));if(k.length===0||x.length===0&&!T?.rawDefinition)continue;let w=[...k,...x].map(u).filter(M=>M!==null),P=w[0]?.parentId??null,N=w.length>0?Math.min(...w.map(M=>M.index)):void 0,R=I.parentId===null||o.has(I.parentId)||g.has(I.parentId)?I.parentId:P;for(let M of[...x,...k])p(M);let $=vy(I.type,I.id),A=a.get(R)??[],O=I.siblingIndex??N??A.length,G=Math.min(Math.max(0,O),A.length);A.splice(G,0,$.group),a.set(R,A),a.set($.group,[$.path,$.content]),a.set($.path,[...x]),a.set($.content,[...k]),b.set($.group,{id:$.group,parentId:R,index:0}),b.set($.path,{id:$.path,parentId:$.group,index:0}),b.set($.content,{id:$.content,parentId:$.group,index:1})}let v=[];for(let[I,x]of a)x.forEach((k,T)=>{let w=b.get(k);if(w){v.push({...w,parentId:I,index:T});return}let P=n.get(k);P&&P.parentId===I?v.push({...P,index:T}):v.push({id:k,parentId:I,index:T})});t.sceneTree=v}function qt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wp(t){return qt(t)&&typeof t.updatedAt=="number"&&Number.isSafeInteger(t.updatedAt)&&t.updatedAt>=0&&typeof t.clientId=="string"}function ri(t,e){return{updatedAt:typeof t=="number"&&Number.isSafeInteger(t)&&t>=0?t:0,clientId:e??""}}function ss(t,e){return Wp(e)?t.updatedAt>e.updatedAt||t.updatedAt===e.updatedAt&&t.clientId>=e.clientId:!0}function wy(t){return qt(t.collaborationState)||(t.collaborationState={}),t.collaborationState}function ky(t,e){let n=wy(t);qt(n.shapeProps)||(n.shapeProps={});let r=n.shapeProps;return qt(r[e])||(r[e]={}),r[e]}function as(t,e){let n=t.collaborationState?.shapeProps;if(!qt(n))return{};let r=n[e];return qt(r)?r:{}}function Py(t,e,n,r){if(n.length===0)return;let i=ky(t,e);for(let o of n)ss(r,i[o])&&(i[o]=r)}function Kp(t,e){let n=t.collaborationState?.shapeProps;if(qt(n)){for(let r of e)delete n[r];Ak(t)}}function Ak(t){let e=t.collaborationState;if(qt(e)){for(let n of["shapeProps","resources"]){let r=e[n];qt(r)&&Object.keys(r).length===0&&delete e[n]}Object.keys(e).length===0&&delete t.collaborationState}}function Xp(t){switch(t.type){case"guide:upsert":return`guide:${t.guide.id}`;case"guide:remove":case"guide:move":return`guide:${t.id}`;case"measurement:upsert":return`measurement:${t.measurement.id}`;case"measurement:remove":case"measurement:move":return`measurement:${t.id}`;case"metadata:patch":return"metadata:document";case"documentScript:upsert":return`documentScript:${t.documentScript.id}`;case"documentScript:remove":return`documentScript:${t.id}`;case"documentStyle:upsert":return`documentStyle:${t.documentStyle.id}`;case"documentStyle:remove":return`documentStyle:${t.id}`;case"templateVariable:upsert":return`templateVariable:${t.templateVariable.name}`;case"templateVariable:remove":return`templateVariable:${t.name}`;case"exportItem:upsert":return`exportItem:${t.exportItem.id}`;case"exportItem:remove":return`exportItem:${t.id}`;case"colorGlyphLibrary:set":return"colorGlyphLibrary";case"animation:config":case"animation:clear":case"animationTrack:upsert":case"animationTrack:remove":return"animation:timeline";case"animationKeyframe:upsert":return`animationKeyframe:${t.trackId}:${t.keyframe.id}`;case"animationKeyframe:remove":return`animationKeyframe:${t.trackId}:${t.keyframeId}`;case"clipMask:upsert":return`clipMask:${t.clipMaskGroup.id}`;case"clipMask:remove":return`clipMask:${t.id}`;case"library:upsert":return`library:${t.def.id}`;case"library:remove":return`library:${t.id}`;case"paintServerDef:upsert":return`paintServerDef:${t.paintServerDef.id}`;case"paintServerDef:remove":return`paintServerDef:${t.id}`;default:return null}}function Ty(t,e,n){if(e.type==="shape:update"&&e.propTimestamps){if(!n)return null;let a=as(t,e.id),c={},l={},d=[];for(let[p,f]of Object.entries(e.state)){let m=ri(e.propTimestamps[p],e.clientId);ss(m,a[p])&&(c[p]=f,l[p]=m.updatedAt,d.push([p,m]))}if(d.length===0)return null;let u=ky(t,e.id);for(let[p,f]of d)u[p]=f;return{...e,state:c,propTimestamps:l}}let r=Xp(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=ri(e.updatedAt,e.clientId),o=wy(t);qt(o.resources)||(o.resources={});let s=o.resources;return ss(i,s[r])?(s[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function Ry(t){let e=0,n=t.collaborationState?.shapeProps;if(qt(n)){for(let i of Object.values(n))if(qt(i))for(let o of Object.values(i))Wp(o)&&(e=Math.max(e,o.updatedAt))}let r=t.collaborationState?.resources;if(qt(r))for(let i of Object.values(r))Wp(i)&&(e=Math.max(e,i.updatedAt));for(let i of t.sceneTree??[])typeof i.updatedAt=="number"&&Number.isSafeInteger(i.updatedAt)&&i.updatedAt>=0&&(e=Math.max(e,i.updatedAt));return e}function Cy(t,e){let n=Object.keys(e.state);if(n.length===0)return;let r=as(t,e.id),i=0;for(let s of n){let a=ri(e.propTimestamps?.[s],e.clientId);i=Math.max(i,r[s]?.updatedAt??0,a.updatedAt)}let o=i+1;e.propTimestamps=Object.fromEntries(n.map(s=>[s,o]))}function My(t,e=null){let n=[];return t.forEach((r,i)=>{n.push({id:r.id,parentId:e,index:i});let o=r.state.children;Array.isArray(o)&&n.push(...My(o,r.id))}),n}function Dn(t,e){if(t===e)return!0;let n=t??$y,r=e??$y;if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}var $y=[];function kc(t){return t.sceneTree&&t.sceneTree.length>0?t.sceneTree:My(t.shapes)}function Ek(t,e){let n=t,r=new Set(t.map(s=>s.id)),i=(s,a,c)=>{r.has(s.id)||(n=Dy(n,{id:s.id,parentId:a,index:c}),r.add(s.id)),Bi(s)?.forEach((d,u)=>i(d,s.id,u))},o=n.filter(s=>s.parentId===null).length;return i(e,null,o),n}function Oy(t){let e=new Map;for(let r of t){let i=e.get(r.parentId)??[];i.push(r),e.set(r.parentId,i)}let n=[];for(let r of e.values())ut(r).forEach((i,o)=>n.push({...i,index:o}));return n}function ds(t,e){let n=t.filter(c=>c.parentId===e);if(n.every(c=>c.orderKey))return t;let r=ut(n),i=new Map,o=[],s=null,a=c=>{if(o.length===0)return;let l=oc(s,c,o.length);o.forEach((d,u)=>i.set(d.id,l[u])),o=[]};for(let c of r)c.orderKey?(a(c.orderKey),s=c.orderKey):o.push(c);return a(null),t.map(c=>i.has(c.id)?{...c,orderKey:i.get(c.id)}:c)}function Dy(t,e){let n,r=[],i=[],o=!1;for(let c of t){if(c.id===e.id){if(n=c,!Yp(e,n))return t;continue}c.parentId===e.parentId?(r.push(c),c.orderKey&&(o=!0)):i.push(c)}if(o){let c=ds([...i,...r],e.parentId),l=ut(c.filter(m=>m.parentId===e.parentId)),d=Math.min(Math.max(0,e.index),l.length),u=d>0?l[d-1].orderKey??null:null,p=d<l.length?l[d].orderKey??null:null,f=u!==null&&p!==null&&u>=p?u:Mi(u,p);return[...i,...l,{...e,orderKey:f}]}let s=r.sort((c,l)=>c.index-l.index).map((c,l)=>({...c,index:l})),a=Math.min(Math.max(0,e.index),s.length);return[...i,...s,{...e,index:a-.5}]}function Mk(t){t.keyframes.sort((e,n)=>{if(e.time!==n.time)return e.time-n.time;let r=e.id??"",i=n.id??"";return r<i?-1:r>i?1:0})}function Zp(t,e){let n=t.keyframes.findIndex(r=>r.id===e.id);n>=0?t.keyframes[n]=e:t.keyframes.push(e),Mk(t)}function Jp(t,e){t.keyframes=t.keyframes.filter(n=>n.id!==e)}function Ny(t,e){let n=t.animationTimeline?.tracks;return Array.isArray(n)?n.find(r=>r.id===e)??null:null}function Yp(t,e){let n=t.updatedAt??0,r=e.updatedAt??0;return n!==r?n>r:(t.clientId??"")>=(e.clientId??"")}function Bi(t){let e=t.state.children;return Array.isArray(e)?e:void 0}var cs=new Set(["group","hyperlink","switch","container","svg"]);function zy(t,e,n,r){for(let i of t){n.set(i.id,e),r.set(i.id,i);let o=Bi(i);o&&zy(o,i.id,n,r)}}function ii(t){let e=t.sceneTree;if(!e||e.length===0)return;let n=new Map,r=new Map;if(zy(t.shapes,null,n,r),r.size===0)return;let i=new Map;for(let u of e){let p=i.get(u.parentId)??[];p.push(u),i.set(u.parentId,p)}let o=new Map,s=(u,p)=>{let f=o.get(u);f?f.push(p):o.set(u,[p])},a=new Set,c=new Set,l=(u,p)=>{for(let f of ut(i.get(u)??[])){if(c.has(f.id))continue;c.add(f.id);let m=r.get(f.id);if(!m){l(f.id,p);continue}s(p,m),a.add(m.id),cs.has(m.type)&&l(f.id,m.id)}};if(l(null,null),a.size===0)return;let d=u=>{let p=n.get(u)??null,f=new Set;for(;p!==null&&!f.has(p);){f.add(p);let m=r.get(p);if(m&&cs.has(m.type))return p;p=n.get(p)??null}return null};for(let[u,p]of r)a.has(u)||s(d(u),p);for(let[u,p]of r){if(!cs.has(p.type))continue;let f=p.state,m=o.get(u);m&&m.length>0?f.children=m:"children"in f&&delete f.children}t.shapes=o.get(null)??[]}function Ok(t){let e=`structural:${t.type}:${t.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function ls(t){let e=t.clipMaskGroups;if(!e||e.length===0)return;let n=t.sceneTree;if(!n||n.length===0)return;let r=new Set(n.map(a=>a.id)),i=new Map;for(let a of n){if(a.parentId===null)continue;let c=i.get(a.parentId);c?c.push(a):i.set(a.parentId,[a])}let o=a=>ut(i.get(a)??[]).map(c=>c.id).filter(c=>!c.startsWith("structural:")),s=new Map(n.map(a=>[a.id,a]));t.clipMaskGroups=e.map(a=>{let c=Ok(a);if(!r.has(c.group))return a;let l=r.has(c.path)?o(c.path):a.clipShapeIds,d=r.has(c.content)?o(c.content):a.contentShapeIds,u=s.get(c.group),p=a.parentId,f=a.siblingIndex;if(u){p=u.parentId;let g=u.parentId===null?n.filter(y=>y.parentId===null):i.get(u.parentId)??[],h=ut(g).findIndex(y=>y.id===c.group);f=h>=0?h:u.index}return Ay(l,a.clipShapeIds)&&Ay(d,a.contentShapeIds)&&p===a.parentId&&f===a.siblingIndex?a:{...a,clipShapeIds:l,contentShapeIds:d,parentId:p,siblingIndex:f}})}function Ay(t,e){return!e||t.length!==e.length?!1:t.every((n,r)=>n===e[r])}function Qp(t,e){e.add(t.id);let n=Bi(t);if(n)for(let r of n)Qp(r,e)}function qp(t,e){for(let n of t){e.set(n.id,n);let r=Bi(n);r&&qp(r,e)}}var Pc=class{constructor(e,n){this.snapshot=e;this.indexed=n}snapshot;indexed;shapeIndex=null;inlineProjectionPending=!1;sceneTreeNormalizePending=!1;memoId=null;memoShape=null;findShape(e){if(this.memoId===e)return this.memoShape;let n;return this.indexed?(this.shapeIndex===null&&(this.shapeIndex=new Map,qp(this.snapshot.shapes,this.shapeIndex)),n=this.shapeIndex.get(e)??null):n=us(this.snapshot.shapes,e),this.memoId=e,this.memoShape=n,n}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&qp([e],this.shapeIndex)}noteShapesRemoved(){this.shapeIndex=null,this.memoId=null,this.memoShape=null}requestInlineProjection(){this.inlineProjectionPending=!0}requestSceneTreeNormalize(){this.sceneTreeNormalizePending=!0}settle(){if(this.sceneTreeNormalizePending){this.sceneTreeNormalizePending=!1;let e=this.snapshot.sceneTree;e&&e.length>0&&(this.snapshot.sceneTree=Oy(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,ii(this.snapshot))}};function us(t,e){for(let n of t){if(n.id===e)return n;let r=Bi(n);if(!r)continue;let i=us(r,e);if(i)return i}return null}function ef(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Dk(t){let e=t.richTextRuns;return!ef(e)||typeof e.text!="string"?null:ei(e)}function zk(t,e){let n=t.state;"extra"in n&&hr(n);let r=new Set;for(let[i,o]of Object.entries(e))o===null?r.add(i):n[i]=o;if(r.size>0){let i={};for(let[o,s]of Object.entries(n))r.has(o)||(i[o]=s);t.state=i}}function _y(t,e,n){let r=[];for(let i of t){if(i.id===e){Qp(i,n);continue}let o=Bi(i);if(o){let s=_y(o,e,n),a=i.state;s.length>0?a.children=s:delete a.children}r.push(i)}return r}function Fy(t,e){let n=t.snapshot,r=n,i=Ty(n,e,e.type!=="shape:update"||t.findShape(e.id)!==null);if(i===null)return null;let o=i,s=o;switch(o.type){case"shape:add":{if(!(t.findShape(o.shape.id)!==null)){let c=kc(r),l=lc(structuredClone(o.shape));r.shapes.push(l),r.sceneTree=Ek(c,l),t.noteShapesAdded(l),t.requestSceneTreeNormalize(),t.requestInlineProjection();let d=new Set;Qp(l,d),Kp(n,d)}break}case"shape:update":{let a=t.findShape(o.id);if(!a)return null;zk(a,o.state);break}case"text:format":{let a=t.findShape(o.id);if(!a)return null;let c=a.state;"extra"in c&&hr(c);let l=Dk(c);if(!l)return null;let d=vc(o.ranges,l.text.length);if(d.length===0)return null;let u={...l,runs:os(l.runs,d)};c.richTextRuns=u;let p=["richTextRuns"];if(o.updatedAt!==void 0){let f=ri(o.updatedAt,o.clientId),m=as(n,o.id);if(p.some(h=>!ss(f,m?.[h]))){let h=Math.max(0,...p.map(y=>m?.[y]?.updatedAt??0));f={updatedAt:Math.max(f.updatedAt,h)+1,clientId:f.clientId},s={...o,updatedAt:f.updatedAt,clientId:f.clientId}}Py(n,o.id,p,f)}break}case"shape:remove":{let a=new Set,c=_y(r.shapes,o.id,a),l=a.size>0;l||a.add(o.id);let d=kc(r),u=d.filter(p=>!a.has(p.id));if(!l&&u.length===d.length)return null;r.shapes=c,r.sceneTree=u,t.noteShapesRemoved(),Kp(n,a),ls(r);break}case"scene:move":{let a=kc(r),c=a.find(u=>u.id===o.id),l=o.updatedAt===void 0?void 0:ri(o.updatedAt,o.clientId),d={id:o.id,parentId:o.parentId,index:o.index,updatedAt:l?.updatedAt,clientId:l?.clientId};if(c&&!Yp(d,c))return null;r.sceneTree=Dy(a,d),t.requestSceneTreeNormalize(),l&&(s={...o,...l}),t.requestInlineProjection(),ls(r);break}case"scene:place":{if(!qo(o.orderKey))return null;let a=kc(r),c=a.find(p=>p.id===o.id),l=o.updatedAt===void 0?void 0:ri(o.updatedAt,o.clientId),d={id:o.id,parentId:o.parentId,index:c?.index??Number.MAX_SAFE_INTEGER,orderKey:o.orderKey,updatedAt:l?.updatedAt,clientId:l?.clientId};if(c&&!Yp(d,c))return null;let u=ds(a,o.parentId);r.sceneTree=[...u.filter(p=>p.id!==o.id),d],t.requestSceneTreeNormalize(),t.requestInlineProjection(),ls(r),l&&(s={...o,...l});break}case"clipMask:upsert":r.clipMaskGroups=Qn(r.clipMaskGroups,o),er(r);break;case"clipMask:remove":{if(!(r.clipMaskGroups??[]).some(c=>c.id===o.id))return null;let a=Qn(r.clipMaskGroups,o);r.clipMaskGroups=a,er(r);break}case"guides:set":r.guides=o.guides;break;case"guide:upsert":r.guides=ts(r.guides,o);break;case"guide:remove":case"guide:move":{let a=ts(r.guides,o);if(Dn(r.guides,a))return null;r.guides=a;break}case"measurements:set":r.measurements=o.measurements;break;case"measurement:upsert":r.measurements=ns(r.measurements,o);break;case"measurement:remove":case"measurement:move":{let a=ns(r.measurements,o);if(Dn(r.measurements,a))return null;r.measurements=a;break}case"metadata:set":r.documentMetadata=o.metadata;break;case"metadata:patch":{let a=Object.fromEntries(Object.entries({...r.documentMetadata??{},...o.patch}).filter(([c])=>!(o.removeKeys??[]).includes(c)));r.documentMetadata=a;break}case"documentScripts:set":r.documentScripts=o.documentScripts;break;case"documentScript:upsert":r.documentScripts=Nt(r.documentScripts,o.documentScript,o.index);break;case"documentScript:remove":{let a=Ft(r.documentScripts,o.id);if(Dn(r.documentScripts,a))return null;r.documentScripts=a;break}case"documentStyles:set":r.documentStyles=o.documentStyles;break;case"documentStyle:upsert":r.documentStyles=Nt(r.documentStyles,o.documentStyle,o.index);break;case"documentStyle:remove":{let a=Ft(r.documentStyles,o.id);if(Dn(r.documentStyles,a))return null;r.documentStyles=a;break}case"templateVariables:set":r.templateVariables=o.templateVariables;break;case"templateVariable:upsert":r.templateVariables=mc(r.templateVariables,o.templateVariable,o.index);break;case"templateVariable:remove":{let a=gc(r.templateVariables,o.name);if(Dn(r.templateVariables,a))return null;r.templateVariables=a;break}case"exportItems:set":r.exportItems=o.exportItems;break;case"exportItem:upsert":r.exportItems=Nt(r.exportItems,o.exportItem,o.index);break;case"exportItem:remove":{let a=Ft(r.exportItems,o.id);if(Dn(r.exportItems,a))return null;r.exportItems=a;break}case"colorGlyphLibrary:set":o.colorGlyphLibrary===null?delete r.colorGlyphLibrary:r.colorGlyphLibrary=o.colorGlyphLibrary;break;case"animation:set":r.animationTimeline=o.animationTimeline;break;case"animation:config":r.animationTimeline={duration:o.config.duration,loop:o.config.loop,playbackSpeed:o.config.playbackSpeed,tracks:Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[]};break;case"animation:clear":delete r.animationTimeline;break;case"animationTrack:upsert":r.animationTimeline={duration:typeof r.animationTimeline?.duration=="number"?r.animationTimeline.duration:0,loop:typeof r.animationTimeline?.loop=="boolean"?r.animationTimeline.loop:!1,playbackSpeed:typeof r.animationTimeline?.playbackSpeed=="number"?r.animationTimeline.playbackSpeed:1,tracks:Nt(Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],o.track,o.index)};break;case"animationTrack:remove":{let a=Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],c=Ft(a,o.id);if(Dn(a,c)&&!r.animationTimeline)return null;c.length>0&&r.animationTimeline?r.animationTimeline={...r.animationTimeline,tracks:c}:delete r.animationTimeline;break}case"animationKeyframe:upsert":{let a=Ny(r,o.trackId);if(!a)return null;Zp(a,structuredClone(o.keyframe));break}case"animationKeyframe:remove":{let a=Ny(r,o.trackId);if(!a)return null;let c=a.keyframes;if(Jp(a,o.keyframeId),Dn(c,a.keyframes))return null;break}case"library:set":r.library=o.library;break;case"library:upsert":r.library=Nt(r.library,o.def,o.index);break;case"library:remove":{let a=Ft(r.library,o.id);if(Dn(r.library,a))return null;r.library=a;break}case"paintServerDefs:set":r.paintServerDefs=o.paintServerDefs;break;case"paintServerDef:upsert":r.paintServerDefs=Nt(r.paintServerDefs,o.paintServerDef,o.index);break;case"paintServerDef:remove":{let a=Ft(r.paintServerDefs,o.id);if(Dn(r.paintServerDefs,a))return null;r.paintServerDefs=a;break}case"presence:cursor":case"presence:selection":break;default:{let a=o;return null}}return s}function Ly(t,e,n){if(e.type==="shape:update"&&e.propTimestamps){let r=n?.type==="shape:update"?new Set(Object.keys(n.state)):new Set,i=Object.keys(e.state).filter(o=>!r.has(o));return Ey(t,e.id,i)}return e.type==="text:format"&&n?.type==="text:format"?n.updatedAt!==e.updatedAt||n.clientId!==e.clientId?Ey(t,e.id,["richTextRuns"]):[]:[]}function _k(t,e){if(e in t)return t[e];let n=t.extra;return ef(n)?n[e]:void 0}function Fk(t,e){if(e in t)return!0;let n=t.extra;return ef(n)&&e in n}function Ey(t,e,n){if(n.length===0)return[];let r=us(t.shapes,e);if(!r)return[];let i=r.state,o=as(t,e),s=new Map;for(let c of n){let l=o[c];if(!l)continue;let d=s.get(l.clientId);d?d.push(c):s.set(l.clientId,[c])}let a=[];for(let[c,l]of s){let d={},u={};for(let p of l)d[p]=Fk(i,p)?structuredClone(_k(i,p)):null,u[p]=o[p].updatedAt;a.push({type:"shape:update",id:e,state:d,propTimestamps:u,clientId:c})}return a}function Tc(t,e){let n=new Pc(t,!1),r=Fy(n,e);return n.settle(),r}function tf(t,e){let n=new Pc(t,e.length>1),r=[];for(let i of e){let o=Fy(n,i);o&&r.push(o)}return n.settle(),r}function nf(t,e){let n=structuredClone(t);return{snapshot:n,acceptedOps:tf(n,e)}}function By(t,e){return nf(t,e).snapshot}function Gy(t){if(!t||t.length===0||t.every(n=>n.orderKey))return t;let e=t;for(let n of new Set(t.map(r=>r.parentId)))e=ds(e,n);return Oy(e)}var Vy=6;function jy(t,e){if(t.length===0)return;let n=new Map;for(let o of t){let s=n.get(o.parentId)??[];s.push(o),n.set(o.parentId,s)}let r=new Set,i=o=>{if(r.has(o)||(r.add(o),o!==null&&!e.hasNode(o)))return;let s=n.get(o);if(!s)return;let a=0;for(let c of ut(s)){if(!e.hasNode(c.id))continue;let l=a++;(e.getParentId(c.id)!==o||e.getSiblingIndex(c.id)!==l)&&e.move(c.id,o,l),i(c.id)}};i(null);for(let o of n.keys())o!==null&&i(o)}var ps="data-svgsketch-passthrough",Lk=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]),Bk=/^<([A-Za-z][\w:-]*)\b[^>]*>/;function Uy(t){return Bk.exec(t.trimStart())}function fs(t){let e=Uy(t);if(!e)return null;let n=/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(e[0]);return n?n[1]??n[2]:null}function Gk(t){let e=Uy(t);if(!e)return null;let n=e[1],r=n.lastIndexOf(":");return r>=0?n.slice(r+1):n}var Vk=new RegExp(`\\s+${ps}\\s*=\\s*(?:"[^"]*"|'[^']*')`);function ms(t){let e=t.markup.indexOf(">");if(e<0)return t;let n=t.markup.slice(0,e+1),r=Vk.exec(n);if(!r)return t;let i=n.slice(0,r.index)+n.slice(r.index+r[0].length);return{...t,markup:i+t.markup.slice(e+1),passthrough:!0}}function Hy(t){let e=[];for(let n of t){if(typeof n!="string")continue;let r=fs(n);if(!r)continue;let i=Gk(n),o=i&&Lk.has(i)?i:"mask";e.push(ms({id:r,type:o,markup:n}))}return e}var Cc={schemaVersion:{kind:"stamped",note:"Serializer stamps CURRENT_SCHEMA_VERSION; no live state."},shapes:{kind:"graph",note:"SceneNode props on graph-owned nodes; the editor Shape registry is the interaction adapter."},viewboxes:{kind:"shape-derived",note:"Projected from `view` shapes on every read (DocumentRootManager.getViewboxes)."},guides:{kind:"aggregate"},measurements:{kind:"aggregate"},sceneTree:{kind:"graph",note:"Serialized by walking the SceneGraph; inline state.children is its projection."},clipMaskGroups:{kind:"aggregate"},documentMetadata:{kind:"aggregate"},documentScripts:{kind:"aggregate"},documentStyles:{kind:"aggregate"},templateVariables:{kind:"aggregate"},animationTimeline:{kind:"aggregate"},library:{kind:"aggregate"},paintServerDefs:{kind:"aggregate"},colorGlyphLibrary:{kind:"aggregate"},exportItems:{kind:"aggregate"},unknownFields:{kind:"aggregate"}},Wy=Object.keys(Cc).filter(t=>Cc[t].kind==="aggregate");function tr(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Nc(){return{title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"",customMetadata:{}}}function Ky(t){return{...Nc(),...t??{}}}function Rc(t){return{guides:structuredClone(t.guides??[]),measurements:structuredClone(t.measurements??[]),clipMaskGroups:vn(t.clipMaskGroups??[]),documentMetadata:structuredClone(Ky(t.documentMetadata)),documentScripts:structuredClone(t.documentScripts??[]),documentStyles:structuredClone(t.documentStyles??[]),templateVariables:structuredClone(t.templateVariables??[]),animationTimeline:t.animationTimeline===void 0?null:structuredClone(t.animationTimeline),exportItems:structuredClone(t.exportItems??[]),colorGlyphLibrary:t.colorGlyphLibrary===void 0||t.colorGlyphLibrary===null?null:structuredClone(t.colorGlyphLibrary),library:structuredClone(t.library??[]),paintServerDefs:structuredClone(t.paintServerDefs??[]),unknownFields:structuredClone(t.unknownFields??{})}}var $c=["symbol","marker","linear-gradient","radial-gradient","pattern","filter"];function rf(t){let e=t.filter(i=>i.builtIn!==!0),n=$c.map(()=>[]),r=[];for(let i of e){let o=$c.indexOf(i.kind);o>=0?n[o].push(i):r.push(i)}return[...n.flat(),...r]}var vr=class t{graph;sections={guides:[],measurements:[],clipMaskGroups:[],documentMetadata:Nc(),documentScripts:[],documentStyles:[],templateVariables:[],animationTimeline:null,exportItems:[],colorGlyphLibrary:null,library:[],paintServerDefs:[],unknownFields:{}};listeners=new Set;unsubscribeGraphStructure=null;disposed=!1;constructor(e=new yr){this.graph=e,this.unsubscribeGraphStructure=this.graph.onStructureChange((n,r)=>{this.foldGraphStructureIntoClipMaskGroups(n,r.id)})}foldGraphStructureIntoClipMaskGroups(e,n){if(this.sections.clipMaskGroups.length===0)return;let r=e==="remove"?/^structural:(clip|mask):(.+):group$/.exec(n):null,i=r?Qn(this.sections.clipMaskGroups,{type:"clipMask:remove",id:r[2]}):this.sections.clipMaskGroups;i=i.map(s=>{let a=`structural:${s.type}:${s.id}`,c=this.graph.getNode(`${a}:group`);if(!c)return s;let l=this.graph.getNode(`${a}:path`),d=this.graph.getNode(`${a}:content`),u=l?this.graph.getChildren(l.id).filter(g=>g.getProp("structural")!==!0).map(g=>g.id):s.clipShapeIds,p=d?this.graph.getChildren(d.id).filter(g=>g.getProp("structural")!==!0).map(g=>g.id):s.contentShapeIds,f=this.graph.getSiblingIndex(c.id);return{...s,clipShapeIds:u,contentShapeIds:p,parentId:this.graph.getParentId(c.id),...f>=0?{siblingIndex:f}:{}}});let o=vn(i);tr(this.sections.clipMaskGroups,o)||(this.sections.clipMaskGroups=o,this.notify("clipMaskGroups"))}onSectionChange(e){return this.disposed?()=>{}:(this.listeners.add(e),()=>this.listeners.delete(e))}notify(e){if(!this.disposed)for(let n of[...this.listeners])n(e)}get isDisposed(){return this.disposed}get sectionListenerCount(){return this.listeners.size}getGuides(){return structuredClone(this.sections.guides)}setGuides(e){this.sections.guides=structuredClone(e),this.notify("guides")}getMeasurements(){return structuredClone(this.sections.measurements)}setMeasurements(e){this.sections.measurements=structuredClone(e),this.notify("measurements")}getDocumentMetadata(){return structuredClone(this.sections.documentMetadata)}setDocumentMetadata(e){this.sections.documentMetadata=structuredClone(Ky(e)),this.notify("documentMetadata")}getDocumentScripts(){return structuredClone(this.sections.documentScripts)}setDocumentScripts(e){this.sections.documentScripts=structuredClone(e),this.notify("documentScripts")}getDocumentStyles(){return structuredClone(this.sections.documentStyles)}setDocumentStyles(e){this.sections.documentStyles=structuredClone(e),this.notify("documentStyles")}getTemplateVariables(){return structuredClone(this.sections.templateVariables)}setTemplateVariables(e){this.sections.templateVariables=structuredClone(e),this.notify("templateVariables")}getAnimationTimeline(){return this.sections.animationTimeline===null?null:structuredClone(this.sections.animationTimeline)}setAnimationTimeline(e){this.sections.animationTimeline=e==null?null:structuredClone(e),this.notify("animationTimeline")}getExportItems(){return structuredClone(this.sections.exportItems)}setExportItems(e){this.sections.exportItems=structuredClone(e),this.notify("exportItems")}getColorGlyphLibrary(){return this.sections.colorGlyphLibrary===null?null:structuredClone(this.sections.colorGlyphLibrary)}setColorGlyphLibrary(e){this.sections.colorGlyphLibrary=e===null?null:structuredClone(e),this.notify("colorGlyphLibrary")}getLibrary(){return structuredClone(this.sections.library)}setLibrary(e){this.sections.library=structuredClone(e),this.notify("library")}upsertLibraryDef(e,n){let r=this.sections.library.findIndex(s=>s.id===e.id),i=n??(r>=0?r:void 0),o=Nt(this.sections.library,structuredClone(e),i);tr(this.sections.library,o)||(this.sections.library=o,this.notify("library"))}removeLibraryDef(e){let n=Ft(this.sections.library,e);tr(this.sections.library,n)||(this.sections.library=n,this.notify("library"))}assembleLibrary(){return rf(this.getLibrary())}getPaintServerDefs(){return structuredClone(this.sections.paintServerDefs)}setPaintServerDefs(e){this.sections.paintServerDefs=structuredClone(e).map(n=>ms(n)),this.notify("paintServerDefs")}getClipMaskGroups(){return structuredClone(this.sections.clipMaskGroups)}setClipMaskGroups(e){this.sections.clipMaskGroups=vn(e),this.notify("clipMaskGroups")}getClipMaskDefinition(e){let n=On(this.sections.clipMaskGroups).get(e);return n?structuredClone(n):null}getClipMaskDefinitions(){return structuredClone(Object.fromEntries(On(this.sections.clipMaskGroups)))}upsertClipMaskDefinition(e,n,r){let i=wc(this.sections.clipMaskGroups,e,n,r);tr(this.sections.clipMaskGroups,i)||(this.sections.clipMaskGroups=i,this.notify("clipMaskGroups"))}upsertClipMaskGroup(e){let n=this.sections.clipMaskGroups.findIndex(i=>i.id===e.id),r=Qn(this.sections.clipMaskGroups,{type:"clipMask:upsert",clipMaskGroup:e,...n>=0?{index:n}:{}});tr(this.sections.clipMaskGroups,r)||(this.sections.clipMaskGroups=r,this.notify("clipMaskGroups"))}unbindClipMaskGroup(e){let n=Qn(this.sections.clipMaskGroups,{type:"clipMask:remove",id:e});tr(this.sections.clipMaskGroups,n)||(this.sections.clipMaskGroups=n,this.notify("clipMaskGroups"))}removeClipMaskDefinition(e){let n=vn(this.sections.clipMaskGroups.filter(r=>At(r)!==e));tr(this.sections.clipMaskGroups,n)||(this.sections.clipMaskGroups=n,this.notify("clipMaskGroups"))}getUnknownFields(){return Object.keys(this.sections.unknownFields).length>0?structuredClone(this.sections.unknownFields):void 0}setUnknownFields(e){this.sections.unknownFields=structuredClone(e??{}),this.notify("unknownFields")}adoptReducerSnapshot(e){let n=this.sections,r=Rc(e),i=Wy.filter(o=>!tr(n[o],r[o]));this.sections=r;for(let o of i)this.notify(o);return i}snapshotForReducer(){let e=structuredClone(this.sections.paintServerDefs);return{schemaVersion:_t,shapes:[],viewboxes:[],guides:structuredClone(this.sections.guides),measurements:structuredClone(this.sections.measurements),clipMaskGroups:structuredClone(this.sections.clipMaskGroups),documentMetadata:structuredClone(this.sections.documentMetadata),documentScripts:structuredClone(this.sections.documentScripts),documentStyles:structuredClone(this.sections.documentStyles),templateVariables:structuredClone(this.sections.templateVariables),...this.sections.animationTimeline===null?{}:{animationTimeline:structuredClone(this.sections.animationTimeline)},exportItems:structuredClone(this.sections.exportItems),...this.sections.colorGlyphLibrary===null?{}:{colorGlyphLibrary:structuredClone(this.sections.colorGlyphLibrary)},library:structuredClone(this.sections.library),paintServerDefs:e,unknownFields:structuredClone(this.sections.unknownFields)}}applyOps(e){let n=this.snapshotForReducer(),r=[],i=new Set;for(let o of e){let s=Rc(n);Tc(n,o);let a=Rc(n);for(let c of Wy)i.has(c)||tr(s[c],a[c])||(i.add(c),r.push(c))}this.sections=Rc(n);for(let o of r)this.notify(o);return r}loadSections(e,n){let r=i=>n===void 0||n.includes(i);r("guides")&&this.setGuides(e.guides??[]),r("measurements")&&this.setMeasurements(e.measurements??[]),r("clipMaskGroups")&&this.setClipMaskGroups(e.clipMaskGroups??[]),r("documentMetadata")&&this.setDocumentMetadata(e.documentMetadata),r("documentScripts")&&this.setDocumentScripts(e.documentScripts??[]),r("documentStyles")&&this.setDocumentStyles(e.documentStyles??[]),r("templateVariables")&&this.setTemplateVariables(e.templateVariables??[]),r("animationTimeline")&&this.setAnimationTimeline(e.animationTimeline??null),r("exportItems")&&this.setExportItems(e.exportItems??[]),r("colorGlyphLibrary")&&this.setColorGlyphLibrary(e.colorGlyphLibrary??null),r("library")&&this.setLibrary(e.library??[]),r("paintServerDefs")&&this.setPaintServerDefs(e.paintServerDefs??[]),r("unknownFields")&&this.setUnknownFields(e.unknownFields)}clearSections(){this.setClipMaskGroups([]),this.setGuides([]),this.setMeasurements([]),this.setDocumentMetadata(void 0),this.setDocumentScripts([]),this.setDocumentStyles([]),this.setTemplateVariables([]),this.setAnimationTimeline(null),this.setExportItems([]),this.setColorGlyphLibrary(null),this.setLibrary([]),this.setPaintServerDefs([]),this.setUnknownFields(void 0)}toSnapshotSections(){let e=this.getTemplateVariables(),n=this.getAnimationTimeline(),r=this.getExportItems(),i=this.getColorGlyphLibrary(),o=this.assembleLibrary(),s=this.getPaintServerDefs(),a=this.getUnknownFields();return{guides:this.getGuides(),measurements:this.getMeasurements(),clipMaskGroups:this.getClipMaskGroups(),documentMetadata:this.getDocumentMetadata(),documentScripts:this.getDocumentScripts(),documentStyles:this.getDocumentStyles(),...e.length>0?{templateVariables:e}:{},...n!==null&&n.tracks.length>0?{animationTimeline:n}:{},...r.length>0?{exportItems:r}:{},...i!==null?{colorGlyphLibrary:i}:{},...o.length>0?{library:o}:{},...s.length>0?{paintServerDefs:s}:{},...a!==void 0?{unknownFields:a}:{}}}cloneOwned(){let e=new t(this.graph.clone());return e.sections=structuredClone(this.sections),e}dispose(){this.disposed||(this.disposed=!0,this.unsubscribeGraphStructure?.(),this.unsubscribeGraphStructure=null,this.listeners.clear(),this.graph.dispose())}};var jk=1;function of(){return`canonical-document-${jk++}`}var oi=class t{constructor(e,n){this.model=e;this.identity=n}model;identity;disposed=!1;static empty(e=of()){return new t(new vr,e)}static own(e,n=of()){if(e.isDisposed)throw new Error("Cannot own a disposed DocumentModel.");return new t(e,n)}get graph(){return this.model.graph}get isDisposed(){return this.disposed}assertCoherent(){if(this.model.graph!==this.graph)throw new Error("Canonical document model and graph identity diverged.");if(this.disposed!==this.model.isDisposed||this.disposed!==this.graph.isDisposed)throw new Error("Canonical document disposal state diverged.")}clone(e=of()){if(this.disposed)throw new Error("Cannot clone a disposed canonical document.");return t.own(this.model.cloneOwned(),e)}dispose(){this.disposed||(this.disposed=!0,this.model.dispose())}},Ac=class{constructor(e=oi.empty()){this.activeDocument=e;if(e.isDisposed)throw new Error("Cannot start a document session with a disposed document.");e.assertCoherent();let n=this;this.view=Object.freeze({get current(){return n.current},get model(){return n.model},get graph(){return n.graph},get version(){return n.version},get isDisposed(){return n.isDisposed},get replacementListenerCount(){return n.replacementListenerCount},onReplacement:r=>n.onReplacement(r)})}activeDocument;listeners=new Set;replacing=!1;disposed=!1;_version=0;view;get current(){return this.activeDocument}get model(){return this.activeDocument.model}get graph(){return this.activeDocument.graph}get version(){return this._version}get isDisposed(){return this.disposed}get replacementListenerCount(){return this.listeners.size}onReplacement(e){return this.disposed?()=>{}:(this.listeners.add(e),()=>this.listeners.delete(e))}replace(e,n={}){if(this.disposed)throw new Error("Cannot replace a disposed document session.");if(this.replacing)throw new Error("Document replacement is already in progress.");if(e===this.activeDocument)throw new Error("Replacement document is already active.");if(e.isDisposed)throw new Error("Cannot install a disposed canonical document.");e.assertCoherent();let r=this.activeDocument,i=this._version,o=Object.freeze({previous:r,next:e,previousVersion:i,version:i+1});this.replacing=!0,this.activeDocument=e,this._version=o.version;try{n.commit?.(o),n.beforeNotify?.(o)}catch(a){this.activeDocument=r,this._version=i;let c=[a];try{n.rollback?.(o)}catch(l){c.push(l)}try{e.dispose()}catch(l){c.push(l)}throw this.replacing=!1,c.length>1?new AggregateError(c,"Document replacement rejection cleanup failed.",{cause:a}):a}let s=[];for(let a of[...this.listeners])try{a(o)}catch(c){s.push(c)}try{n.finalize?.(o)}catch(a){s.push(a)}try{r.dispose()}catch(a){s.push(a)}return this.replacing=!1,{event:o,postCommitErrors:s}}dispose(){if(!this.disposed){if(this.replacing)throw new Error("Cannot dispose a document session during replacement.");this.disposed=!0,this.listeners.clear(),this.activeDocument.dispose()}}};var Xy=Object.freeze({linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"});function Zy(t,e,n,r,i=1e-4){if(Math.abs(t)<i&&Math.abs(e)<i&&Math.abs(n-1)<i&&Math.abs(r-1)<i)return"linear";for(let[o,s]of Object.entries(Xr))if(s&&Math.abs(t-s[0])<i&&Math.abs(e-s[1])<i&&Math.abs(n-s[2])<i&&Math.abs(r-s[3])<i)return o;return null}function Ec(t,e,n,r){let i=Zy(t,e,n,r);return i===null?{easing:"custom-bezier",customBezier:[t,e,n,r]}:{easing:i}}function Uk(t){let e=[],n=0,r="";for(let i of t)i==="("?n++:i===")"&&n--,i===","&&n===0?(e.push(r.trim()),r=""):r+=i;return(r.trim()!==""||e.length>0)&&e.push(r.trim()),e}function Hk(t){switch(t){case"jump-start":case"start":return"jump-start";case"jump-end":case"end":return"jump-end";case"jump-none":return"jump-none";case"jump-both":return"jump-both";default:return null}}function Wk(t){let e=[];for(let i of t)i.positions.length===0?e.push({value:i.value,position:null}):(e.push({value:i.value,position:i.positions[0]}),i.positions.length===2&&e.push({value:i.value,position:i.positions[1]}));if(e.length<2)return null;e[0].position===null&&(e[0].position=0),e[e.length-1].position===null&&(e[e.length-1].position=1);let n=0;for(;n<e.length;){if(e[n].position!==null){n++;continue}let i=n;for(;i<e.length&&e[i].position===null;)i++;let o=e[n-1].position,s=e[i]?.position??1,a=i-n+1;for(let c=0;c<i-n;c++)e[n+c].position=o+(s-o)*(c+1)/a;n=i}let r=e[0].position;return e.map(i=>{let o=Math.max(r,i.position);return r=o,{value:i.value,position:o}})}function si(t){let e=t.trim().toLowerCase();if(!e)return null;if(e==="step-start")return{kind:"steps",count:1,position:"jump-start"};if(e==="step-end")return{kind:"steps",count:1,position:"jump-end"};if(e in Xy)return{kind:"keyword",easing:Xy[e]};let n=/^cubic-bezier\s*\(([^)]*)\)$/u.exec(e);if(n){let c=n[1].split(",").map(f=>Number(f.trim()));if(c.length!==4||c.some(f=>!Number.isFinite(f)))return null;let[l,d,u,p]=c;return l<0||l>1||u<0||u>1?null:{kind:"cubic-bezier",points:[l,d,u,p]}}let r=/^steps\s*\(([^)]*)\)$/u.exec(e);if(r){let c=r[1].split(",").map(u=>u.trim());if(c.length<1||c.length>2||!/^\d+$/u.test(c[0]))return null;let l=Number(c[0]);if(!Number.isInteger(l)||l<1)return null;let d=Hk(c[1]??"jump-end");return!d||d==="jump-none"&&l<2?null:{kind:"steps",count:l,position:d}}let i=/^linear\s*\(([\s\S]*)\)$/u.exec(e);if(!i)return null;let o=Uk(i[1]);if(o.length===0)return null;let s=[];for(let c of o){let l=c.split(/\s+/u).filter(Boolean);if(l.length===0)return null;let d=Number(l[0]);if(!Number.isFinite(d))return null;let u=[];for(let p of l.slice(1)){if(!p.endsWith("%"))return null;let f=Number(p.slice(0,-1));if(!Number.isFinite(f))return null;u.push(f/100)}if(u.length>2)return null;s.push({value:d,positions:u})}let a=Wk(s);return a&&a.length>=2?{kind:"linear",points:a}:null}function sf(t,e){switch(delete t.customBezier,delete t.linearPoints,delete t.stepsParams,e.kind){case"keyword":t.easing=e.easing;return;case"cubic-bezier":{let n=Ec(...e.points);t.easing=n.easing,n.customBezier&&(t.customBezier=n.customBezier);return}case"steps":t.easing="steps",t.stepsParams={count:e.count,position:e.position};return;case"linear":t.easing="linear-function",t.linearPoints=[...e.points]}}function Yy(t,e,n){let r=1-t;return 3*r*r*t*e+3*r*t*t*n+t*t*t}function qy(t,e){let n=Math.max(0,Math.min(1,t)),r=0,i=1,o=n;for(let s=0;s<24;s++){let a=Yy(o,e[0],e[2]);if(Math.abs(a-n)<=1e-8)break;a<n?r=o:i=o,o=(r+i)/2}return Yy(o,e[1],e[3])}function af(t,e){let n=Math.max(0,Math.min(1,e));if(!t)return n;switch(t.kind){case"keyword":{let r=Xr[t.easing];return r?qy(n,r):n}case"cubic-bezier":return qy(n,t.points);case"steps":{let{count:r,position:i}=t,o=Math.floor(n*r);(i==="jump-start"||i==="jump-both")&&o++;let s=i==="jump-none"?r-1:i==="jump-both"?r+1:r;return Math.max(0,Math.min(1,(o+(i==="jump-none"?-1:0))/s))}case"linear":{let r=t.points;if(n<=r[0].position)return r[0].value;for(let i=1;i<r.length;i++){if(n>r[i].position)continue;let o=r[i-1],s=r[i],a=s.position-o.position;return a<=0?s.value:o.value+(s.value-o.value)*(n-o.position)/a}return r.at(-1).value}}}function nr(t){let e=t.trim(),n=/^(\d+):(\d{2}):(\d{2}(?:\.\d+)?)$/u.exec(e);if(n)return Number(n[1])*3600+Number(n[2])*60+Number(n[3]);let r=/^(\d{2}):(\d{2}(?:\.\d+)?)$/u.exec(e);if(r)return Number(r[1])*60+Number(r[2]);let i=/^([+-]?\d+(?:\.\d+)?)\s*(h|min|ms|s)?$/u.exec(e);if(i){let s=Number(i[1]);switch(i[2]??"s"){case"h":return s*3600;case"min":return s*60;case"ms":return s/1e3;default:return s}}let o=Number.parseFloat(e);return Number.isNaN(o)?0:o}function Jy(t,e){switch(t){case"reverse":return!0;case"alternate":return e%2===1;case"alternate-reverse":return e%2===0;default:return!1}}function cf(t){if(t.cycleDuration!==void 0)return Math.max(0,t.cycleDuration);if(t.keyframes.length<2)return 0;let e=t.keyframes[0]?.time??0,n=t.keyframes[t.keyframes.length-1]?.time??e;return Math.max(0,n-e)}function lf(t){let e=t.keyframes[0]?.time??0;if(!t.beginTrigger)return e;if(t.beginTrigger.type!=="time")return null;let n=Number.parseFloat(t.beginTrigger.value);return Number.isFinite(n)?n:null}function df(t){if(t.cycleInfinite)return null;let e=lf(t);return e===null?null:e+cf(t)*Math.max(0,t.cycleRepeats??1)}function Mc(t,e,n,r,i){return t+(Jy(n,r)?e-i:i)}function Kk(t,e){let n=t.keyframes[0]?.time??0,r=lf(t);if(r===null)return null;let i=cf(t);if(i<=0)return e>=r||t.fillBackwards?n:null;let o=t.cycleBehavior??"restart",s=e-r;if(s<0)return t.fillBackwards?Mc(n,i,o,0,0):null;let a=Math.max(0,t.cycleRepeats??1),c=t.cycleInfinite??!1,l=c?1/0:i*a;if(!c&&s>=l){if(t.fill==="remove")return null;if(a<=0)return Mc(n,i,o,0,0);let p=Math.floor(a),f=a-p,m=f>Number.EPSILON?p:p-1,g=f>Number.EPSILON?f*i:i;return Mc(n,i,o,m,g)}let d=Math.floor(s/i),u=s-d*i;return Mc(n,i,o,d,u)}function uf(t){if(!t.fillBackwards||t.keyframes.length===0)return null;let e=t.keyframes[0].time,n=t.beginTrigger?.type==="time"?Number.parseFloat(t.beginTrigger.value):Number.NaN,r=Number.isFinite(n)?Math.max(0,n):e;if(!(r>0))return null;let o=Jy(t.cycleBehavior??"restart",0)?t.keyframes.at(-1):t.keyframes[0],s=Array.isArray(o.value)?[...o.value]:o.value;return{...t,id:`${t.id}:backwards-fill`,keyframes:[{time:0,value:s,easing:"linear"},{time:r,value:s,easing:"linear"}],beginTrigger:void 0,endTrigger:void 0,cycleDuration:r,cycleRepeats:void 0,cycleInfinite:!1,cycleBehavior:"restart",fill:"remove",fillBackwards:!1,sourceSmilId:void 0,template:void 0}}var Xk=new Set(["ease","ease-in","ease-out","ease-in-out","linear","step-start","step-end"]),Yk=new Set(["normal","reverse","alternate","alternate-reverse"]),qk=new Set(["none","forwards","backwards","both"]),Zk=new Set(["running","paused"]),pf="(?:\\d+(?:\\.\\d+)?|\\.\\d+)",eS=`[+-]?${pf}`,Jk=new RegExp(`^${pf}(?:s|ms)$`,"u"),Qk=new RegExp(`^${eS}(?:s|ms)$`,"u"),e0=new RegExp(`^${pf}$`,"u");function ff(t){switch(t.kind){case"keyword":return t.easing;case"cubic-bezier":return"custom-bezier";case"steps":return"steps";case"linear":return"linear-function"}}function gs(t){if(!t)return[];let e=[],n=0,r=null,i=!1,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}if(r){a===r&&(r=null);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?n++:a===")"?n=Math.max(0,n-1):a===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function hs(t,e){let n=gs(t);return n.length===0?"":n[e%n.length]}function Oc(t){let n=t.trim().replace(/\w+\([^)]*\)/gu,f=>f.replace(/\s+/gu,"")).split(/\s+/u).filter(Boolean);if(n.length===0)return null;let r=0,i=0,o="linear",s=null,a="normal",c="1",l="none",d="",u=!1,p=!1;for(let f of n){if(!u&&Jk.test(f)){r=f.endsWith("ms")?Number(f.slice(0,-2))/1e3:Number(f.slice(0,-1)),u=!0;continue}if(u&&!p&&Qk.test(f)){i=f.endsWith("ms")?Number(f.slice(0,-2))/1e3:Number(f.slice(0,-1)),p=!0;continue}if(/^(?:cubic-bezier|steps|linear)\(/u.test(f)||Xk.has(f)){let m=si(f);m&&(s=m,o=ff(m));continue}if(Yk.has(f)){a=f;continue}if(f==="infinite"){c=f;continue}if(e0.test(f)){c=f;continue}if(qk.has(f)){l=f;continue}Zk.has(f)||d||(d=f)}return!d||r<=0?null:{name:d,duration:r,delay:i,easing:o,parsedEasing:s,direction:a,iterationCount:c,fillMode:l}}function Qy(t){let e=new RegExp(`^(${eS})\\s*(s|ms)$`,"iu").exec(t.trim());if(!e)return null;let n=Number(e[1]);return e[2].toLowerCase()==="ms"?n/1e3:n}function mf(t,e,n){let r=u=>hs(e[u],n),i=Qy(r("animation-delay"));i!==null&&(t.delay=i);let o=Qy(r("animation-duration"));o!==null&&o>0&&(t.duration=o);let s=si(r("animation-timing-function"));s&&(t.parsedEasing=s,t.easing=ff(s));let a=r("animation-direction");a&&(t.direction=a);let c=r("animation-iteration-count");c&&(t.iterationCount=c);let l=r("animation-fill-mode");l&&(t.fillMode=l);let d=r("animation-name");d&&d!=="none"&&(t.name=d)}function gf(t){let e=gs(t["animation-name"]);if(e.length===0||e.every(r=>!r||r==="none"))return"";let n=["animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state"];return e.map((r,i)=>{let o=n.map(s=>hs(t[s],i)).filter(Boolean);return o.push(r),o.join(" ")}).join(", ")}function hf(t){let e=t.fillMode==="forwards"||t.fillMode==="both",n=t.fillMode==="backwards"||t.fillMode==="both";return{...e?{}:{fill:"remove"},...n?{fillBackwards:!0}:{}}}function zc(t){return/[\t\n\f\r ]/u.test(t??"")}function ys(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function Dc(t,e){let n=e;for(;n<t.length;){if(zc(t[n])){n++;continue}let r=ys(t,n);if(r===n)break;n=r}return n}function Gi(t){let e="";for(let n=0;n<t.length;n++){let r=t[n];if(r!=="\\"){e+=r;continue}n++;let i=t[n];if(i===void 0)return null;if(i===`
7
+ `||i==="\r"||i==="\f"){i==="\r"&&t[n+1]===`
8
+ `&&n++;continue}if(/[0-9a-f]/iu.test(i)){let o=i;for(;o.length<6&&/[0-9a-f]/iu.test(t[n+1]??"");)o+=t[++n];zc(t[n+1])&&n++;let s=Number.parseInt(o,16);e+=s===0||s>1114111||s>=55296&&s<=57343?"\uFFFD":String.fromCodePoint(s);continue}e+=i}return e}function zn(t,e,n=!1){let r=[],i=0,o=null,s=!1,a=0;for(let c=0;c<t.length;c++){let l=t[c];if(o){s?s=!1:l==="\\"?s=!0:l===o&&(o=null);continue}if(l==="/"&&t[c+1]==="*"){c=Math.max(c,ys(t,c)-1);continue}if(l==='"'||l==="'"){o=l;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}")a=Math.max(0,a-1);else if(l===e&&a===0&&(r.push(Object.freeze({start:i,end:c})),i=c+1,n))break}return r.push(Object.freeze({start:i,end:t.length})),r}function ai(t,e){return zn(t,e,e===":").map(n=>t.slice(n.start,n.end))}function t0(t){return!!(t&&(/[-_a-z]/iu.test(t)||t==="\\"))}function n0(t){return!!(t&&(/[-_a-z0-9]/iu.test(t)||t==="\\"))}function r0(t,e){let n=e;for(;n<t.length;){let r=t[n];if(r!=="\\"){if(!n0(r))break;n++;continue}n++;let i=t[n];if(i===void 0||i===`
9
+ `||i==="\r"||i==="\f")break;if(!/[0-9a-f]/iu.test(i)){n++;continue}let o=0;for(;o<6&&/[0-9a-f]/iu.test(t[n]??"");)o++,n++;zc(t[n])&&n++}return n}function xn(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,ys(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!t0(o))continue;let s=i,a=r0(t,i);if(t[a]!=="("){i=a-1;continue}let c=a+1,l=1,d=null,u=!1,p=c;for(;p<t.length;p++){let f=t[p];if(d){u?u=!1:f==="\\"?u=!0:f===d&&(d=null);continue}if(f==="/"&&t[p+1]==="*"){p=Math.max(p,ys(t,p)-1);continue}if(f==='"'||f==="'"){d=f;continue}if(f==="(")l++;else if(f===")"&&--l===0)break}if(l!==0){i=a;continue}e.push(Object.freeze({name:Gi(t.slice(s,a))?.toLowerCase()??t.slice(s,a).toLowerCase(),tokenStart:s,tokenEnd:p+1,argumentsStart:c,argumentsEnd:p})),i=p}return Object.freeze(e)}function i0(t,e){if(t.slice(e,e+3).toLowerCase()!=="url"||t[e+3]!=="(")return!1;let n=t[e-1];return!n||!/[-_a-z0-9]/iu.test(n)}function _n(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,ys(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!i0(t,i))continue;let s=i,a=Dc(t,i+4),c=t[a]==='"'||t[a]==="'"?t[a++]:null;if(a=Dc(t,a),t[a]!=="#")continue;a++;let l=a,d=a,u=!1,p=!1;for(;a<t.length;a++){let m=t[a];if(p){p=!1,d=a+1;continue}if(m==="\\"){p=!0,d=a+1;continue}if(c){if(m===c){a=Dc(t,a+1),u=t[a]===")";break}d=a+1;continue}if(m===")"){u=!0;break}if(zc(m)||m==="/"&&t[a+1]==="*"){a=Dc(t,a),u=t[a]===")";break}d=a+1}if(!u||d<=l)continue;let f=Gi(t.slice(l,d));f&&(e.push(Object.freeze({targetAuthoredId:f,tokenStart:s,tokenEnd:a+1,targetStart:l,targetEnd:d})),i=a)}return Object.freeze(e)}var nS=String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?`,rS="px|pt|pc|in|cm|mm|q|em|rem|%|ex|ch|vw|vh|vmin|vmax",o0=new RegExp(String.raw`^(${nS})\s*(${rS})?$`,"i"),tS=new RegExp(`(${nS})(${rS})?`,"gi");function pt(t){if(t===null||t.trim().length===0)return null;let e=o0.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?Object.freeze({value:n,unit:(e[2]??"").toLowerCase()}):null}function ci(t){if(!t)return Object.freeze([]);tS.lastIndex=0;let e=[],n;for(;(n=tS.exec(t))!==null;){let r=Number(n[1]);Number.isFinite(r)&&e.push(Object.freeze({value:r,unit:(n[2]??"").toLowerCase()}))}return Object.freeze(e)}function rr(t,e){let n=t.value;if(Number.isFinite(n))switch(t.unit.toLowerCase()){case"%":return e.percentBasis===void 0?void 0:n*e.percentBasis/100;case"vw":return e.viewportWidth===void 0?void 0:n*e.viewportWidth/100;case"vh":return e.viewportHeight===void 0?void 0:n*e.viewportHeight/100;case"vmin":return e.viewportWidth===void 0||e.viewportHeight===void 0?void 0:n*Math.min(e.viewportWidth,e.viewportHeight)/100;case"vmax":return e.viewportWidth===void 0||e.viewportHeight===void 0?void 0:n*Math.max(e.viewportWidth,e.viewportHeight)/100;case"em":return e.fontSize===void 0?void 0:n*e.fontSize;case"rem":return e.rootFontSize===void 0?void 0:n*e.rootFontSize;case"ex":return e.xHeight!==void 0?n*e.xHeight:e.fontSize===void 0?void 0:n*.5*e.fontSize;case"ch":return e.chWidth!==void 0?n*e.chWidth:e.fontSize===void 0?void 0:n*.5*e.fontSize;case"":case"px":return n;case"pt":return n*(4/3);case"pc":return n*16;case"in":return n*96;case"cm":return n*(96/2.54);case"mm":return n*(96/25.4);case"q":return n*(96/101.6);default:return}}function Pe(t,e){let n=pt(t);return n?rr(n,e):void 0}function Ut(t){let e=pt(t);if(!(!e||["em","rem","%","ex","ch","vw","vh","vmin","vmax"].includes(e.unit)))return rr(e,{})}var _e=Object.freeze([1,0,0,1,0,0]);function ft(t,e,n,r,i,o){return[t,e,n,r,i,o]}function bs(t){return ft(t[0]??1,t[1]??0,t[2]??0,t[3]??1,t[4]??0,t[5]??0)}function tt(t){return[t[0],t[1],t[2],t[3],t[4],t[5]]}function ir(t){return Array.isArray(t)&&t.length>=6&&t.slice(0,6).every(Number.isFinite)}function Et(t,e=1e-9){return Math.abs((t[0]??1)-1)<=e&&Math.abs(t[1]??0)<=e&&Math.abs(t[2]??0)<=e&&Math.abs((t[3]??1)-1)<=e&&Math.abs(t[4]??0)<=e&&Math.abs(t[5]??0)<=e}function s0(t,e,n=1e-9){for(let r=0;r<6;r++)if(Math.abs(t[r]-e[r])>n)return!1;return!0}function ge(t,e){return ft(t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5])}function a0(t){let e=t[0]*t[3]-t[2]*t[1];if(Math.abs(e)<1e-10)return null;let n=1/e;return ft(t[3]*n,-t[1]*n,-t[2]*n,t[0]*n,(t[2]*t[5]-t[3]*t[4])*n,(t[1]*t[4]-t[0]*t[5])*n)}function We(t,e){return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}function Fc(t,e){return{x:t[0]*e.x+t[2]*e.y,y:t[1]*e.x+t[3]*e.y}}function qe(t,e=0){return ft(1,0,0,1,t,e)}function li(t,e=t){return ft(t,0,0,e,0,0)}function ji(t){let e=t*Math.PI/180,n=Math.cos(e),r=Math.sin(e);return ft(n,r,-r,n,0,0)}function vs(t){return ft(1,0,Math.tan(t*Math.PI/180),1,0,0)}function xs(t){return ft(1,Math.tan(t*Math.PI/180),0,1,0,0)}function yf(t,e){return ge(ge(qe(t.x,t.y),e),qe(-t.x,-t.y))}var c0=9,l0=10,d0=12,u0=13,p0=32,iS=43,f0=44,oS=45,m0=46,g0=48,h0=57,y0=40,S0=41,b0=69,v0=101,x0=0,I0=1,aS=2,w0=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function k0(t){return t===p0||t===c0||t===l0||t===u0||t===d0}function _c(t){return t>=g0&&t<=h0}function P0(t){let e=t>=65&&t<=90,n=t>=97&&t<=122;return e||n||_c(t)}function Vi(t){for(;t.pos<t.src.length&&k0(t.src.charCodeAt(t.pos));)t.pos++}function cS(t){let e=t.pos;return Vi(t),t.src.charCodeAt(t.pos)===f0?(t.pos++,Vi(t),aS):t.pos>e?I0:x0}function sS(t){let e=t.src,n=t.pos,r=n,i=e.charCodeAt(r);(i===iS||i===oS)&&r++;let o=!1;for(;r<e.length&&_c(e.charCodeAt(r));)r++,o=!0;if(e.charCodeAt(r)===m0){let c=r+1;for(;c<e.length&&_c(e.charCodeAt(c));)c++;c>r+1&&(r=c,o=!0)}if(!o)return null;let s=e.charCodeAt(r);if(s===v0||s===b0){let c=r+1,l=e.charCodeAt(c);(l===iS||l===oS)&&c++;let d=c;for(;d<e.length&&_c(e.charCodeAt(d));)d++;d>c&&(r=d)}let a=Number(e.slice(n,r));return Number.isFinite(a)?(t.pos=r,a):null}function T0(t,e){switch(t){case"matrix":return bs(e);case"translate":return qe(e[0],e[1]??0);case"scale":return li(e[0],e[1]??e[0]);case"rotate":return e.length===3?yf({x:e[1],y:e[2]},ji(e[0])):ji(e[0]);case"skewX":return vs(e[0]);case"skewY":return xs(e[0]);default:return null}}function R0(t){let e=t.src,n=t.pos;for(;t.pos<e.length&&P0(e.charCodeAt(t.pos));)t.pos++;if(t.pos===n)return null;let r=e.slice(n,t.pos),i=w0.get(r);if(!i||(Vi(t),e.charCodeAt(t.pos)!==y0))return null;t.pos++,Vi(t);let o=i[i.length-1],s=sS(t);if(s===null)return null;let a=[s];for(;;){let c=t.pos;cS(t);let l=sS(t);if(l===null){t.pos=c;break}if(a.push(l),a.length>o)return null}return Vi(t),e.charCodeAt(t.pos)!==S0||(t.pos++,!i.includes(a.length))?null:T0(r,a)}function C0(t){let e={src:t,pos:0};if(Vi(e),e.pos>=t.length)return _e;let n=_e;for(;;){let r=R0(e);if(r===null)return null;n=ge(n,r);let i=cS(e);if(e.pos>=t.length)return i===aS?null:n}}var $0=2048,Ss=new Map;function Zt(t){if(!t)return _e;let e=Ss.get(t);if(e!==void 0)return e;let n=C0(t),r=n===null?null:Object.freeze(n);if(Ss.size>=$0){let i=Ss.keys().next().value;i!==void 0&&Ss.delete(i)}return Ss.set(t,r),r}function Ht(t){return Zt(t)??_e}function Is(t){let e=t[0],n=t[1],r=t[2],i=t[3],o=Math.sqrt(e*e+n*n);if(o<1e-12)return{rotation:0,scaleX:0,scaleY:Math.sqrt(r*r+i*i),skewX:0};let s=Math.atan2(n,e),c=(e*i-n*r)/o,l=c!==0?(e*r+n*i)/(o*o):0,d=Math.atan(l),u=180/Math.PI;return{rotation:s*u,scaleX:o,scaleY:c,skewX:d*u}}function ws(t){return!ir(t)||Et(t)?null:`matrix(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]})`}function ks(t,e){let n=t.translateX??0,r=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",o=t.rotation??0,s=t.skewX??0,a=t.skewY??0,c=t.scaleX??1,l=t.scaleY??1,d=qe(n,r);if(i)return ge(d,Ht(i));if(o===0&&s===0&&a===0&&c===1&&l===1)return d;let u=t.customPivot??e;if(!u)return d;let p=ge(ge(ge(ji(o),li(c,l)),vs(s)),xs(a));return ge(d,yf(u,p))}function bt(t,e){return ws(un(t,e))}function un(t,e){let n=t.transformMatrix;return ir(n)&&!Et(n)?bs(n):ks(t,e)}function Sf(t,e){let n=t.ancestorTransform;if(!ir(n)){delete t.ancestorTransform;return}if(Et(n)){delete t.ancestorTransform;return}let r=ir(t.transformMatrix)?bs(t.transformMatrix):ks(t,e);t.transformMatrix=tt(ge(bs(n),r)),delete t.ancestorTransform}function bf(t,e,n){let r=bt(t,{x:e,y:n});return r?`${r} translate(${e}, ${n})`:`translate(${e}, ${n})`}var N0=Object.freeze({left:0,center:50,right:100}),A0=Object.freeze({top:0,center:50,bottom:100});function Ir(t,e,n){let r=pt(t);return!r||r.unit===""&&r.value!==0?null:rr(r,{...n,percentBasis:e==="x"?n.boxWidth:e==="y"?n.boxHeight:void 0})??null}function lS(t,e,n){let r=t.trim().toLowerCase(),i=e==="horizontal"?N0:A0;if(Object.hasOwn(i,r))return{kind:"percentage",value:i[r]};let o=pt(r);if(!o||o.unit===""&&o.value!==0)return null;if(o.unit==="%")return{kind:"percentage",value:o.value};let s=rr(o,n);return s===void 0?null:{kind:"length",value:s}}function dS(t,e,n){return t.kind==="length"?e+t.value:n===void 0?null:e+t.value*n/100}function Ts(t,e={}){let n=t.trim().split(/\s+/u).filter(Boolean);if(n.length===0||n.length>3)return null;let r=0;if(n.length===3){let d=Ir(n[2],"z",e);if(d===null||n[2].includes("%"))return null;r=d}let i,o;if(n.length===1){let d=n[0].toLowerCase();d==="top"||d==="bottom"?(i="center",o=n[0]):(i=n[0],o="center")}else{i=n[0],o=n[1];let d=i.toLowerCase(),u=o.toLowerCase(),p=d==="top"||d==="bottom",f=u==="left"||u==="right";p&&(f||u==="center")?[i,o]=[o,i]:d==="center"&&f&&([i,o]=[o,i])}let s=lS(i,"horizontal",e),a=lS(o,"vertical",e);if(!s||!a)return null;let c=dS(s,e.boxX??0,e.boxWidth),l=dS(a,e.boxY??0,e.boxHeight);return c===null||l===null?null:Object.freeze(r===0?{x:c,y:l}:{x:c,y:l,z:r})}var Vc=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),E0=new Set(["matrix3d","perspective","rotate3d","rotatex","rotatey","rotatez","scale3d","scalez","translate3d","translatez"]),M0=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(deg|grad|rad|turn)?$/iu;function uS(t){return t.replace(/\/\*[\s\S]*?\*\//gu,"").trim()===""}function O0(t){let e=[],n="",r=0,i=null,o=!1,s=!1,a=()=>{let c=n.trim();return n="",c?(e.push(c),!0):!1};for(let c=0;c<t.length;c++){let l=t[c];if(i){n+=l,o?o=!1:l==="\\"?o=!0:l===i&&(i=null);continue}if(l==='"'||l==="'"){i=l,n+=l;continue}if(l==="/"&&t[c+1]==="*"){let d=t.indexOf("*/",c+2);if(d<0)return null;n+=" ",c=d+1;continue}if(l==="("){r++,n+=l;continue}if(l===")"){if(r===0)return null;r--,n+=l;continue}if(r===0&&l===","){if(!a())return null;s=!0;continue}if(r===0&&/\s/u.test(l)&&!s){n.trim()&&a();continue}n+=l}return r!==0||i||n.trim()===""&&s||n.trim()&&!a()?null:Object.freeze(e)}function SS(t){if(t.trim().toLowerCase()==="none")return Object.freeze([]);let e=xn(t);if(e.length===0)return null;let n=[],r=0;for(let i of e){if(!uS(t.slice(r,i.tokenStart)))return null;let o=O0(t.slice(i.argumentsStart,i.argumentsEnd));if(!o)return null;n.push(Object.freeze({name:i.name,args:o})),r=i.tokenEnd}return uS(t.slice(r))?Object.freeze(n):null}function In(t){if(t===void 0||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function pn(t){if(t===void 0)return null;let e=M0.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n)||!e[2]&&n!==0)return null;switch(e[2]?.toLowerCase()){case"grad":return n*Math.PI/200;case"rad":return n;case"turn":return n*2*Math.PI;default:return n*Math.PI/180}}function ui(t,e){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let i=0;i<4;i++)for(let o=0;o<4;o++)n[r*4+i]+=t[r*4+o]*e[o*4+i];return n}function pi(t,e,n){return[1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1]}function Ps(t,e,n){return[t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1]}function wr(t,e,n,r){let i=Math.hypot(t,e,n);if(i===0)return r===0?Vc:null;t/=i,e/=i,n/=i;let o=Math.cos(r),s=Math.sin(r),a=1-o;return[t*t*a+o,t*e*a-n*s,t*n*a+e*s,0,e*t*a+n*s,e*e*a+o,e*n*a-t*s,0,n*t*a-e*s,n*e*a+t*s,n*n*a+o,0,0,0,0,1]}function Jt(t,...e){return e.includes(t.length)}function jc(t,e){let n=t.args;switch(t.name){case"translate":{if(!Jt(n,1,2))return null;let r=Ir(n[0],"x",e),i=Ir(n[1]??"0","y",e);return r===null||i===null?null:pi(r,i,0)}case"translatex":case"translatey":case"translatez":{if(!Jt(n,1))return null;let r=t.name.at(-1),i=Ir(n[0],r,e);return i===null?null:pi(r==="x"?i:0,r==="y"?i:0,r==="z"?i:0)}case"translate3d":{if(!Jt(n,3))return null;let r=Ir(n[0],"x",e),i=Ir(n[1],"y",e),o=Ir(n[2],"z",e);return r===null||i===null||o===null?null:pi(r,i,o)}case"scale":{if(!Jt(n,1,2))return null;let r=In(n[0]),i=n.length===1?r:In(n[1]);return r===null||i===null?null:Ps(r,i,1)}case"scalex":case"scaley":case"scalez":{if(!Jt(n,1))return null;let r=In(n[0]);return r===null?null:Ps(t.name==="scalex"?r:1,t.name==="scaley"?r:1,t.name==="scalez"?r:1)}case"scale3d":{if(!Jt(n,3))return null;let r=n.map(In);return r.some(i=>i===null)?null:Ps(r[0],r[1],r[2])}case"rotate":case"rotatex":case"rotatey":case"rotatez":{if(!Jt(n,1))return null;let r=pn(n[0]);return r===null?null:t.name==="rotatex"?wr(1,0,0,r):t.name==="rotatey"?wr(0,1,0,r):wr(0,0,1,r)}case"rotate3d":{if(!Jt(n,4))return null;let r=In(n[0]),i=In(n[1]),o=In(n[2]),s=pn(n[3]);return r===null||i===null||o===null||s===null?null:wr(r,i,o,s)}case"skew":{if(!Jt(n,1,2))return null;let r=pn(n[0]),i=pn(n[1]??"0deg");return r===null||i===null?null:[1,Math.tan(r),0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1]}case"skewx":case"skewy":{if(!Jt(n,1))return null;let r=pn(n[0]);return r===null?null:t.name==="skewx"?[1,Math.tan(r),0,0,0,1,0,0,0,0,1,0,0,0,0,1]:[1,0,0,0,Math.tan(r),1,0,0,0,0,1,0,0,0,0,1]}case"matrix":{if(!Jt(n,6))return null;let r=n.map(In);return r.some(i=>i===null)?null:[r[0],r[2],0,r[4],r[1],r[3],0,r[5],0,0,1,0,0,0,0,1]}case"matrix3d":{if(!Jt(n,16))return null;let r=n.map(In);if(r.some(o=>o===null))return null;let i=[r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15]];return i[12]===0&&i[13]===0&&i[14]===0&&i[15]===1?i:"perspective"}case"perspective":return Jt(n,1)&&Ir(n[0],"z",e)!==null?"perspective":null;default:return null}}function bS(t,e){let n=Vc;for(let r of t){let i=jc(r,e);if(!i||i==="perspective")return i;n=ui(n,i)}return n}function If(t){let e=SS(t);if(!e)return"invalid";let n=bS(e,{boxWidth:100,boxHeight:100,viewportWidth:100,viewportHeight:100,fontSize:16,rootFontSize:16,xHeight:8,chWidth:8});return n==="perspective"?"unsupported-perspective":n===null?"invalid":null}function Bc(t){return t.startsWith("translate")?"translate":t.startsWith("scale")?"scale":t.startsWith("rotate")?"rotate":t.startsWith("skew")?"skew":"matrix"}function pS(t){let e=t.name;return e==="perspective"?null:e.startsWith("translate")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"0px"))}):e.startsWith("scale")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"1"))}):e==="rotate3d"?Object.freeze({name:e,args:Object.freeze(["0","0","1","0deg"])}):e.startsWith("rotate")||e.startsWith("skew")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"0deg"))}):e==="matrix"?Object.freeze({name:e,args:Object.freeze(["1","0","0","1","0","0"])}):e==="matrix3d"?Object.freeze({name:e,args:Object.freeze(Vc.map(String))}):null}function D0(t,e){let n=[...t],r=[...e],i=Math.max(n.length,r.length);for(let o=0;o<i;o++){if(!n[o]&&r[o]){let s=pS(r[o]);if(!s)return null;n[o]=s}if(!r[o]&&n[o]){let s=pS(n[o]);if(!s)return null;r[o]=s}}return[n,r]}function fS(t,e){let n=jc(t,e);return!n||n==="perspective"?null:[n[3],n[7],n[11]]}function mS(t){let e=jc(t,{});return!e||e==="perspective"?null:[e[0],e[5],e[10]]}function at(t,e,n){return t+(e-t)*n}function z0(t,e,n,r){let i=Bc(t.name);if(i!==Bc(e.name))return null;if(i==="translate"){let o=fS(t,r),s=fS(e,r);return o&&s?pi(at(o[0],s[0],n),at(o[1],s[1],n),at(o[2],s[2],n)):null}if(i==="scale"){let o=mS(t),s=mS(e);return o&&s?Ps(at(o[0],s[0],n),at(o[1],s[1],n),at(o[2],s[2],n)):null}if(i==="rotate"&&t.name===e.name){if(t.name==="rotate3d"){let c=t.args.slice(0,3).map(In),l=e.args.slice(0,3).map(In),d=pn(t.args[3]),u=pn(e.args[3]);if(c.some(y=>y===null)||l.some(y=>y===null)||d===null||u===null)return null;let p=Math.hypot(c[0],c[1],c[2]),f=Math.hypot(l[0],l[1],l[2]);if(p===0||f===0)return null;let m=[c[0]/p,c[1]/p,c[2]/p],g=[l[0]/f,l[1]/f,l[2]/f],h=m[0]*g[0]+m[1]*g[1]+m[2]*g[2];return Math.abs(Math.abs(h)-1)>1e-10?null:wr(m[0],m[1],m[2],at(d,h<0?-u:u,n))}let o=pn(t.args[0]),s=pn(e.args[0]);if(o===null||s===null)return null;let a=at(o,s,n);return t.name==="rotatex"?wr(1,0,0,a):t.name==="rotatey"?wr(0,1,0,a):wr(0,0,1,a)}if(i==="skew"&&t.name===e.name&&t.args.length===e.args.length){let o=t.args.map(pn),s=e.args.map(pn);return o.some(a=>a===null)||s.some(a=>a===null)?null:jc({name:t.name,args:o.map((a,c)=>`${at(a,s[c],n)}rad`)},r)}return null}function _0(t,e,n,r){let i=D0(t,e);if(!i)return null;let o=Vc;for(let s=0;s<i[0].length;s++){let a=z0(i[0][s],i[1][s],n,r);if(!a)return null;o=ui(o,a)}return o}function Gc(t){return Math.abs(t[12])>1e-10||Math.abs(t[13])>1e-10||Math.abs(t[14])>1e-10||Math.abs(t[15]-1)>1e-10?null:ft(t[0],t[4],t[1],t[5],t[3],t[7])}function F0(t){return[t[0],t[2],0,t[4],t[1],t[3],0,t[5],0,0,1,0,0,0,0,1]}function Lc(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function vf(t){return Math.hypot(t[0],t[1],t[2])}function di(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function xf(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function L0(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function B0(t,e,n){let r=t[0],i=e[0],o=n[0],s=t[1],a=e[1],c=n[1],l=t[2],d=e[2],u=n[2],p=r+a+u,f,m,g,h;if(p>0){let b=Math.sqrt(p+1)*2;h=b/4,f=(d-c)/b,m=(o-l)/b,g=(s-i)/b}else if(r>a&&r>u){let b=Math.sqrt(1+r-a-u)*2;h=(d-c)/b,f=b/4,m=(i+s)/b,g=(o+l)/b}else if(a>u){let b=Math.sqrt(1+a-r-u)*2;h=(o-l)/b,f=(i+s)/b,m=b/4,g=(c+d)/b}else{let b=Math.sqrt(1+u-r-a)*2;h=(s-i)/b,f=(o+l)/b,m=(c+d)/b,g=b/4}let y=Math.hypot(f,m,g,h);return[f/y,m/y,g/y,h/y]}function gS(t){if(Math.abs(t[12])>1e-10||Math.abs(t[13])>1e-10||Math.abs(t[14])>1e-10||Math.abs(t[15]-1)>1e-10)return null;let e=[t[0],t[4],t[8]],n=[t[1],t[5],t[9]],r=[t[2],t[6],t[10]],i=vf(e);if(i<1e-12)return null;e=di(e,1/i);let o=Lc(e,n);n=xf(n,di(e,o));let s=vf(n);if(s<1e-12)return null;n=di(n,1/s),o/=s;let a=Lc(e,r);r=xf(r,di(e,a));let c=Lc(n,r);r=xf(r,di(n,c));let l=vf(r);return l<1e-12?null:(r=di(r,1/l),a/=l,c/=l,Lc(e,L0(n,r))<0&&(i=-i,e=di(e,-1)),{translate:[t[3],t[7],t[11]],scale:[i,s,l],skew:[o,a,c],quaternion:B0(e,n,r)})}function G0(t,e,n){let r=[...e],i=t.reduce((l,d,u)=>l+d*r[u],0);if(i<0&&(r=r.map(l=>-l),i=-i),i>.9995){let l=t.map((u,p)=>at(u,r[p],n)),d=Math.hypot(...l);return l.map(u=>u/d)}let o=Math.acos(Math.max(-1,Math.min(1,i))),s=Math.sin(o),a=Math.sin((1-n)*o)/s,c=Math.sin(n*o)/s;return t.map((l,d)=>l*a+r[d]*c)}function V0(t){let[e,n,r,i]=t;return[1-2*(n*n+r*r),2*(e*n-r*i),2*(e*r+n*i),0,2*(e*n+r*i),1-2*(e*e+r*r),2*(n*r-e*i),0,2*(e*r-n*i),2*(n*r+e*i),1-2*(e*e+n*n),0,0,0,0,1]}function j0(t,e,n){let r=gS(t),i=gS(e);if(!r||!i)return null;let o=r.translate.map((d,u)=>at(d,i.translate[u],n)),s=r.scale.map((d,u)=>at(d,i.scale[u],n)),a=r.skew.map((d,u)=>at(d,i.skew[u],n)),c=V0(G0(r.quaternion,i.quaternion,n)),l=[1,a[0],a[1],0,0,1,a[2],0,0,0,1,0,0,0,0,1];return ui(ui(pi(o[0],o[1],o[2]),ui(c,l)),Ps(s[0],s[1],s[2]))}function hS(t){return Math.abs(t[2])<1e-10&&Math.abs(t[6])<1e-10&&Math.abs(t[8])<1e-10&&Math.abs(t[9])<1e-10&&Math.abs(t[10]-1)<1e-10&&Math.abs(t[11])<1e-10}function U0(t,e,n){let r=Gc(t),i=Gc(e);if(!r||!i)return null;let o=Is(r),s=Is(i),a=s.rotation;for(;a-o.rotation>180;)a-=360;for(;a-o.rotation<-180;)a+=360;let c=at(o.rotation,a,n)*Math.PI/180,l=at(o.skewX,s.skewX,n)*Math.PI/180,d=at(o.scaleX,s.scaleX,n),u=at(o.scaleY,s.scaleY,n),p=Math.cos(c),f=Math.sin(c),m=Math.tan(l);return F0(ft(p*d,f*d,p*d*m-f*u,f*d*m+p*u,at(r[4],i[4],n),at(r[5],i[5],n)))}function H0(t,e,n,r,i,o){let s=_0(t,e,i,o);return s||(hS(n)&&hS(r)?U0(n,r,i):j0(n,r,i))}function yS(t,e){return ui(ui(pi(e.x,e.y,e.z??0),t),pi(-e.x,-e.y,-(e.z??0)))}function xr(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?0:Number(t.toFixed(10))}function W0(t){return t.every(e=>e.length===1&&(e[0].name==="rotate"||e[0].name==="rotatez"))}function K0(t,e,n){let r=new Set;for(let i of t)for(let o of i)o.name.startsWith("translate")?(o.name!=="translatey"&&o.name!=="translatez"&&r.add("translateX"),o.name!=="translatex"&&o.name!=="translatez"&&r.add("translateY")):o.name.startsWith("scale")?(o.name!=="scaley"&&o.name!=="scalez"&&r.add("scaleX"),o.name!=="scalex"&&o.name!=="scalez"&&r.add("scaleY")):o.name.startsWith("rotate")?r.add("rotation"):o.name==="skew"||o.name==="skewx"?r.add("skewX"):o.name==="skewy"?r.add("skewY"):(o.name==="matrix"||o.name==="matrix3d")&&(r.add("translateX"),r.add("translateY"),r.add("scaleX"),r.add("scaleY"),r.add("rotation"),r.add("skewX"));return e&&(r.add("translateX"),r.add("translateY"),r.add("scaleX"),r.add("scaleY"),r.add("rotation")),n.some(i=>i.skewX!==0)&&r.add("skewX"),Object.freeze([...r])}function Rs(t,e={},n=16){if(t.length===0||!Number.isInteger(n)||n<1)return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let r=t.map(g=>SS(g.transform));if(r.some(g=>g===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let i=r.map(g=>bS(g,e));if(i.some(g=>g==="perspective"))return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});if(i.some(g=>g===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let o=r,s=i,a=e.transformOrigin,c=W0(o),l=e.retainPureRotationOrigin===!0&&c,d=c?o.map(g=>pn(g[0].args[0])*180/Math.PI):null,u=o.some(g=>g.some(h=>E0.has(h.name)))||a!==void 0&&!l&&c||o.some((g,h)=>h>0&&g.length!==o[h-1].length)||o.some((g,h)=>h>0&&g.some((y,b)=>Bc(y.name)!==Bc(o[h-1][b]?.name??"matrix"))),p=[];for(let g=0;g<t.length;g++){let h=a&&!l?yS(s[g],a):s[g],y=Gc(h);if(!y)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[g].offset,matrix:y,...d?{rotation:d[g]}:{}});let b=t[g+1];if(!(!b||!u))for(let v=1;v<n;v++){let I=v/n,x=Math.max(0,Math.min(1,e.progressForInterval?.(g,I)??I)),k=H0(o[g],o[g+1],s[g],s[g+1],x,e);if(!k)return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let T=a&&!l?yS(k,a):k,w=Gc(T);if(!w)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[g].offset+(b.offset-t[g].offset)*I,matrix:w,...d?{rotation:at(d[g],d[g+1],x)}:{}})}}let f=null,m=p.sort((g,h)=>g.offset-h.offset).map(({offset:g,matrix:h,rotation:y})=>{let b=Is(h),v=y??b.rotation;if(y===void 0&&f!==null){for(;v-f>180;)v-=360;for(;v-f<-180;)v+=360}f=v;let I=ft(...h.map(xr));return Object.freeze({offset:xr(g),matrix:I,translateX:xr(I[4]),translateY:xr(I[5]),rotation:xr(v),scaleX:xr(b.scaleX),scaleY:xr(b.scaleY),skewX:xr(b.skewX),skewY:0})});return Object.freeze({status:"projected",stops:Object.freeze(m),sampled:u,pureRotation:l,channels:K0(o,u,m)})}function $s(t,e,n=-90){let r=[],i=n*Math.PI/180;for(let o=0;o<t;o++){let s=i+o*2*Math.PI/t;r.push({x:e*Math.cos(s),y:e*Math.sin(s)})}return r}function Hc(t,e,n,r=-90){let i=[],o=e*(n/100),s=r*Math.PI/180;for(let a=0;a<t*2;a++){let c=s+a*Math.PI/t,l=a%2===0?e:o;i.push({x:l*Math.cos(c),y:l*Math.sin(c)})}return i}function Wc(t,e,n=0){let r=t*(e/100)/2,i=[{x:-r,y:-t},{x:r,y:-t},{x:r,y:-r},{x:t,y:-r},{x:t,y:r},{x:r,y:r},{x:r,y:t},{x:-r,y:t},{x:-r,y:r},{x:-t,y:r},{x:-t,y:-r},{x:-r,y:-r}];if(n===0)return i;let o=Math.cos(n*Math.PI/180),s=Math.sin(n*Math.PI/180);return i.map(a=>({x:a.x*o-a.y*s,y:a.x*s+a.y*o}))}function Kc(t,e,n,r,i=-90){let s=t*2*(n/100),a=t*(e/100),c=a*(r/100),l=[{x:t,y:0},{x:t-s,y:-a/2},{x:t-s,y:-c/2},{x:-t,y:-c/2},{x:-t,y:c/2},{x:t-s,y:c/2},{x:t-s,y:a/2}];if(i===0)return l;let d=Math.cos(i*Math.PI/180),u=Math.sin(i*Math.PI/180);return l.map(p=>({x:p.x*d-p.y*u,y:p.x*u+p.y*d}))}function Xc(t,e,n,r,i=0){let o=t,s=o*(n/100),a=o*(r/100),c=a/2,l=e*Math.PI/180,d=Math.cos(l),u=Math.sin(l),p=Math.abs(d),f=Math.abs(u),m=Math.max(p,f)||1,g={x:d*(o/m),y:u*(o/m)},h={x:g.x+d*s,y:g.y+u*s},y=Math.min(a,o-c),b=-o+c+y,v=o-c-y,I={x:-o,y:-o},x={x:o,y:-o},k={x:o,y:o},T={x:-o,y:o},w;if(p>=f&&d>0){let R=Math.max(b,Math.min(v,g.y)),$={x:o,y:R-c},A={x:o,y:R+c};w=[I,x,$,h,A,k,T]}else if(p>=f&&d<=0){let R=Math.max(b,Math.min(v,g.y)),$={x:-o,y:R+c},A={x:-o,y:R-c};w=[I,x,k,T,$,h,A]}else if(u<0){let R=Math.max(b,Math.min(v,g.x)),$={x:R-c,y:-o},A={x:R+c,y:-o};w=[I,$,h,A,x,k,T]}else{let R=Math.max(b,Math.min(v,g.x)),$={x:R+c,y:o},A={x:R-c,y:o};w=[I,x,k,$,h,A,T]}if(i===0)return w;let P=Math.cos(i*Math.PI/180),N=Math.sin(i*Math.PI/180);return w.map(R=>({x:R.x*P-R.y*N,y:R.x*N+R.y*P}))}function Yc(t,e,n,r,i=0){let o=Math.max(2,Math.round(e)),s=t*(n/100),a=t*(r/100)/2,c=o+1,l=[];for(let g=0;g<c;g++){let h=g/(c-1),y=-t+h*2*t,b=0;g>0&&g<c-1&&(b=g%2===1?s:-s),l.push({x:b,y})}let d=[],u=[];for(let g=0;g<c;g++){if(g===0||g===c-1){d.push({...l[g]}),u.push({...l[g]});continue}let h=l[g-1],y=l[g],b=l[g+1],v=y.x-h.x,I=y.y-h.y,x=Math.hypot(v,I)||1,k=v/x,T=I/x,w=b.x-y.x,P=b.y-y.y,N=Math.hypot(w,P)||1,R=w/N,$=P/N,A=(k+R)/2,O=(T+$)/2,G=Math.hypot(A,O),M,V;G<1e-6?(M=-T,V=k):(M=-O/G,V=A/G),d.push({x:y.x-M*a,y:y.y-V*a}),u.push({x:y.x+M*a,y:y.y+V*a})}let p=[];p.push(d[0]);for(let g=1;g<c-1;g++)p.push(u[g]);p.push(d[c-1]);for(let g=c-2;g>=1;g--)p.push(d[g]);if(i===0)return p;let f=Math.cos(i*Math.PI/180),m=Math.sin(i*Math.PI/180);return p.map(g=>({x:g.x*f-g.y*m,y:g.x*m+g.y*f}))}function qc(t,e,n,r=0){let i=t,o=Math.max(.3,Math.min(.9,e/100)),s=-i*(n/100),a={x:0,y:i},c={x:0,y:s},l={x:-i*o,y:i*.4},d={x:-i*o,y:-i},u={x:i*o,y:-i},p={x:i*o,y:i*.4},f=[a,l,d,c,u,p,a],m=r===0?f:(()=>{let x=Math.cos(r*Math.PI/180),k=Math.sin(r*Math.PI/180);return f.map(T=>({x:T.x*x-T.y*k,y:T.x*k+T.y*x}))})(),[g,h,y,b,v,I]=m;return`M ${g.x} ${g.y} C ${h.x} ${h.y} ${y.x} ${y.y} ${b.x} ${b.y} C ${v.x} ${v.y} ${I.x} ${I.y} ${g.x} ${g.y} Z`}function Zc(t,e,n,r=0){let i=Math.max(3,Math.round(e)),o=Math.max(.3,Math.min(1,n/100)),s=t,a=s*1.7,c=s*1.15,l=[];for(let T=0;T<i;T++){let P=(90+T/i*360)*Math.PI/180;l.push({x:a/2*Math.cos(P),y:-(c/2)*Math.sin(P)})}let d=.15,u=0;for(let T=0;T<i;T++){let w=l[T],P=l[(T+1)%i];u=Math.max(u,Math.hypot(P.x-w.x,P.y-w.y))}let p=u/(2*(1-d))+.001,f=Math.max(p,u*(.68+o*.35)),m=l.map(T=>{let w=T.y/(c/2);return f*(1-d*w)});function g(T){let w=l[T],P=l[(T+1)%i],N=m[T],R=m[(T+1)%i],$=P.x-w.x,A=P.y-w.y,O=Math.hypot($,A)||1,G=(N*N-R*R+O*O)/(2*O),M=Math.sqrt(Math.max(0,N*N-G*G)),V=w.x+G/O*$,X=w.y+G/O*A,Y=-A/O,U=$/O,te={x:V+Y*M,y:X+U*M},Z={x:V-Y*M,y:X-U*M};return te.x*te.x+te.y*te.y>Z.x*Z.x+Z.y*Z.y?te:Z}let h=[];for(let T=0;T<i;T++)h.push(g(T));let y=14,b=[];for(let T=0;T<i;T++){let w=l[T],P=m[T],N=h[(T-1+i)%i],R=h[T],$=Math.atan2(N.y-w.y,N.x-w.x),O=Math.atan2(R.y-w.y,R.x-w.x)-$;O<=0&&(O+=2*Math.PI);let G=2*Math.PI-O,M=$+O/2,V=$-G/2,X={x:w.x+P*Math.cos(M),y:w.y+P*Math.sin(M)},Y={x:w.x+P*Math.cos(V),y:w.y+P*Math.sin(V)},te=X.x*X.x+X.y*X.y>Y.x*Y.x+Y.y*Y.y?O:-G;for(let Z=0;Z<y;Z++){let ne=Z/y,F=$+ne*te;b.push({x:w.x+P*Math.cos(F),y:w.y+P*Math.sin(F)})}}let v=0;for(let T of b){let w=Math.max(Math.abs(T.x),Math.abs(T.y));w>v&&(v=w)}if(v>0&&v!==s){let T=s/v;for(let w of b)w.x*=T,w.y*=T}let I=T=>{if(r===0)return T;let w=Math.cos(r*Math.PI/180),P=Math.sin(r*Math.PI/180);return{x:T.x*w-T.y*P,y:T.x*P+T.y*w}},x=b.map(I),k=`M ${x[0].x} ${x[0].y}`;for(let T=1;T<x.length;T++)k+=` L ${x[T].x} ${x[T].y}`;return k+=" Z",k}function wn(t,e=0,n=0){if(t.length<3)return"";if(e<=0)return t.map((o,s)=>(s===0?"M":"L")+`${o.x},${o.y}`).join(" ")+" Z";let r=Math.min(e,n*.4),i="";for(let o=0;o<t.length;o++){let s=t[(o-1+t.length)%t.length],a=t[o],c=t[(o+1)%t.length],l={x:s.x-a.x,y:s.y-a.y},d=Math.hypot(l.x,l.y);l.x/=d,l.y/=d;let u={x:c.x-a.x,y:c.y-a.y},p=Math.hypot(u.x,u.y);u.x/=p,u.y/=p;let f=Math.min(r,d/2),m=Math.min(r,p/2),g={x:a.x+l.x*f,y:a.y+l.y*f},h={x:a.x+u.x*m,y:a.y+u.y*m};i+=o===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${a.x},${a.y} ${h.x},${h.y}`}return i+" Z"}function Jc(t,e,n="evenodd"){let r=t*(e/100),i=n==="nonzero"?1:0;return`M ${t} 0 A ${t} ${t} 0 1 1 ${-t} 0 A ${t} ${t} 0 1 1 ${t} 0 Z M ${r} 0 A ${r} ${r} 0 1 ${i} ${-r} 0 A ${r} ${r} 0 1 ${i} ${r} 0 Z`}function Qc(t,e,n,r=1,i=0){let o=t*(n/100),a=Math.round(e*36),c=e*2*Math.PI,l=(t-o/2)/c,d=i*Math.PI/180,u=[],p=[];for(let g=0;g<=a;g++){let h=g/a,y=h*c*r+d,b=l*(h*c)+o/2,v=o/2;u.push({x:(b+v*.3)*Math.cos(y),y:(b+v*.3)*Math.sin(y)}),p.push({x:Math.max(0,b-v*.3)*Math.cos(y),y:Math.max(0,b-v*.3)*Math.sin(y)})}let f=`M ${u[0].x} ${u[0].y}`;for(let g=1;g<u.length;g++)f+=` L ${u[g].x} ${u[g].y}`;let m=p[p.length-1];f+=` L ${m.x} ${m.y}`;for(let g=p.length-2;g>=0;g--)f+=` L ${p[g].x} ${p[g].y}`;return f+=" Z",f}var X0=.2;function Pf(t,e,n,r=0){let i=e*(n/100),o=e,s=e-i,a=2*Math.PI/t,c=a*X0/2,l=a/4,d=r*Math.PI/180,u=[];for(let p=0;p<t;p++){let f=d+p*a;u.push({x:s*Math.cos(f),y:s*Math.sin(f)}),u.push({x:o*Math.cos(f+l-c),y:o*Math.sin(f+l-c)}),u.push({x:o*Math.cos(f+l+c),y:o*Math.sin(f+l+c)}),u.push({x:s*Math.cos(f+a/2),y:s*Math.sin(f+a/2)})}return u}function el(t,e,n,r=0,i=0,o="evenodd",s=0){let a=Pf(t,e,n,s),c=Math.min(r,e*.1),l=wn(a,c,e);if(i>0){let d=e*(i/100),u=o==="nonzero"?1:0;l+=` M ${d} 0 A ${d} ${d} 0 1 ${u} ${-d} 0 A ${d} ${d} 0 1 ${u} ${d} 0 Z`}return l}function tl(t,e,n,r,i,o="round",s="uniform",a){let c=Math.min(n,r)/2,l,d,u,p,f,m,g,h;if(s==="non-uniform"&&a?(l=Math.min(a.radiusTL??i,c),d=Math.min(a.radiusTR??i,c),u=Math.min(a.radiusBR??i,c),p=Math.min(a.radiusBL??i,c),f=a.shapeTL??o,m=a.shapeTR??o,g=a.shapeBR??o,h=a.shapeBL??o):(l=d=u=p=Math.min(i,c),f=m=g=h=o),!(o!=="round"||s==="non-uniform"||l>0&&f!=="round"||d>0&&m!=="round"||u>0&&g!=="round"||p>0&&h!=="round")&&l===d&&d===u&&u===p)return null;let b=`M${t+l},${e}`;return b+=` L${t+n-d},${e}`,b+=Uc(m,d,t+n,e,"tr"),b+=` L${t+n},${e+r-u}`,b+=Uc(g,u,t+n,e+r,"br"),b+=` L${t+p},${e+r}`,b+=Uc(h,p,t,e+r,"bl"),b+=` L${t},${e+l}`,b+=Uc(f,l,t,e,"tl"),b+=" Z",b}function Uc(t,e,n,r,i){if(e<=0)return"";switch(t){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${n},${r+e}`;case"br":return` A${e},${e} 0 0 1 ${n-e},${r}`;case"bl":return` A${e},${e} 0 0 1 ${n},${r-e}`;case"tl":return` A${e},${e} 0 0 1 ${n+e},${r}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${n},${r+e}`;case"br":return` A${e},${e} 0 0 0 ${n-e},${r}`;case"bl":return` A${e},${e} 0 0 0 ${n},${r-e}`;case"tl":return` A${e},${e} 0 0 0 ${n+e},${r}`}break;case"bevel":switch(i){case"tr":return` L${n},${r+e}`;case"br":return` L${n-e},${r}`;case"bl":return` L${n},${r-e}`;case"tl":return` L${n+e},${r}`}break;case"notch":switch(i){case"tr":return` L${n-e},${r+e} L${n},${r+e}`;case"br":return` L${n-e},${r-e} L${n-e},${r}`;case"bl":return` L${n+e},${r-e} L${n},${r-e}`;case"tl":return` L${n+e},${r+e} L${n+e},${r}`}break}return""}function nl(t,e,n,r,i,o={}){let s=e+r/2,a=n+i/2;switch(t){case"diamond":return`M${s},${n} L${e+r},${a} L${s},${n+i} L${e},${a} Z`;case"parallelogram":{let c=(o.slantPercent??20)/100*r;return`M${e+c},${n} L${e+r},${n} L${e+r-c},${n+i} L${e},${n+i} Z`}case"trapezoid":{let c=(o.topWidthPercent??70)/100*r,l=(r-c)/2;return`M${e+l},${n} L${e+l+c},${n} L${e+r},${n+i} L${e},${n+i} Z`}case"terminator":{let c=i/2;return`M${e+c},${n} L${e+r-c},${n} A${c},${c} 0 0 1 ${e+r-c},${n+i} L${e+c},${n+i} A${c},${c} 0 0 1 ${e+c},${n} Z`}case"cylinder":{let c=r/2,l=Math.min((o.capHeightPercent??15)/100*i,i/2);return`M${e},${n+l} A${c},${l} 0 0 1 ${e+r},${n+l} A${c},${l} 0 0 1 ${e},${n+l} L${e},${n+i-l} A${c},${l} 0 0 0 ${e+r},${n+i-l} L${e+r},${n+l} M${s-c},${n+l} A${c},${l} 0 0 0 ${s+c},${n+l}`}case"document-shape":{let c=(o.waveAmplitudePercent??15)/100*i;return`M${e},${n} L${e+r},${n} L${e+r},${n+i} C${e+r*.75},${n+i-c*2} ${s+r*.25},${n+i+c} ${s},${n+i} C${s-r*.25},${n+i-c} ${e+r*.25},${n+i+c*.5} ${e},${n+i} Z`}}}function kr(t,e,n=!1,r=.5,i){if(t.length<2)return t.length===1?`M ${t[0].x} ${t[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return J0(t,n,r);case"BASIS":case"basis":return Q0(t,n);case"ARC":case"arc":return i&&i.length>0?Y0(t,n,i):Cs(t,n,"CUBIC");case"LINEAR":case"linear":return Cs(t,n,"LINEAR");case"QUADRATIC":case"quadratic":return Cs(t,n,"QUADRATIC");case"CUBIC":case"cubic":return Cs(t,n,"CUBIC");default:return Cs(t,n)}}function Y0(t,e,n){let r=`M ${t[0].x} ${t[0].y}`,i=0,o={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let s=0;s<t.length-1;s++){let a=t[s+1];if(a.isSubpathStart){if(e&&s-i>=1){let l=t[i],d=n?.[s]??o;r+=` A ${d.rx} ${d.ry} ${d.rotation} ${d.largeArc?1:0} ${d.sweep?1:0} ${l.x} ${l.y} Z`}r+=` M ${a.x} ${a.y}`,i=s+1;continue}let c=n?.[s]??o;r+=` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${a.x} ${a.y}`}if(e&&t.length-i>1){let s=t[i],a=n?.[t.length-1]??o;r+=` A ${a.rx} ${a.ry} ${a.rotation} ${a.largeArc?1:0} ${a.sweep?1:0} ${s.x} ${s.y} Z`}return r}function Cs(t,e,n){let r=`M ${t[0].x} ${t[0].y}`,i=0,o=null,s=null;for(let a=0;a<t.length-1;a++){let c=t[a],l=t[a+1];if(l.isSubpathStart){if(e&&a-i>=1){let u=t[i];r+=wf(c,u,u.segmentType,o,s,n),r+=" Z"}r+=` M ${l.x} ${l.y}`,i=a+1,o=null,s=null;continue}r+=wf(c,l,l.segmentType,o,s,n);let d=Z0(l.segmentType??n,c,l);o=d,d==="quad"?s=c.handleOut??null:s=null}if(e&&t.length-i>1){let a=t[t.length-1],c=t[i],l=(c.segmentType??n??(a.handleOut||c.handleIn?"CUBIC":"LINEAR")).toUpperCase();l==="LINEAR"||l==="HORIZONTAL"||l==="VERTICAL"||(r+=wf(a,c,c.segmentType,o,s,n)),r+=" Z"}return r}var q0=.001;function Ui(t,e){return Math.abs(t-e)<q0}function Z0(t,e,n){let r=(t??(e.handleOut||n.handleIn?"CUBIC":"LINEAR")).toUpperCase();return r==="CUBIC"||r==="SMOOTH_CUBIC"?"cubic":r==="QUADRATIC"||r==="SMOOTH_QUADRATIC"?"quad":null}function wf(t,e,n,r,i,o){let s=(n??o??(t.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(s==="LINEAR"||s==="HORIZONTAL"||s==="VERTICAL")return(s==="HORIZONTAL"||s==="LINEAR")&&Ui(t.y,e.y)?` H ${e.x}`:(s==="VERTICAL"||s==="LINEAR")&&Ui(t.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(s==="ARC"){let l=e.arcParams;return l?` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.sweep?1:0} ${e.x} ${e.y}`:` L ${e.x} ${e.y}`}if(s==="QUADRATIC"||s==="SMOOTH_QUADRATIC"){let l=t.handleOut??{x:(t.x+e.x)/2,y:(t.y+e.y)/2};return r==="quad"&&i&&Ui(l.x,2*t.x-i.x)&&Ui(l.y,2*t.y-i.y)?` T ${e.x} ${e.y}`:` Q ${l.x} ${l.y} ${e.x} ${e.y}`}let a=t.handleOut??{x:t.x,y:t.y},c=e.handleIn??{x:e.x,y:e.y};return r==="cubic"&&t.handleIn&&t.handleOut&&Ui(t.handleOut.x,2*t.x-t.handleIn.x)&&Ui(t.handleOut.y,2*t.y-t.handleIn.y)?` S ${c.x} ${c.y} ${e.x} ${e.y}`:` C ${a.x} ${a.y} ${c.x} ${c.y} ${e.x} ${e.y}`}function J0(t,e,n){if(t.length<2)return t.length===1?`M ${t[0].x} ${t[0].y}`:"";let r=n,i=e?[t[t.length-1],...t,t[0],t[1]]:[t[0],...t,t[t.length-1]],o=`M ${t[0].x} ${t[0].y}`,s=e?t.length:t.length-1;for(let a=0;a<s;a++){let c=i[a],l=i[a+1],d=i[a+2],u=i[a+3],p=Math.hypot(d.x-l.x,d.y-l.y),f=Math.hypot(l.x-c.x,l.y-c.y),m=Math.hypot(u.x-d.x,u.y-d.y),g=Math.pow(f,r),h=Math.pow(p,r),y=Math.pow(m,r),b=Math.pow(f,2*r),v=Math.pow(p,2*r),I=Math.pow(m,2*r),x,k,T,w;f<1e-8?(x=l.x,k=l.y):(x=(b*d.x-v*c.x+(2*b+3*g*h+v)*l.x)/(3*g*(g+h)),k=(b*d.y-v*c.y+(2*b+3*g*h+v)*l.y)/(3*g*(g+h))),m<1e-8?(T=d.x,w=d.y):(T=(I*l.x-v*u.x+(2*I+3*y*h+v)*d.x)/(3*y*(y+h)),w=(I*l.y-v*u.y+(2*I+3*y*h+v)*d.y)/(3*y*(y+h))),o+=` C ${x} ${k} ${T} ${w} ${d.x} ${d.y}`}return e&&(o+=" Z"),o}function Q0(t,e){let n=t.length;if(n<2)return n===1?`M ${t[0].x} ${t[0].y}`:"";if(n===2)return`M ${t[0].x} ${t[0].y} L ${t[1].x} ${t[1].y}`;if(e){let o=(t[0].x+4*t[1].x+t[2].x)/6,s=(t[0].y+4*t[1].y+t[2].y)/6,a=`M ${o} ${s}`;for(let c=0;c<n;c++){let l=t[(c+1)%n],d=t[(c+2)%n],u=t[(c+3)%n];a+=kf(l,d,u)}return a+=" Z",a}let r=t,i=`M ${r[0].x} ${r[0].y}`;i+=` L ${(5*r[0].x+r[1].x)/6} ${(5*r[0].y+r[1].y)/6}`;for(let o=0;o<=n-3;o++)i+=kf(r[o],r[o+1],r[o+2]);return i+=kf(r[n-2],r[n-1],r[n-1]),i+=` L ${r[n-1].x} ${r[n-1].y}`,i}function kf(t,e,n){return` C ${(2*t.x+e.x)/3} ${(2*t.y+e.y)/3} ${(t.x+2*e.x)/3} ${(t.y+2*e.y)/3} ${(t.x+4*e.x+n.x)/6} ${(t.y+4*e.y+n.y)/6}`}function rl(t,e,n){let r=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(n)?Math.max(1,n):4;switch(t){case"dashed":case"dotted":case"custom":return`${r} ${i}`;default:return null}}var vS={bearing:!0,catmullRom:!0},xS={M:["number","number"],m:["number","number"],L:["number","number"],l:["number","number"],H:["number"],h:["number"],V:["number"],v:["number"],C:["number","number","number","number","number","number"],c:["number","number","number","number","number","number"],S:["number","number","number","number"],s:["number","number","number","number"],Q:["number","number","number","number"],q:["number","number","number","number"],T:["number","number"],t:["number","number"],A:["number","number","number","flag","flag","number","number"],a:["number","number","number","flag","flag","number","number"],Z:[],z:[]},eP=new Set(Object.keys(xS));function tP(t){return t===32||t===9||t===10||t===12||t===13}function ol(t){return t>=48&&t<=57}function IS(t){return t>=65&&t<=90||t>=97&&t<=122}var Rf=class{constructor(e){this.source=e}source;position=0;get length(){return this.source.length}skipWhitespace(){for(;this.position<this.length&&tP(this.source.charCodeAt(this.position));)this.position++}skipOptionalCommaWhitespace(){this.skipWhitespace(),this.source.charCodeAt(this.position)===44&&(this.position++,this.skipWhitespace())}readNumber(){let e=this.position,n=e,r=this.source.charCodeAt(n);(r===43||r===45)&&n++;let i=0;for(;n<this.length&&ol(this.source.charCodeAt(n));)n++,i++;if(this.source.charCodeAt(n)===46){let a=n;n++;let c=0;for(;n<this.length&&ol(this.source.charCodeAt(n));)n++,c++;if(c===0){if(i===0)return null;n=a}}else if(i===0)return null;let o=this.source.charCodeAt(n);if(o===101||o===69){let a=n;n++;let c=this.source.charCodeAt(n);(c===43||c===45)&&n++;let l=0;for(;n<this.length&&ol(this.source.charCodeAt(n));)n++,l++;l===0&&(n=a)}let s=Number(this.source.slice(e,n));return Number.isFinite(s)?(this.position=n,s):null}readFlag(){let e=this.source[this.position];return e!=="0"&&e!=="1"?null:(this.position++,e==="1"?1:0)}};function wS(t,e){return eP.has(t)||(t==="B"||t==="b")&&e.bearing?!0:(t==="R"||t==="r")&&e.catmullRom===!0}function nP(t){if(!t)return!1;let e=t.charCodeAt(0);return ol(e)||t==="+"||t==="-"||t==="."||t===","}function rP(t,e,n,r){return{code:t,offset:e.position,command:n,message:r}}function Tf(t,e,n){let r=[];for(let i=0;i<e.length;i++){i>0||n?t.skipOptionalCommaWhitespace():t.skipWhitespace();let o=e[i]==="flag"?t.readFlag():t.readNumber();if(o===null)return null;r.push(o)}return r}function il(t,e){if(t.skipWhitespace(),t.position>=t.length)return"end";let n=t.source[t.position];return wS(n,e)?"command":nP(n)?"parameter":IS(n.charCodeAt(0))?"unsupported-command":"unexpected"}function kn(t,e={}){let n=new Rf(t),r=e.extensions??{},i=[],o=!0,s=(a,c,l)=>({commands:i,error:rP(a,n,c,l)});for(;;){if(n.skipWhitespace(),n.position>=n.length)return{commands:i,error:null};let a=n.position,c=n.source[n.position];if(!wS(c,r)){let f=IS(c.charCodeAt(0))?"unsupported-command":"unexpected-content";return s(f,null,`Unexpected path content '${c}'`)}n.position++;let l=c;if(o&&l!=="M"&&l!=="m")return s("initial-moveto-required",l,"Path data must begin with moveto");if(o=!1,l==="Z"||l==="z"){i.push({type:l,params:[],offset:a});let f=il(n,r);if(f==="end"||f==="command")continue;return s(f==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Closepath cannot be implicitly repeated")}if(l==="B"||l==="b"){let f=[];for(;;){let m=Tf(n,["number"],f.length>0);if(!m){if(f.length===0)return s("missing-parameter",l,"Bearing requires at least one angle");break}f.push(m[0]);let g=il(n,r);if(g!=="parameter"){if(g==="end"||g==="command")break;return i.push({type:l,params:f,offset:a}),s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Invalid bearing command content")}}i.push({type:l,params:f,offset:a});continue}if(l==="R"||l==="r"){let f=[];for(;;){let m=Tf(n,["number","number"],f.length>0);if(!m)return s("missing-parameter",l,"Catmull-Rom requires complete coordinate pairs");f.push(...m);let g=il(n,r);if(g!=="parameter"){if(g==="end"||g==="command")break;return s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Invalid Catmull-Rom command content")}}if(f.length<6)return s("missing-parameter",l,`R/r: needs at least 3 coordinate pairs, got ${f.length/2}`);i.push({type:l,params:f,offset:a});continue}let u=xS[l],p=0;for(;;){let f=Tf(n,u,p>0);if(!f)return s("missing-parameter",l,`Incomplete ${l} command parameters`);let m=p>0&&(l==="M"||l==="m")?l==="M"?"L":"l":l;i.push({type:m,params:f,offset:a}),p++;let g=il(n,r);if(g==="end"||g==="command")break;if(g!=="parameter")return s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,`Unexpected content in ${l} command`)}}}function sl(t){return t.map(e=>e.params.length===0?e.type:`${e.type} ${e.params.join(" ")}`).join(" ")}function iP(t,e,n){let r=[...t.params];if(t.type!==t.type.toUpperCase())return r;switch(t.type){case"M":case"L":case"T":case"C":case"S":case"Q":case"R":for(let i=0;i<r.length;i+=2)r[i]+=e,r[i+1]+=n;break;case"H":r[0]+=e;break;case"V":r[0]+=n;break;case"A":r[5]+=e,r[6]+=n;break}return r}function kS(t,e,n){let r=kn(t);return r.error?null:sl(r.commands.map((i,o)=>{let s=iP(i,e,n);return o===0&&i.type==="m"&&(s[0]+=e,s[1]+=n),{...i,params:s}}))}function PS(t,e){let n=kn(t);if(n.error)return null;let[r,i,o,s,a,c]=e,l=[],d=0,u=0,p=0,f=0,m=(h,y)=>[r*h+o*y+a,i*h+s*y+c],g=(h,y,b)=>{l.push({type:h,params:y,offset:b})};for(let h of n.commands){let y=h.type===h.type.toLowerCase(),b=h.type.toUpperCase(),v=h.params,I=d,x=u;if(b==="A")return null;if(b==="Z"){g("Z",[],h.offset),d=p,u=f;continue}if(b==="H"){d=y?d+v[0]:v[0],g("L",m(d,u),h.offset);continue}if(b==="V"){u=y?u+v[0]:v[0],g("L",m(d,u),h.offset);continue}let k=T=>[(y?I:0)+v[T],(y?x:0)+v[T+1]];switch(b){case"M":case"L":case"T":{let T=k(0);d=T[0],u=T[1],b==="M"&&(p=d,f=u),g(b,m(d,u),h.offset);break}case"C":{let T=m(...k(0)),w=m(...k(2)),P=k(4);d=P[0],u=P[1],g("C",[...T,...w,...m(...P)],h.offset);break}case"S":case"Q":{let T=m(...k(0)),w=k(2);d=w[0],u=w[1],g(b,[...T,...m(...w)],h.offset);break}}}return sl(l)}var Hi=Math.PI*2;function oP(t,e,n,r){let i=e*e-4*t*n;if(!(i>=0))return;let o=Math.sqrt(i),s=-.5*(e+(e>=0?o:-o));if(t!==0){let a=s/t;a>0&&a<1&&r.push(a)}if(s!==0){let a=n/s;a>0&&a<1&&r.push(a)}}function sP(t,e,n,r,i){let o=1-i;return o*o*o*t+3*o*o*i*e+3*o*i*i*n+i*i*i*r}function aP(t,e,n,r){let i=1-r;return i*i*t+2*i*r*e+r*r*n}function cl(t,e,n,r){let i=t<r?t:r,o=t>r?t:r,s=-t+3*e-3*n+r,a=2*(t-2*e+n),c=e-t,l=[];oP(s,a,c,l);for(let d of l){let u=sP(t,e,n,r,d);u<i&&(i=u),u>o&&(o=u)}return{min:i,max:o}}function ll(t,e,n){let r=t<n?t:n,i=t>n?t:n,o=t-2*e+n;if(o!==0){let s=(t-e)/o;if(s>0&&s<1){let a=aP(t,e,n,s);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function TS(t,e,n,r){let i=t*r-e*n>=0?1:-1,o=Math.sqrt((t*t+e*e)*(n*n+r*r));if(o===0)return 0;let s=(t*n+e*r)/o;return s<-1?s=-1:s>1&&(s=1),i*Math.acos(s)}function Ns(t,e,n,r,i,o,s,a,c){if(t===a&&e===c||n===0||r===0)return null;let l=Math.abs(n),d=Math.abs(r),u=i%360*Math.PI/180,p=Math.cos(u),f=Math.sin(u),m=(t-a)/2,g=(e-c)/2,h=p*m+f*g,y=-f*m+p*g,b=h*h,v=y*y,I=l*l,x=d*d,k=b/I+v/x;if(k>1){let U=Math.sqrt(k);l*=U,d*=U,I=l*l,x=d*d}let T=I*v+x*b;if(T===0)return null;let w=(I*x-T)/T;w<0&&(w=0);let P=Math.sqrt(w);o===s&&(P=-P);let N=P*(l*y/d),R=P*(-(d*h)/l),$=p*N-f*R+(t+a)/2,A=f*N+p*R+(e+c)/2,O=(h-N)/l,G=(y-R)/d,M=(-h-N)/l,V=(-y-R)/d,X=TS(1,0,O,G),Y=TS(O,G,M,V);return!s&&Y>0?Y-=Hi:s&&Y<0&&(Y+=Hi),{cx:$,cy:A,rx:l,ry:d,phi:u,theta1:X,deltaTheta:Y}}function cP(t,e){let n=Math.cos(t.phi),r=Math.sin(t.phi),i=e?We(e,{x:t.cx,y:t.cy}):{x:t.cx,y:t.cy},o=e?Fc(e,{x:t.rx*n,y:t.rx*r}):{x:t.rx*n,y:t.rx*r},s=e?Fc(e,{x:-t.ry*r,y:t.ry*n}):{x:-t.ry*r,y:t.ry*n};return{cx:i.x,cy:i.y,ux:o.x,uy:o.y,vx:s.x,vy:s.y}}function lP(t,e){let n=Math.cos(e),r=Math.sin(e);return{x:t.cx+t.ux*n+t.vx*r,y:t.cy+t.uy*n+t.vy*r}}function dP(t,e,n){if(n>=0){let i=(t-e)%Hi;return i<0&&(i+=Hi),i<=n}let r=(e-t)%Hi;return r<0&&(r+=Hi),r<=-n}function $f(t,e,n,r,i,o,s,a,c,l){let d=l?We(l,{x:t,y:e}):{x:t,y:e},u=l?We(l,{x:a,y:c}):{x:a,y:c},p={minX:Math.min(d.x,u.x),minY:Math.min(d.y,u.y),maxX:Math.max(d.x,u.x),maxY:Math.max(d.y,u.y)},f=Ns(t,e,n,r,i,o,s,a,c);if(!f)return p;let m=cP(f,l),g=Math.atan2(m.vx,m.ux),h=Math.atan2(m.vy,m.uy),y=[g,g+Math.PI,h,h+Math.PI];for(let b of y){if(!dP(b,f.theta1,f.deltaTheta))continue;let v=lP(m,b);v.x<p.minX&&(p.minX=v.x),v.x>p.maxX&&(p.maxX=v.x),v.y<p.minY&&(p.minY=v.y),v.y>p.maxY&&(p.maxY=v.y)}return p}var Cf=class{constructor(e){this.params=e}params;index=0;readNumber(){return this.params[this.index++]??null}readFlag(){let e=this.readNumber();return e===null?null:e===1}};function al(t,e,n,r){let i=r?We(r,{x:e,y:n}):{x:e,y:n};i.x<t.minX&&(t.minX=i.x),i.x>t.maxX&&(t.maxX=i.x),i.y<t.minY&&(t.minY=i.y),i.y>t.maxY&&(t.maxY=i.y),t.any=!0}function Nf(t,e){e.minX<t.minX&&(t.minX=e.minX),e.maxX>t.maxX&&(t.maxX=e.maxX),e.minY<t.minY&&(t.minY=e.minY),e.maxY>t.maxY&&(t.maxY=e.maxY),t.any=!0}function RS(t,e,n,r,i,o,s,a,c,l){let d=l?We(l,{x:e,y:n}):{x:e,y:n},u=l?We(l,{x:r,y:i}):{x:r,y:i},p=l?We(l,{x:o,y:s}):{x:o,y:s},f=l?We(l,{x:a,y:c}):{x:a,y:c},m=cl(d.x,u.x,p.x,f.x),g=cl(d.y,u.y,p.y,f.y);Nf(t,{minX:m.min,maxX:m.max,minY:g.min,maxY:g.max})}function CS(t,e,n,r,i,o,s,a){let c=a?We(a,{x:e,y:n}):{x:e,y:n},l=a?We(a,{x:r,y:i}):{x:r,y:i},d=a?We(a,{x:o,y:s}):{x:o,y:s},u=ll(c.x,l.x,d.x),p=ll(c.y,l.y,d.y);Nf(t,{minX:u.min,maxX:u.max,minY:p.min,maxY:p.max})}function fn(t,e){if(!t)return null;let n=kn(t),r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},i=0,o=0,s=0,a=0,c=0,l=0,d=null,u="",p=()=>r.any?{minX:r.minX,minY:r.minY,maxX:r.maxX,maxY:r.maxY}:null;for(let f of n.commands){u=f.type;let m=new Cf(f.params),g=u>="a"&&u<="z";switch(u){case"M":case"m":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();i=g?i+h:h,o=g?o+y:y,s=i,a=o,al(r,i,o,e),d=null,u=g?"l":"L";break}case"L":case"l":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();i=g?i+h:h,o=g?o+y:y,al(r,i,o,e),d=null;break}case"H":case"h":{let h=m.readNumber();if(h===null)return p();i=g?i+h:h,al(r,i,o,e),d=null;break}case"V":case"v":{let h=m.readNumber();if(h===null)return p();o=g?o+h:h,al(r,i,o,e),d=null;break}case"C":case"c":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber(),I=m.readNumber(),x=m.readNumber();if(h===null||y===null||b===null||v===null||I===null||x===null)return p();let k=g?i+h:h,T=g?o+y:y,w=g?i+b:b,P=g?o+v:v,N=g?i+I:I,R=g?o+x:x;RS(r,i,o,k,T,w,P,N,R,e),c=w,l=P,d="cubic",i=N,o=R;break}case"S":case"s":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber();if(h===null||y===null||b===null||v===null)return p();let I=d==="cubic"?2*i-c:i,x=d==="cubic"?2*o-l:o,k=g?i+h:h,T=g?o+y:y,w=g?i+b:b,P=g?o+v:v;RS(r,i,o,I,x,k,T,w,P,e),c=k,l=T,d="cubic",i=w,o=P;break}case"Q":case"q":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber();if(h===null||y===null||b===null||v===null)return p();let I=g?i+h:h,x=g?o+y:y,k=g?i+b:b,T=g?o+v:v;CS(r,i,o,I,x,k,T,e),c=I,l=x,d="quad",i=k,o=T;break}case"T":case"t":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();let b=d==="quad"?2*i-c:i,v=d==="quad"?2*o-l:o,I=g?i+h:h,x=g?o+y:y;CS(r,i,o,b,v,I,x,e),c=b,l=v,d="quad",i=I,o=x;break}case"A":case"a":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readFlag(),I=m.readFlag(),x=m.readNumber(),k=m.readNumber();if(h===null||y===null||b===null||v===null||I===null||x===null||k===null)return p();let T=g?i+x:x,w=g?o+k:k;Nf(r,$f(i,o,h,y,b,v,I,T,w,e)),i=T,o=w,d=null;break}case"Z":case"z":{i=s,o=a,d=null;break}default:return p()}}return p()}function $S(t,e,n=!1,r=.5,i,o){return t.length===0?null:fn(kr(t,e,n,r,i),o)}function NS(t){return t.replace(/[^a-zA-Z0-9_-]/g,"_")}function uP(t){let e=t.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function Af(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(Af).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${Af(n)}`).join(",")}}`}function pP(t){let e=new Map,n=r=>{for(let i of r)e.set(i.id,(e.get(i.id)??0)+1),Array.isArray(i.state.children)&&n(i.state.children)};return n(t),e}function AS(t,e,n){return t.map(r=>{let i=n.has(r.id)?e[r.id]:void 0,o=i?{...r.state,...i}:{...r.state},s=o.children;return Array.isArray(s)&&(o.children=AS(s,e,n)),i!==void 0||o.children!==r.state.children?{...r,state:o}:r})}function fi(t,e){let n=String(e.state.variantKey??""),r=n?t.variants?.[n]:void 0,i=r?n:"",o=r??t.shapes,s=[];n&&!r&&s.push({code:"unknown-symbol-variant",shapeId:e.id,message:`Symbol instance ${e.id} requests unknown variant ${n} from ${t.id}; the base definition is used.`});let a=e.state.symbolOverrides??{},c=Object.entries(a),l=o;if(c.length>0){let f=pP(o),m=new Set;for(let[g]of c){let h=f.get(g)??0;h===1?m.add(g):s.push({code:h>1?"ambiguous-symbol-override-target":"unresolved-symbol-override-target",shapeId:e.id,message:h>1?`Symbol instance ${e.id} override target ${g} is ambiguous in ${t.id}.`:`Symbol instance ${e.id} override target ${g} is absent from ${t.id}.`})}l=AS(o,a,m)}let d=i!==""||c.length>0,u=c.length>0?`${t.id}--ovr-${e.id}`:i?`${t.id}--${NS(i)}`:t.id,p=`${t.id}\0${i}\0${Af(a)}`;return{shapes:l,requestedVariantKey:n,effectiveVariantKey:i,candidateTargetId:u,materializationKey:p,materialized:d,diagnostics:s}}function Wi(t,e=!1){let n=t.state.symbolId??"",r=t.state.variantKey??"";return e||uP(t)?`${n}--ovr-${t.id}`:r?`${n}--${NS(r)}`:n}function ES(t,e){return[...fi(t,e).shapes]}function Te(t,e,n){return Object.freeze({type:t,renderer:e,resolve:n})}function fP(t){let e=t.state,n=e.x??0,r=e.y??0;return{kind:"circle",shapeType:"circle",cx:n,cy:r,r:e.radius??50,defaultPivot:{x:n,y:r}}}function mP(t){let e=t.state,n=e.cx??e.x??0,r=e.cy??e.y??0;return{kind:"ellipse",shapeType:"ellipse",cx:n,cy:r,rx:e.rx??50,ry:e.ry??30,pathLength:e.pathLength,defaultPivot:{x:n,y:r}}}function MS(t){let e=t.state,n=e,r=e.x??0,i=e.y??0,o=t.type==="square"?e.size:void 0,s=o??e.width??100,a=o??e.height??100,c=e.cornerRadius??0,l=e.rx,d=e.ry,u=l!==void 0&&l>=0?l:void 0,p=d!==void 0&&d>=0?d:void 0,f=Math.max(0,c),m=u??p??f,g=u??m,h=p??m,y=Math.min(Math.max(0,g),Math.max(0,s)/2),b=Math.min(Math.max(0,h),Math.max(0,a)/2),v=n.cornerShape??"round",I=n.cornerMode??"uniform",x=null;return(v!=="round"||I==="non-uniform")&&(x=tl(r,i,s,a,c,v,I,I==="non-uniform"?{radiusTL:n.cornerRadiusTL,radiusTR:n.cornerRadiusTR,radiusBR:n.cornerRadiusBR,radiusBL:n.cornerRadiusBL,shapeTL:n.cornerShapeTL,shapeTR:n.cornerShapeTR,shapeBR:n.cornerShapeBR,shapeBL:n.cornerShapeBL}:void 0)||null),{kind:"rectangle",shapeType:t.type,x:r,y:i,width:s,height:a,rx:y,ry:b,pathData:x,defaultPivot:{x:r+s/2,y:i+a/2}}}function gP(t){let e=t.state,n=e.x1??0,r=e.y1??0,i=e.x2??0,o=e.y2??0;return{kind:"line",shapeType:"line",x1:n,y1:r,x2:i,y2:o,boundsPolicy:e.sourceRef||e.targetRef||e.routingMode?"linked-line":"analytic",defaultPivot:{x:(n+i)/2,y:(r+o)/2}}}function hP(t){let e=t.state.textX??t.state.x??0,n=t.state.textY??t.state.y??0;return{kind:"text",shapeType:"text",x:e,y:n,boundsPolicy:"measure-text",defaultPivot:{x:e,y:n}}}function yP(t){let e=t.state,n=e.pathPoints??[],r=kr(n,e.pathCurveType??"CUBIC",e.pathClosed??!1,e.pathTension??.5,e.pathArcParams),i=n.length>0?e.customPivot??{x:n[0].x,y:n[0].y}:null;return{kind:"path",shapeType:"path",role:"spline",d:r,placement:null,fillRule:null,defaultPivot:i}}function SP(t){let e=t.state,n=e.polylinePoints??[];return{kind:"polyline",shapeType:"polyline",points:n,closed:e.polylineClosed??!1,defaultPivot:n.length>0?e.customPivot??{x:n[0].x,y:n[0].y}:null}}function dl(t,e,n,r){let i=t.state,o=i.x??0,s=i.y??0,a=i.width??n,c=i.height??r;return{kind:"positioning-rect",shapeType:t.type,role:e,x:o,y:s,width:a,height:c,defaultPivot:{x:o+a/2,y:s+c/2}}}function mn(t,e,n=!1){let r=t.state,i=r.cx??0,o=r.cy??0,s={radius:r.radius??50,cornerRadius:r.cornerRadius??0,shiftAngle:r.shiftAngle??-90,fillRule:r.fillRule??"nonzero"};return{kind:"path",shapeType:t.type,role:"polygon",d:e(r,s),placement:{x:i,y:o},fillRule:n?s.fillRule:null,defaultPivot:{x:i,y:o}}}function Ki(t,e){let n=t.state,r=n.x??0,i=n.y??0,o=n.width??100,s=n.height??60;return{kind:"path",shapeType:e,role:"flowchart",d:nl(e,r,i,o,s,{slantPercent:n.slantPercent,topWidthPercent:n.topWidthPercent,capHeightPercent:n.capHeightPercent,waveAmplitudePercent:n.waveAmplitudePercent}),placement:null,fillRule:null,defaultPivot:{x:r+o/2,y:i+s/2}}}function ul(t,e){return{kind:"container",shapeType:t.type,role:e,boundsPolicy:"children",defaultPivot:null}}function bP(t){let e=t.state;return{kind:"embedded-svg",shapeType:"svg",x:e.svgX,y:e.svgY,width:e.svgWidth,height:e.svgHeight,viewBoxX:e.svgViewBoxX,viewBoxY:e.svgViewBoxY,viewBoxWidth:e.svgViewBoxWidth,viewBoxHeight:e.svgViewBoxHeight,preserveAspectRatio:e.svgPreserveAspectRatio,boundsPolicy:"children",defaultPivot:null}}function vP(t){let e=t.state;return{kind:"view",shapeType:"view",viewBoxX:e.viewBoxX,viewBoxY:e.viewBoxY,viewBoxWidth:e.viewBoxWidth,viewBoxHeight:e.viewBoxHeight,preserveAspectRatio:e.viewPreserveAspectRatio,boundsPolicy:"none",defaultPivot:null}}function xP(t){let e=t.state;return{kind:"shape-reference",shapeType:"shape-reference",targetShapeId:e.targetShapeId,offsetX:e.offsetX??0,offsetY:e.offsetY??0,width:e.width,height:e.height,boundsPolicy:"reference",defaultPivot:null}}function IP(t){let e=t.state;return{kind:"symbol-instance",shapeType:"symbol-instance",symbolId:e.symbolId??"",targetId:Wi(t),x:e.x??0,y:e.y??0,width:e.width??100,height:e.height??100,boundsPolicy:"symbol",defaultPivot:null}}var DS=Object.freeze({rectangle:Te("rectangle","rectangle",MS),square:Te("square","rectangle",MS),circle:Te("circle","circle",fP),ellipse:Te("ellipse","ellipse",mP),line:Te("line","line",gP),text:Te("text","text",hP),image:Te("image","image",t=>dl(t,"image",100,100)),path:Te("path","path",yP),polyline:Te("polyline","polyline",SP),triangle:Te("triangle","polygon",t=>mn(t,(e,n)=>wn($s(3,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),ngon:Te("ngon","polygon",t=>mn(t,(e,n)=>wn($s(e.sides??6,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),star:Te("star","polygon",t=>mn(t,(e,n)=>wn(Hc(e.arms??5,n.radius,e.innerRadiusPercent??50,n.shiftAngle),n.cornerRadius,n.radius))),cross:Te("cross","polygon",t=>mn(t,(e,n)=>wn(Wc(n.radius,e.armWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),ring:Te("ring","polygon",t=>mn(t,(e,n)=>Jc(n.radius,e.innerRadiusPercent??50,n.fillRule),!0)),spiral:Te("spiral","polygon",t=>mn(t,(e,n)=>Qc(n.radius,e.turns??3,e.thicknessPercent??20,e.spiralDirection??1,n.shiftAngle))),gear:Te("gear","polygon",t=>mn(t,(e,n)=>el(e.teeth??8,n.radius,e.toothDepthPercent??30,n.cornerRadius,e.holeRadiusPercent??0,n.fillRule,n.shiftAngle),!0)),arrow:Te("arrow","polygon",t=>mn(t,(e,n)=>wn(Kc(n.radius,e.headWidthPercent??100,e.headLengthPercent??30,e.shaftWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),"symbol-instance":Te("symbol-instance","symbol-instance",IP),group:Te("group","container",t=>ul(t,"group")),container:Te("container","container",t=>ul(t,"group")),cloud:Te("cloud","polygon",t=>mn(t,(e,n)=>Zc(n.radius,e.cloudBumps??5,e.cloudPuffinessPercent??60,n.shiftAngle))),heart:Te("heart","polygon",t=>mn(t,(e,n)=>qc(n.radius,e.lobeRadiusPercent??50,e.cleftDepthPercent??25,n.shiftAngle))),lightning:Te("lightning","polygon",t=>mn(t,(e,n)=>wn(Yc(n.radius,e.boltSegments??3,e.boltJaggednessPercent??40,e.boltWidthPercent??30,n.shiftAngle),n.cornerRadius,n.radius))),speechBubble:Te("speechBubble","polygon",t=>mn(t,(e,n)=>wn(Xc(n.radius,e.tailAngleDeg??45,e.tailLengthPercent??40,e.tailWidthPercent??25,n.shiftAngle),n.cornerRadius,n.radius))),diamond:Te("diamond","flowchart",t=>Ki(t,"diamond")),parallelogram:Te("parallelogram","flowchart",t=>Ki(t,"parallelogram")),trapezoid:Te("trapezoid","flowchart",t=>Ki(t,"trapezoid")),terminator:Te("terminator","flowchart",t=>Ki(t,"terminator")),cylinder:Te("cylinder","flowchart",t=>Ki(t,"cylinder")),"document-shape":Te("document-shape","flowchart",t=>Ki(t,"document-shape")),hyperlink:Te("hyperlink","hyperlink",t=>ul(t,"hyperlink")),switch:Te("switch","switch",t=>ul(t,"switch")),svg:Te("svg","svg",bP),view:Te("view","view",vP),"shape-reference":Te("shape-reference","shape-reference",xP),video:Te("video","media",t=>dl(t,"video",320,180)),audio:Te("audio","media",t=>dl(t,"audio",320,180)),"foreign-object":Te("foreign-object","foreign-object",t=>dl(t,"foreign-object",100,100))}),wP=Object.freeze(Object.keys(DS));function zS(){return wP}function Xi(t){return DS[t]}function Qt(t){return Xi(t.type)?.resolve(t)??null}function OS(t,e,n,r){return n<0||r<0?null:{minX:t,minY:e,maxX:t+n,maxY:e+r}}function kP(t){if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;for(let o=1;o<t.length;o++){let s=t[o];s.x<e&&(e=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y)}return{minX:e,minY:n,maxX:r,maxY:i}}function As(t,e){let n=Qt(t);if(!n)return null;switch(n.kind){case"circle":return n.r<0?null:{minX:n.cx-n.r,minY:n.cy-n.r,maxX:n.cx+n.r,maxY:n.cy+n.r};case"ellipse":return n.rx<0||n.ry<0?null:{minX:n.cx-n.rx,minY:n.cy-n.ry,maxX:n.cx+n.rx,maxY:n.cy+n.ry};case"rectangle":return n.pathData?fn(n.pathData):OS(n.x,n.y,n.width,n.height);case"line":return n.boundsPolicy==="linked-line"?null:{minX:Math.min(n.x1,n.x2),minY:Math.min(n.y1,n.y2),maxX:Math.max(n.x1,n.x2),maxY:Math.max(n.y1,n.y2)};case"text":return e?.measureText?.(t,n)??null;case"path":return fn(n.d,n.placement?qe(n.placement.x,n.placement.y):void 0);case"polyline":return kP(n.points);case"positioning-rect":return OS(n.x,n.y,n.width,n.height);case"container":case"embedded-svg":case"view":case"shape-reference":case"symbol-instance":return null}}function pl(t,e){let n=As(t,e);return n?{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2}:null}var _S=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u,PP=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function fl(t){return(t.match(PP)??[]).map(Number).filter(Number.isFinite)}function FS(t){let e=fl(t),n=e.length-e.length%2,r=[];for(let i=0;i<n;i+=2)r.push(`${e[i]},${e[i+1]}`);return r.join(" ")}function Es(t,e){let n=fl(t),r=fl(e),i=n.length-n.length%2,o=r.length-r.length%2;if(i!==o)return null;if(i===0)return"";let s=[];for(let a=0;a<i;a+=2)s.push(`${n[a]+r[a]},${n[a+1]+r[a+1]}`);return s.join(" ")}function ml(t){return t.additive==="sum"||t.values==null&&t.from==null&&t.to==null&&t.by!=null?"sum":"replace"}function Pr(t,e,n="number"){if(n==="points"){let r=a=>FS(a.trim()),i=ml(t)==="sum",o=e===void 0?void 0:r(e),s=a=>{if(!i||o===void 0)return[...a];let c=a.map(l=>Es(o,l));return c.every(l=>l!==null)?c:null};if(t.values){let a=t.values.split(";").map(c=>c.trim()).filter(Boolean).map(r);return a.length===0?null:s(a)}if(t.from!=null&&t.to!=null)return s([r(t.from),r(t.to)]);if(t.from!=null&&t.by!=null){let a=r(t.from),c=Es(a,r(t.by));return c===null?null:s([a,c])}if(t.to!=null&&o!==void 0){let a=r(t.to);if(!i)return[o,a];let c=Es(o,a);return c===null?null:[o,c]}if(t.by!=null&&o!==void 0){let a=Es(o,r(t.by));return a===null?null:[o,a]}return null}if(t.values){let r=t.values.split(";").map(i=>i.trim()).filter(Boolean);return r.length===0?null:r}if(t.from!=null&&t.to!=null)return[t.from.trim(),t.to.trim()];if(t.from!=null&&t.by!=null){let r=Number(t.from),i=Number(t.by);return Number.isFinite(r)&&Number.isFinite(i)?[String(r),String(r+i)]:null}if(t.to!=null&&e!==void 0)return[e.trim(),t.to.trim()];if(t.by!=null){let r=Number(t.by);return Number.isFinite(r)?["0",String(r)]:null}return null}function gl(t){let e=t.dur?.trim();return!e||e==="indefinite"||e==="media"?0:nr(e)}function or(t,e,n=t.calcMode??"linear"){if(t.keyTimes){let r=t.keyTimes.split(";").map(i=>i.trim());if(r.length===e&&r.every(i=>_S.test(i)))return r.map(Number)}return e<=1?e===1?[0]:[]:n==="discrete"?Array.from({length:e},(r,i)=>i/e):Array.from({length:e},(r,i)=>i/(e-1))}function sr(t){return t.keySplines?t.keySplines.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let n=fl(e);return[n[0]??0,n[1]??0,n[2]??0,n[3]??0]}):[]}function Ef(t){if(t.repeatCount==="indefinite")return{cycleInfinite:!0};if(t.repeatCount&&_S.test(t.repeatCount.trim())){let e=Number(t.repeatCount);if(e>1)return{cycleRepeats:Math.round(e)}}if(t.repeatDur==="indefinite")return{cycleInfinite:!0};if(t.repeatDur){let e=nr(t.repeatDur),n=gl(t);if(e>0&&n>0){let r=Math.max(1,Math.ceil(e/n));if(r>1)return{cycleRepeats:r}}}return{}}function Mf(t){return t.fill==="freeze"?{}:{fill:"remove"}}function Pn(t,e,n,r,i,o){let s=[];for(let a=0;a<t.length&&a<e.length;a++){let c=t[a].trim(),l=o==="color"||o==="path"||o==="points"||o==="numberList"||o==="discrete",d=Number(c),u={time:e[a]*r,value:l||!Number.isFinite(d)?c:d,easing:"linear"};if(a>0&&i==="spline"&&n[a-1]){let p=Ec(...n[a-1]);u.easing=p.easing,p.customBezier&&(u.customBezier=p.customBezier)}else a>0&&i==="discrete"&&(u.easing="steps",u.stepsParams={count:1,position:"jump-end"});s.push(u)}return s}var TP=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:h|min|s|ms)?$/iu,RP=/^([A-Za-z_][\w.-]*)\.repeat\((\d+)\)\s*([+-]\s*\S+)?$/u,CP=/^([A-Za-z_][\w.-]*)\.(begin|end)\s*([+-]\s*\S+)?$/u,Of=class{bySourceId=new Map;beginCache=new Map;resolving=new Set;constructor(e){for(let n of e)n.sourceAnimationId&&!this.bySourceId.has(n.sourceAnimationId)&&this.bySourceId.set(n.sourceAnimationId,n)}activations(e){let r=(e.attributes.begin??"0s").split(";").map(c=>c.trim()).filter(Boolean),i=r.flatMap(c=>{let l=this.resolveEntry(c);return l!==null&&Number.isFinite(l)?[{entry:c,time:l}]:[]}),o=new Map;for(let c of i)o.set(c.time,c.entry);let a=r.length>1&&e.kind!=="discard"&&e.additive!=="sum"&&o.size>1?[...o.keys()].sort((c,l)=>c-l):i.length>0?[i[0].time]:[null];return Object.freeze(a.map(c=>{let l=Object.freeze({...e.attributes,...c!==null?{begin:`${c}s`}:{}}),d=e.duration;if(e.attributes.values?.split(";").map(p=>p.trim()).filter(Boolean)?.length===1&&c!==null&&e.attributes.end){let p=this.resolveEntry(e.attributes.end.split(";")[0].trim());p!==null&&Number.isFinite(p)&&p>=c&&(d=p-c)}return Object.freeze({...e,attributes:l,duration:d})}))}resolveCandidateBegin(e){let n=this.beginCache.get(e.animationId);if(n!==void 0)return n;if(this.resolving.has(e.animationId))return null;this.resolving.add(e.animationId);let r=e.attributes.begin?.split(";")[0]?.trim()||"0s",i=this.resolveEntry(r);return this.resolving.delete(e.animationId),i!==null&&this.beginCache.set(e.animationId,i),i}resolveEntry(e){if(!e||e==="0")return 0;if(e==="indefinite")return Number.POSITIVE_INFINITY;if(TP.test(e))return nr(e);let n=e.match(RP);if(n){let i=this.bySourceId.get(n[1]);if(!i)return null;let o=this.resolveCandidateBegin(i);if(o===null||!Number.isFinite(o))return o;let s=Number(n[2]),a=this.repeatEventTime(i,o,s);return a===null||!Number.isFinite(a)?a:a+this.offset(n[3])}let r=e.match(CP);if(r){let i=this.bySourceId.get(r[1]);if(!i)return null;let o=this.resolveCandidateBegin(i);if(o===null||!Number.isFinite(o))return o;let s=this.activeDuration(i),a=r[2]==="end"?s!==null?o+s:null:o;return a===null?null:a+this.offset(r[3])}return null}offset(e){return e?nr(e.replace(/\s+/gu,"")):0}repeatEventTime(e,n,r){if(r<1||e.duration<=0)return Number.POSITIVE_INFINITY;let i=this.activeDuration(e);return i===null||r*e.duration>=i?Number.POSITIVE_INFINITY:n+r*e.duration}activeDuration(e){if(e.duration<=0)return null;let n=e.attributes.repeatCount,r=e.attributes.repeatDur,i=e.duration,o=!1;if(n==="indefinite"&&(i=Number.POSITIVE_INFINITY,o=!0),n&&n!=="indefinite"){let s=Number(n);Number.isFinite(s)&&s>0&&(i=s*e.duration,o=!0)}if(r==="indefinite")o||(i=Number.POSITIVE_INFINITY);else if(r){let s=nr(r);Number.isFinite(s)&&s>=0&&(i=o?Math.min(i,s):s)}return i}},Fn=Object.freeze({cx:{property:"x",valueType:"number",stateKey:"x"},cy:{property:"y",valueType:"number",stateKey:"y"},d:{property:"pathMorph",valueType:"path",stateKey:"d"},display:{property:"display",valueType:"discrete",stateKey:"display"},fill:{property:"fillColor",valueType:"color",stateKey:"fillColor"},"fill-opacity":{property:"fillOpacity",valueType:"number",stateKey:"fillOpacity"},height:{property:"height",valueType:"number",stateKey:"height"},opacity:{property:"opacity",valueType:"number",stateKey:"opacity"},points:{property:"polylinePoints",valueType:"points",stateKey:"points"},r:{property:"radius",valueType:"number",stateKey:"radius"},rx:{property:"rx",valueType:"number",stateKey:"rx"},ry:{property:"ry",valueType:"number",stateKey:"ry"},stroke:{property:"strokeColor",valueType:"color",stateKey:"borderColor"},target:{property:"linkTarget",valueType:"discrete",stateKey:"linkTarget"},"stroke-dasharray":{property:"strokeDasharray",valueType:"numberList",stateKey:"strokeDasharray"},"stroke-dashoffset":{property:"strokeDashoffset",valueType:"number",stateKey:"strokeDashoffset"},"stroke-linecap":{property:"strokeLinecap",valueType:"discrete",stateKey:"strokeLinecap"},"stroke-linejoin":{property:"strokeLinejoin",valueType:"discrete",stateKey:"strokeLinejoin"},"stroke-miterlimit":{property:"strokeMiterlimit",valueType:"number",stateKey:"strokeMiterlimit"},"stroke-opacity":{property:"strokeOpacity",valueType:"number",stateKey:"strokeOpacity"},"stroke-width":{property:"strokeWidth",valueType:"number",stateKey:"borderWidth"},visibility:{property:"visibility",valueType:"discrete",stateKey:"visibility"},width:{property:"width",valueType:"number",stateKey:"width"},x:{property:"x",valueType:"number",stateKey:"x"},x1:{property:"x1",valueType:"number",stateKey:"x1"},x2:{property:"x2",valueType:"number",stateKey:"x2"},y:{property:"y",valueType:"number",stateKey:"y"},y1:{property:"y1",valueType:"number",stateKey:"y1"},y2:{property:"y2",valueType:"number",stateKey:"y2"}}),$P=Object.freeze({...Fn,"font-size":{property:"fontSize",valueType:"number",stateKey:"fontSize"}}),NP=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function GS(t){return(t.match(NP)??[]).map(Number).filter(Number.isFinite)}function Df(t,e){let n=t?.[e];if(n!=null)return Array.isArray(n)?n.join(" "):String(n)}function VS(t){switch(t.property){case"visibility":return"visible";case"display":return"inline";case"opacity":case"fillOpacity":case"strokeOpacity":return"1";default:return}}function Tn(t){let e=t.attributes.begin?.split(";")[0]?.trim();return!e||e==="0"||e==="0s"?{offset:0}:/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:h|min|s|ms)?$/iu.test(e)?{offset:nr(e)}:/^[A-Za-z_][\w.-]*(?:\.[A-Za-z_][\w.-]*)?(?:[+-].+)?$/u.test(e)?{offset:0,beginTrigger:{type:"event",value:e}}:{offset:0,beginTrigger:{type:"expression",value:e}}}function gi(t){let e=Ef(t.attributes),n=Tn(t);return{enabled:!0,cycleBehavior:"restart",...t.duration>0?{cycleDuration:t.duration}:{},...t.additive==="sum"?{additive:"sum"}:{},...e,...Mf(t.attributes),...n.beginTrigger?{beginTrigger:n.beginTrigger}:{}}}function Yi(t,e){return t.map(n=>({...n,time:n.time+e}))}function jS(t,e,n,r,i){let o=t.attributeName?.toLowerCase();if(!o)return null;let s=i?.projection??Fn[o]??{property:o,valueType:"discrete",stateKey:o},a=t.attributes,c=i?.underlying??Df(n,s.stateKey)??VS(s),l=Pr(a,c,s.valueType);if(!l||l.length===0)return null;let d=t.kind==="set"?"discrete":a.calcMode??"linear",u=t.duration,p=Tn(t);if(t.kind==="set"){let h=[{time:p.offset,value:l.at(-1),easing:"linear"}];return u>0&&t.fill==="remove"&&c!==void 0&&h.push({time:p.offset+u,value:c,easing:"linear"}),{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...u>0?{cycleDuration:u}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"set",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:h}}if(l.length===1){let h=Pn(l,[0],[],u,"discrete",s.valueType)[0]?.value;if(h===void 0)return null;let y=[{time:p.offset,value:h,easing:"linear"}];if(u>0&&t.fill==="remove"&&c!==void 0){let b=Pn([c],[0],[],u,"discrete",s.valueType)[0]?.value;b!==void 0&&y.push({time:p.offset+u,value:b,easing:"linear"})}return{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...u>0?{cycleDuration:u}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:y}}let f=or(a,l.length,d),m=sr(a),g=Yi(Pn(l,f,m,u,d,s.valueType),p.offset);return g.length<2?null:{id:`svg-animation-${r}`,shapeId:e,property:s.property,...gi(t),...d!=="linear"?{calcMode:d}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:g}}var AP=Object.freeze({"stop-color":{suffix:"Color",valueType:"color"},"stop-opacity":{suffix:"Opacity",valueType:"number"},offset:{suffix:"Offset",valueType:"number"}});function EP(t,e){return e==="stop-color"?t.color:String(e==="stop-opacity"?t.opacity:t.offset)}function MP(t,e,n,r){let i=t.attributeName?.toLowerCase(),o=t.targetSourceNodeId;if(!e||!i||!o)return[];let s=AP[i];if(!s||t.kind!=="animate"&&t.kind!=="set")return[];let a=[],c=new Set;for(let l of e.candidates)l.stops.forEach((d,u)=>{if(!(d.sourceNodeId!==o&&d.correspondingSourceNodeId!==o)){for(let p of e.bindings)if(!(p.gradientSourceNodeId!==l.sourceNodeId||p.propertyName!=="fill"&&p.propertyName!=="stroke"))for(let f of US(p.occurrenceId,n)){let m=`${p.propertyName}GradientStop${u}${s.suffix}`,g=`${f.shapeId}|${m}`;if(c.has(g))continue;c.add(g);let h=jS(t,f.shapeId,f.state,r+a.length,{projection:{property:m,valueType:s.valueType,stateKey:m},underlying:EP(d,i)});h&&a.push(h)}}});return a}function US(t,e){let n=e.shapeBindingsForOccurrence?.(t);if(n&&n.length>0)return n;let r=e.shapeIdForOccurrence(t);return r?[{shapeId:r,shapeType:"unknown",state:e.shapeStateForOccurrence(t)}]:[]}var OP=new Set(["clip-path","display","fill","mask","opacity","visibility"]);function DP(t,e){if(t.targetStatus!=="resolved"||!t.targetOccurrenceId)return[];let n=US(t.targetOccurrenceId,e);if(!n.some(i=>i.shapeType==="group")||t.kind==="animateTransform"||t.kind==="animateMotion"||t.kind==="discard"||OP.has(t.attributeName?.toLowerCase()??""))return n;let r=e.descendantShapeBindingsForOccurrence?.(t.targetOccurrenceId);return r&&r.length>0?r:n}function zP(t,e,n){if(t.kind!=="animate"||t.attributeName?.toLowerCase()!=="viewbox")return[];let r=e.shapeType==="svg"?"svgViewBox":e.shapeType==="view"?"viewBox":null;if(!r||t.duration<=0)return[];let i=Pr(t.attributes,void 0,"numberList");if(!i||i.length<2)return[];let o=i.map(GS);if(o.some(d=>d.length<4))return[];let s=t.attributes.calcMode??"linear",a=or(t.attributes,o.length,s),c=sr(t.attributes),l=Tn(t);return["X","Y","Width","Height"].map((d,u)=>({id:`svg-animation-${n+u}`,shapeId:e.shapeId,property:`${r}${d}`,...gi(t),...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:Yi(Pn(o.map(p=>String(p[u])),a,c,t.duration,s,"number"),l.offset)}))}var _P=Object.freeze([{cssProperty:"fill",projection:Fn.fill},{cssProperty:"stroke",projection:Fn.stroke},{cssProperty:"stroke-width",projection:Fn["stroke-width"]},{cssProperty:"fill-opacity",projection:Fn["fill-opacity"]},{cssProperty:"stroke-opacity",projection:Fn["stroke-opacity"]},{cssProperty:"opacity",projection:Fn.opacity},{cssProperty:"visibility",projection:Fn.visibility},{cssProperty:"display",projection:Fn.display}]);function LS(t,e){if(e==="number"){let n=Number.parseFloat(t);if(Number.isFinite(n))return String(n)}return t.trim().toLowerCase()}function FP(t,e,n,r){if(!t.targetOccurrenceId||t.attributeName?.toLowerCase()!=="class")return[];let i=t.kind==="set"?t.attributes.to===void 0?null:["",t.attributes.to]:Pr(t.attributes,void 0,"discrete");if(!i||i.length<2||t.kind==="animate"&&t.duration<=0)return[];let o=Math.max(t.duration,.001),s=or(t.attributes,i.length,"discrete"),a=sr(t.attributes),c=Tn(t),l=i.map(u=>n.stylesheetValuesWithClass(t.targetOccurrenceId,u)),d=[];for(let{cssProperty:u,projection:p}of _P){let f=Df(e.state,p.stateKey)??VS(p)??"",m=l.map(h=>h[u]??f),g=LS(f,p.valueType);m.every(h=>LS(h,p.valueType)===g)||d.push({id:`svg-animation-${r+d.length}`,shapeId:e.shapeId,property:p.property,...gi(t),calcMode:"discrete",sourceSmilElement:t.kind==="set"?"set":"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:Yi(Pn(m,s,a,o,"discrete",p.valueType),c.offset)})}return d}function LP(t,e,n){let r=t.attributes.type?.trim().toLowerCase();if(!r)return[];let i=t.attributes,o=Pr(i,void 0,"numberList");if(!o||o.length<2)return[];let s=i.calcMode??"linear",a=or(i,o.length,s),c=sr(i),l=Tn(t),d=gi(t),u=o.map(GS),p=(f,m,g,h)=>{let y=Pn(o.map((b,v)=>{let I=m(u[v]);return Array.isArray(I)?I.join(" "):String(I)}),a,c,t.duration,s,f==="transformMatrix"?"numberList":"number").map((b,v)=>({...b,time:b.time+l.offset,value:f==="transformMatrix"?u[v].slice(0,6):b.value}));return{id:`svg-animation-${n+g}`,shapeId:e,property:f,...d,additive:t.additive,...t.additive==="replace"&&t.replacesCarrierBase?{replacesCarrierBase:!0}:{},...h?{transformOrigin:h}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:y}};if(r==="translate")return[p("translateX",f=>f[0]??0,0),p("translateY",f=>f[1]??0,1)];if(r==="scale")return[p("scaleX",f=>f[0]??1,0),p("scaleY",f=>f[1]??f[0]??1,1)];if(r==="rotate"){let f=u.find(m=>m.length>=3);return[p("rotation",m=>m[0]??0,0,f?{x:f[1],y:f[2]}:{x:0,y:0})]}return r==="skewx"||r==="skewy"?[p(r==="skewx"?"skewX":"skewY",f=>f[0]??0,0)]:r==="matrix"&&u.every(f=>f.length>=6)?[p("transformMatrix",f=>f.slice(0,6),0)]:[]}function HS(t,e,n,r){if(!t.motionPathData||t.duration<=0)return null;let i=t.attributes.keyPoints?.split(";").map(Number).filter(Number.isFinite),o=i&&i.length>=2?i:[0,1],s=t.attributes.calcMode??"paced",a=or(t.attributes,o.length,s),c=sr(t.attributes),l=Tn(t),d=t.attributes.rotate?.trim(),u=d===void 0?Number.NaN:Number(d),p=t.motionPathSourceNodeId?n.shapeIdForSourceNode(t.motionPathSourceNodeId):null;return{id:`svg-animation-${r}`,shapeId:e,property:"pathMotion",...gi(t),motionPath:t.motionPathData,...p?{motionPathRef:{shapeId:p,mode:"curveTemplate"}}:{},...d==="auto"||d==="auto-reverse"?{motionRotate:d}:Number.isFinite(u)?{motionRotate:u}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...s!=="linear"&&s!=="paced"?{calcMode:s}:{},keyframes:Yi(Pn(o.map(String),a,c,t.duration,s,"number"),l.offset)}}var BP=new Set(["cx","cy","r","rx","ry","x","y","x1","y1","x2","y2","width","height","opacity","fill-opacity","stroke-opacity","stop-opacity","stroke-width","stroke-dashoffset","stroke-miterlimit","offset","pathlength","startoffset","fr"]),GP=new Set(["fill","stroke","stop-color","flood-color","lighting-color"]);function mi(t){return{shapeId:t.shapeId,domTargetSelector:t.selector}}function VP(t,e,n,r){let i=HS(t,e.shapeId,n,r);return i?{...i,property:"domTransformStack",additive:t.additive,...mi(e),transformFunction:"translate",transformStackIndex:0,transformBaseValue:e.baseTransform}:null}function jP(t,e,n,r){let i=t.attributes.type?.trim();if(i!=="translate"&&i!=="scale"&&i!=="rotate"&&i!=="skewX"&&i!=="skewY"&&i!=="matrix")return null;let o=Pr(t.attributes,void 0,"discrete");if(!o||o.length<2||t.duration<=0)return null;let s=t.attributes.calcMode??"linear",a=or(t.attributes,o.length,s),c=sr(t.attributes),l=Tn(t);return{id:`svg-animation-${n}`,...mi(e),property:"domTransformStack",...gi(t),additive:t.additive,...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animateTransform",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},transformFunction:i,transformStackIndex:r,transformBaseValue:e.baseTransform,keyframes:Yi(Pn(o,a,c,t.duration,s,"discrete"),l.offset)}}function UP(t,e,n){let r=t.attributeName;if(!r||t.kind!=="animate"&&t.kind!=="set")return null;let i=r.toLowerCase(),o=e.baseAttributes[r]??e.baseAttributes[i]??"",s=t.kind==="animate"&&(i==="display"||i==="visibility"),a=t.kind==="set"?"string":BP.has(i)?"number":GP.has(i)?"color":"string";if(t.kind==="set"){let g=t.attributes.to?.trim();if(g===void 0)return null;let h=Tn(t),y=[{time:h.offset,value:g,easing:"linear"}];return t.duration>0&&t.fill==="remove"&&y.push({time:h.offset+t.duration,value:o,easing:"linear"}),{id:`svg-animation-${n}`,...mi(e),property:"domAttribute",enabled:!0,...t.duration>0?{cycleDuration:t.duration}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"set",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},domAttribute:r,domAttributeValueType:"string",transformBaseValue:o,keyframes:y}}let c=s||a==="string"?"discrete":a,l=Pr(t.attributes,o,c);if(!l||l.length===0||t.duration<=0)return null;let d=s?"discrete":t.attributes.calcMode??"linear",u=or(t.attributes,l.length,d),p=sr(t.attributes),f=Tn(t),m=s?i==="display"?"domDisplay":"domVisibility":"domAttribute";return{id:`svg-animation-${n}`,...mi(e),property:m,...gi(t),calcMode:d,sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...m==="domAttribute"?{domAttribute:r,domAttributeValueType:a}:{},transformBaseValue:o,keyframes:Yi(Pn(l,u,p,t.duration,d,c),f.offset)}}function HP(t,e,n,r,i){if(t.kind==="animateMotion")return VP(t,e,n,r);if(t.kind==="animateTransform")return jP(t,e,r,i);if(t.kind==="discard"){let o=Tn(t);return{id:`svg-animation-${r}`,...mi(e),property:"discard",enabled:!0,sourceSmilElement:"discard",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},transformBaseValue:e.baseAttributes.display??"",keyframes:[{time:o.offset,value:1,easing:"linear"}]}}return UP(t,e,r)}function WP(t,e,n,r,i){let o=DP(t,n);if(o.length===0&&t.targetOccurrenceId){let a=n.domTargetForOccurrence?.(t.targetOccurrenceId),c=a?HP(t,a,n,r,i):null;return c?[c]:[]}let s=[];for(let a of o){if(t.kind==="animateTransform"){s.push(...LP(t,a.shapeId,r+s.length));continue}if(t.kind==="animateMotion"){let u=HS(t,a.shapeId,n,r+s.length);u&&s.push(u);continue}if(t.kind==="discard"){let u=Tn(t);s.push({id:`svg-animation-${r+s.length}`,shapeId:a.shapeId,property:"discard",enabled:!0,sourceSmilElement:"discard",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:[{time:u.offset,value:1,easing:"linear"}]});continue}let c=zP(t,a,r+s.length);if(c.length>0){s.push(...c);continue}let l=FP(t,a,e,r+s.length);if(l.length>0){s.push(...l);continue}let d=jS(t,a.shapeId,a.state,r+s.length);d&&s.push(d)}return s}function hl(t){let e=Number(t.iterationCount);return{enabled:!0,cycleDuration:t.duration,cycleBehavior:t.direction==="reverse"||t.direction==="alternate"||t.direction==="alternate-reverse"?t.direction:"restart",...t.iterationCount==="infinite"?{cycleInfinite:!0}:Number.isFinite(e)&&e>=0&&e!==1?{cycleRepeats:e}:{},...hf(t)}}var KP=Object.freeze([["translateX",0],["translateY",0],["scaleX",1],["scaleY",1],["rotation",0],["skewX",0],["skewY",0]]);function XP(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId),o=i?null:n.domTargetForOccurrence?.(t.occurrenceId),s=i??o?.shapeId??null;if(!s)return[];let a=e.value(t.occurrenceId,"transform-box")??"view-box",c=n.cssTransformContextForOccurrence?.(t.occurrenceId,a),l=n.shapeBindingsForOccurrence?.(t.occurrenceId)[0],d=(a==="fill-box"||a==="content-box")&&l?.state?As({id:l.shapeId,type:l.shapeType,state:l.state}):null,u={...d?{boxX:d.minX,boxY:d.minY,boxWidth:d.maxX-d.minX,boxHeight:d.maxY-d.minY}:{},...c??{}},p=t.keyframes.stops.flatMap(x=>{let k=x.properties.transform??x.properties["-webkit-transform"]??x.properties["-moz-transform"];return k===void 0?[]:[{offset:x.offset,raw:k,timing:x.properties["animation-timing-function"]}]});if(p.length===0)return[];let f=e.value(t.occurrenceId,"transform")??"none";p[0].offset>0&&p.unshift({offset:0,raw:f,timing:void 0}),p.at(-1).offset<1&&p.push({offset:1,raw:f,timing:void 0});let h=e.style(t.occurrenceId)?.cascadedValues["transform-origin"]?Ts(e.value(t.occurrenceId,"transform-origin")??"0 0",u):{x:0,y:0},y=Rs(p.map(({offset:x,raw:k})=>({offset:x,transform:k})),{...u,...h?{transformOrigin:h}:{},retainPureRotationOrigin:!o,progressForInterval:(x,k)=>{let T=p[x]?.timing;return af(T?si(T):t.animation.parsedEasing,k)}});if(y.status!=="projected")return[];if(o)return[{id:`svg-animation-${r}`,...mi(o),property:"domTransformStack",...hl(t.animation),additive:"replace",replacesCarrierBase:!0,transformFunction:"matrix",transformStackIndex:0,transformBaseValue:o.baseTransform,template:{name:t.animation.name},keyframes:y.stops.map(x=>yl(x.offset,x.matrix.join(" "),t.animation,y.sampled?"linear":p.findLast(k=>k.offset<x.offset)?.timing))}];let b=y.stops.map(x=>({offset:x.offset,channels:x})),v=new Set(y.channels),I=[];for(let[x,k]of KP){if(!v.has(x))continue;let T=b.flatMap(({offset:w,channels:P})=>{if(!P)return[];let N=P[x]??k,R=p.findLastIndex($=>$.offset<w);return[yl(w,N,t.animation,y.sampled?"linear":p[Math.max(0,R)]?.timing)]});T.length<2||I.push({id:`svg-animation-${r+I.length}`,shapeId:s,property:x,...hl(t.animation),additive:x==="translateX"||x==="translateY"?"sum":"replace",replacesCarrierBase:!0,...x==="rotation"&&h&&(y.pureRotation||h.x===0&&h.y===0&&(h.z??0)===0)?{transformOrigin:{x:h.x,y:h.y}}:{},template:{name:t.animation.name},keyframes:T})}return I}function BS(t,e){let n=t.trim();if(e!=="number")return n;let r=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(?:px)?$/iu.exec(n);if(!r)return null;let i=Number(r[1]);return Number.isFinite(i)?i:null}function yl(t,e,n,r){let i={time:t*n.duration+n.delay,value:e,easing:n.easing},o=r?si(r):n.parsedEasing;return o&&sf(i,o),i}function YP(t,e){if(t.length!==0){if(t[0].offset>0){let n=e();n&&t.unshift({...n,offset:0})}if(t.at(-1).offset<1){let n=e();n&&t.push({...n,offset:1})}}}function qP(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId),o=i?null:n.domTargetForOccurrence?.(t.occurrenceId),s=i??o?.shapeId??null;if(!s)return[];let a=n.shapeStateForOccurrence(t.occurrenceId),c=new Set(t.keyframes.stops.flatMap(d=>Object.keys(d.properties)));c.delete("animation-timing-function"),c.delete("transform"),c.delete("-webkit-transform"),c.delete("-moz-transform");let l=[];for(let d of c){let u=$P[d];if(!u)continue;let p=t.keyframes.stops.flatMap(m=>{let g=m.properties[d];if(g===void 0)return[];let h=BS(g,u.valueType);return h===null?[]:[{offset:m.offset,value:h,timing:m.properties["animation-timing-function"]}]}),f=e.value(t.occurrenceId,d)??Df(a,u.stateKey)??o?.baseAttributes[d];if(YP(p,()=>{if(f==null)return null;let m=BS(f,u.valueType);return m===null?null:{offset:0,value:m,timing:void 0}}),!(p.length<2)){if(o){l.push({id:`svg-animation-${r+l.length}`,...mi(o),property:"domAttribute",domAttribute:d,domAttributeValueType:u.valueType==="number"?"number":u.valueType==="color"?"color":"string",...hl(t.animation),template:{name:t.animation.name},keyframes:p.map((m,g)=>yl(m.offset,m.value,t.animation,g===0?void 0:p[g-1].timing))});continue}l.push({id:`svg-animation-${r+l.length}`,shapeId:s,property:u.property,...hl(t.animation),template:{name:t.animation.name},keyframes:p.map((m,g)=>yl(m.offset,m.value,t.animation,g===0?void 0:p[g-1].timing))})}}return l}function ZP(t){let e=Math.max(0,...t.keyframes.map(n=>n.time));return df(t)??e}function zf(t,e,n,r){let i=new Of(t.smil),o=[],s=[],a=[],c=[],l=[],d=new Map,u=new Map;for(let g of t.smil){let h=0;if(g.kind==="animateTransform"&&g.targetOccurrenceId){let y=`${g.targetOccurrenceId}|${g.sourceNodeId}`,b=d.get(y);b!==void 0?h=b:(h=u.get(g.targetOccurrenceId)??0,d.set(y,h),u.set(g.targetOccurrenceId,h+1))}for(let y of i.activations(g)){let b=MP(y,r,n,1),v=b.length>0?b:WP(y,e,n,1,h);g.kind==="animateTransform"?o.push(...v):g.kind==="animateMotion"?s.push(...v):g.kind==="set"?c.push(...v):g.kind==="discard"?l.push(...v):a.push(...v)}}let p=[],f=[];for(let g of t.css)p.push(...XP(g,e,n,1)),f.push(...qP(g,e,n,1));let m=[...o,...s,...a,...c,...l,...p,...f].map((g,h)=>{let y=`svg-animation-${h+1}`;return{...g,id:y,keyframes:g.keyframes.map((b,v)=>({...b,id:b.id??`${y}-kf-${v+1}`}))}});return m.length===0?null:{duration:Math.max(...m.map(ZP)),loop:m.some(g=>g.cycleInfinite===!0),playbackSpeed:1,tracks:m}}function Ms(t,e){return zf(t.animations,t.styles,e,t.gradients)}var WS=["native-validation-warning","unavailable-shape-descriptor","malformed-source","missing-svg-root","invalid-svg-attribute","duplicate-svg-id","missing-svg-namespace","no-materializable-content","unsupported-svg-element","unsupported-ingest-capability","empty-hyperlink-dropped","nested-hyperlink-flattened","required-features-dropped","unresolved-reference","circular-use-reference","circular-resource-reference","use-expansion-limit-exceeded","external-effect-failed","application-rolled-back"],qi=["native-document-open","full-snapshot-restore","svg-document-import","external-svg-paste","internal-clipboard-paste","plugin-svg-fragment","pattern-fragment","vectorized-svg-fragment"];var Ds=["geometry","containers","source-order","hierarchy","root-viewport-frame","common-presentation","conditional-processing","authored-attributes","gradients","patterns","filters","paint-server-definitions","markers","symbols","use-and-linked-references","clip-definitions","mask-definitions","clip-mask-membership","smil-animation","css-animation","metadata","scripts","styles","custom-properties","views","embedded-svg","fonts","external-assets"],ar=t=>({status:"supported",by:t}),Os=(t,e)=>({status:"diagnosed-unsupported",by:t,reason:e}),KS=(t,e)=>({status:"diagnosed-lossy",by:t,reason:e}),Tr=t=>({status:"exempt",reason:t}),JP="plugin SVG result diagnostic collector",Ff="pattern fragment diagnostic collector",Lf="vectorized SVG result diagnostic collector";function Fe(t,e={}){return{"native-document-open":ar("native snapshot parse and canonical restore"),"full-snapshot-restore":ar("canonical full-snapshot restore"),"svg-document-import":ar(t),"external-svg-paste":ar(t),"internal-clipboard-paste":ar("closed clipboard subgraph materializer"),"plugin-svg-fragment":e.plugin??ar("plugin fragment plan materializer"),"pattern-fragment":e.pattern??Os(Ff,"Pattern fragments retain only capabilities enrolled by the pattern tile contract."),"vectorized-svg-fragment":e.vectorized??Os(Lf,"Vectorized ingestion intentionally accepts path-oriented geometry only.")}}var Sl=t=>Os(JP,t),Rr=t=>Os(Ff,t),XS=t=>Os(Lf,t),en=t=>ar(t),_f=t=>ar(t),bl={geometry:Fe("SVG shape element parser",{pattern:en("fragment-scoped pattern shape parser"),vectorized:_f("vectorized path geometry parser")}),containers:Fe("SVG structural container planner",{pattern:en("fragment-scoped pattern hierarchy parser")}),"source-order":Fe("source document order index and SceneGraph placement",{pattern:en("pattern source-order materializer"),vectorized:_f("vectorized path document-order traversal")}),hierarchy:Fe("source DOM hierarchy planner and SceneGraph placement",{pattern:en("fragment-scoped pattern hierarchy materializer")}),"root-viewport-frame":Fe("root SVG frame parser and application policy",{plugin:Tr("Plugin fragment framing is consumed only for bounds scaling."),pattern:Tr("Pattern fragments use the explicit tile width and height as their local frame."),vectorized:KS(Lf,"Vectorized source framing is consumed only to scale path geometry into target bounds.")}),"common-presentation":Fe("shared SVG presentation parser",{pattern:en("pattern shape presentation parser"),vectorized:_f("vectorized path presentation parser")}),"conditional-processing":Fe("SVG switch and conditional-processing attribute parser",{pattern:en("pattern shape conditional-processing parser"),vectorized:XS("Vectorized ingestion does not preserve SVG conditional-processing branches.")}),"authored-attributes":Fe("authored-attribute preservation parser",{pattern:en("pattern authored-attribute preservation parser")}),gradients:Fe("gradient parser and library reference materializer",{pattern:en("fragment-scoped pattern gradient resolver")}),patterns:Fe("pattern parser and library reference materializer",{pattern:en("fragment-scoped nested-pattern resolver")}),filters:Fe("filter parser and reference materializer"),"paint-server-definitions":Fe("paint-server definition collector and materializer",{pattern:en("fragment-scoped pattern paint-server collector")}),markers:Fe("marker definition parser and reference materializer"),symbols:Fe("symbol definition and instance materializer"),"use-and-linked-references":Fe("use resolver and stable reference-edge materializer",{pattern:en("fragment-scoped linked-reference resolver")}),"clip-definitions":Fe("clip definition parser and materializer",{pattern:Rr("Pattern editing omits document clip definitions.")}),"mask-definitions":Fe("mask definition parser and materializer",{pattern:Rr("Pattern editing omits document mask definitions.")}),"clip-mask-membership":Fe("clip and mask membership materializer",{pattern:Rr("Pattern editing omits document clip and mask membership.")}),"smil-animation":Fe("SMIL parser and animation-track materializer",{pattern:Rr("Pattern editing materializes a static tile without SMIL tracks.")}),"css-animation":Fe("CSS keyframe parser and animation-track materializer",{pattern:Rr("Pattern editing materializes a static tile without CSS animation tracks.")}),metadata:Fe("document metadata parser and field policy",{plugin:Sl("Plugin fragments preserve host document metadata."),pattern:Tr("Pattern fragments have no document metadata scope."),vectorized:Tr("Vectorized fragments have no document metadata scope.")}),scripts:Fe("inert script partitioner and document script materializer",{plugin:ar("inert plugin fragment script data materializer"),pattern:Rr("Pattern fragments do not execute or adopt scripts."),vectorized:XS("Vectorized fragments do not execute or adopt scripts.")}),styles:Fe("preserved CSS style collector and materializer",{pattern:en("fragment-scoped pattern style resolver")}),"custom-properties":Fe("CSS custom-property collector and materializer",{pattern:en("fragment-scoped pattern variable resolver")}),views:Fe("SVG view parser and SceneGraph materializer",{plugin:Sl("Plugin fragments do not alter document navigation views."),pattern:Tr("Pattern fragments have no document navigation view scope."),vectorized:Tr("Vectorized fragments have no document navigation view scope.")}),"embedded-svg":Fe("embedded SVG container parser and materializer",{pattern:KS(Ff,"Pattern editing flattens nested SVG content into the local tile frame.")}),fonts:Fe("declared font-consent effect and approved loader",{plugin:Sl("Plugin fragments do not start an implicit external font consent flow."),pattern:Rr("Pattern fragments do not start an implicit font consent flow."),vectorized:Tr("Path-only vectorized fragments do not consume font resources.")}),"external-assets":Fe("declared external-asset resolver with proxy policy",{plugin:Sl("Plugin fragments diagnose assets outside the enrolled security policy."),pattern:Rr("Pattern fragments diagnose external assets instead of fetching them."),vectorized:Tr("Path-only vectorized fragments do not consume external assets.")})};function YS(t,e){return bl[t][e]}function qS(t=Ds,e=qi,n=bl){if(t.length===0)throw new Error("Ingest feature roster must not be empty.");if(e.length===0)throw new Error("Ingress intent roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("Ingest feature roster contains duplicate entries.");if(new Set(e).size!==e.length)throw new Error("Ingress intent roster contains duplicate entries.");for(let r of Object.keys(n))if(!t.includes(r))throw new Error(`Unknown ingest feature ${r} has a capability matrix.`);for(let r of t){let i=n[r];if(!i)throw new Error(`Ingest feature ${r} lacks a capability matrix.`);for(let o of e){let s=i[o];if(!s)throw new Error(`Ingest feature ${r} lacks intent ${o}.`);if((s.status==="exempt"?s.reason:s.by).trim().length<12)throw new Error(`Ingest feature ${o} lacks a substantive owner or reason.`);if((s.status==="diagnosed-lossy"||s.status==="diagnosed-unsupported")&&s.reason.trim().length<24)throw new Error(`Ingest feature ${o} lacks a substantive diagnostic reason.`)}for(let o of Object.keys(i))if(!e.includes(o))throw new Error(`Ingest feature ${r} has unknown intent ${o}.`)}}var hi=1,zs="document-root:0";function _s(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return`fnv1a32:${(e>>>0).toString(16).padStart(8,"0")}`}function Fs(t){let e=structuredClone(t),n=r=>{if(!(r===null||typeof r!="object"||Object.isFrozen(r))){for(let i of Object.values(r))n(i);Object.freeze(r)}};return n(e),e}function QP(t){if(t instanceof Map)return t;let e=new Map;for(let n of t)e.set(n.id,n);return e}function eT(t){if(t.kind==="marker")return t.shapes;if(t.kind!=="symbol")return[];if(!t.variants)return t.shapes;let e=[...t.shapes];for(let n of Object.values(t.variants))e.push(...n);return e}function ZS(t,e,n,r){let i=QP(n),o=new Set,s=[],a=[],c=u=>{if(typeof u!="string"||!u||o.has(u))return;let p=i.get(u);p&&(p.kind!=="symbol"&&p.kind!=="marker"||(o.add(u),s.push(p)))},l=u=>{a.push(u)},d=u=>{let p=u.state;if(!p)return;c(p.symbolId),c(p.markerStart),c(p.markerMid),c(p.markerEnd);let f=p.children;if(Array.isArray(f))for(let g of f)l(g);let m=p.symbolOverrides;if(m&&typeof m=="object"&&!Array.isArray(m))for(let[g,h]of Object.entries(m))!h||typeof h!="object"||Array.isArray(h)||l({id:g,type:"symbol-override",state:h})};for(let u of t)l(u);for(let u of e)c(u);for(;;){let u=a.shift();if(u){r(u),d(u);continue}let p=s.shift();if(!p)break;for(let f of eT(p))l(f)}}var tT=[],nT=[];function Bs(t,e,n){ZS(t,nT,e,n)}function vl(t,e,n){ZS(tT,t,e,n)}function JS(t,e){if(!t)return;let n=t,r=n.markerStart;typeof r=="string"&&r&&e(r);let i=n.markerMid;typeof i=="string"&&i&&e(i);let o=n.markerEnd;typeof o=="string"&&o&&e(o);let s=n.startEndpoint;typeof s=="string"&&s&&s!=="none"&&e(Ls(s));let a=n.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(Ls(a))}function Ls(t){return`line-marker-${t}`}var QS=new Set(["fillLibraryId","strokeLibraryId","markerStart","markerMid","markerEnd","symbolId"]);function eb(t,e,n){if(!t)return;let r=t,i=s=>{typeof s=="string"&&s&&n(s)};i(r.fillLibraryId),i(r.strokeLibraryId),i(r.markerStart),i(r.markerMid),i(r.markerEnd),i(r.symbolId);let o=r.filterLibraryIds;if(Array.isArray(o)&&o.length>0)for(let s of o)i(s);else Array.isArray(r.filters)&&r.filters.length>0&&n(`filter-${e}`);r.fillLibraryId||i(r.fillGradient?.id),r.strokeLibraryId||i(r.strokeGradient?.id)}function yi(t,e=[]){let n=new Set,r=new Set;return Bs(t,e,i=>{let o=i.state;if(!o)return;typeof o.markerStart=="string"&&o.markerStart&&n.add(o.markerStart),typeof o.markerMid=="string"&&o.markerMid&&n.add(o.markerMid),typeof o.markerEnd=="string"&&o.markerEnd&&n.add(o.markerEnd);let s=o.startEndpoint,a=o.endEndpoint;typeof s=="string"&&s&&s!=="none"&&!o.markerStart&&r.add(s),typeof a=="string"&&a&&a!=="none"&&!o.markerEnd&&r.add(a)}),{ids:n,legacyEndpoints:r}}function tb(t,e){let{ids:n,legacyEndpoints:r}=yi(t,e);for(let i of r)n.add(Ls(i));return n}var nb=["validate","allocate-identities","document-fields","canonical-nodes","projections","references","commit","external-effects"];function rT(t){let e=t.map((o,s)=>({node:o,index:s})),n=new Set(t.map(o=>o.id)),r=new Set,i=[];for(;e.length>0;){let s=e.filter(({node:a})=>a.parentId===null||!n.has(a.parentId)||r.has(a.parentId)).sort((a,c)=>a.node.sourceOrder-c.node.sourceOrder||a.index-c.index)[0];if(!s)throw new Error("Ingestion node hierarchy contains a parent cycle.");e.splice(e.indexOf(s),1),i.push(s.node),r.add(s.node.id)}return i}var Gs=class extends Error{diagnostics;constructor(e,n,r){super(e,{cause:r}),this.name="IngestApplicationError",this.diagnostics=n}};function iT(t,e){let n=o=>o==="id"||/(?:Id|Ids)$/.test(o)||o==="shapeInsideRef"||QS.has(o),r=(o,s=!1)=>{if(s){let l=e.get(o);if(l)return l}if(o.startsWith("#")){let l=e.get(o.slice(1));if(l)return`#${l}`}let a=o.replace(/url\(\s*(['"]?)#([^'"\s)]+)\1\s*\)/g,(l,d,u)=>{let p=e.get(u);return p?`url(${d}#${p}${d})`:l});if(!a.includes("<"))return a;let c=a;for(let[l,d]of e){let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p="(?:&quot;|&apos;|&#34;|&#39;|&#x22;|&#x27;)";c=c.replace(new RegExp(`(\\bid\\s*=\\s*["'])${u}(["'])`,"g"),`$1${d}$2`).replace(new RegExp(`(\\b(?:href|xlink:href)\\s*=\\s*["']#)${u}(["'])`,"g"),`$1${d}$2`).replace(new RegExp(`([uU][rR][lL]\\(\\s*(?:${p})?#)${u}((?:${p})?\\s*\\))`,"gu"),`$1${d}$2`)}return c},i=(o,s=!1)=>{if(Array.isArray(o)){for(let a=0;a<o.length;a++){let c=typeof o[a]=="string"?r(o[a],s):void 0;c!==void 0?o[a]=c:i(o[a],s)}return}if(!(o===null||typeof o!="object"))for(let[a,c]of Object.entries(o)){let l=n(a),d=typeof c=="string"?r(c,l):void 0;d!==void 0?o[a]=d:i(c,l)}};for(let o of t.nodes)i(o.serialized),i(o.groupPath,!0);i(t.documentFields),i(t.referenceEdges),i(t.clipMaskGroups)}function Cr(t,e){if(e.injectFailureAfterStage===t)throw new Error(`Injected ingestion failure after ${t}.`)}function oT(t){let e=[],n=(i,o)=>{typeof i=="string"&&i.length>0&&e.push([i,o])},r=t.documentFields;for(let i of r.library??[])n(i.id,"library-definition");for(let i of r.paintServerDefs??[])n(i.id,"paint-server-definition");for(let i of r.documentStyles??[])n(i.id,"document-style");for(let i of r.documentScripts??[])n(i.id,"document-script");for(let i of r.animationTimeline?.tracks??[]){n(i.id,"animation-track");for(let o of i.keyframes)n(o.id,"animation-keyframe")}for(let i of t.clipMaskGroups)n(i.id,"clip-mask-group");return e}function rb(t,e,n={}){let r=e.captureRollbackState(),i=structuredClone([...t.diagnostics]),o="validate";try{if(t.planVersion!==1)throw new Error(`Unsupported ingestion plan version ${t.planVersion}.`);if(t.diagnostics.some(u=>u.severity==="error"))throw new Error("Ingestion plan contains an error diagnostic.");if(n.warningPolicy==="reject"&&t.diagnostics.some(u=>u.severity==="warning"))throw new Error("Ingestion warnings were rejected by caller policy.");Cr("validate",n),o="allocate-identities";let s=structuredClone(t),a=new Map,c=e.resolvePlanIdentity?.(zs);c&&a.set(zs,c);for(let u of s.nodes){if(a.has(u.planNodeId))throw new Error(`Duplicate plan node id ${u.planNodeId}.`);a.set(u.planNodeId,s.identityMode==="preserve"?u.planNodeId:e.allocateId(u.planNodeId,u.serialized.type))}for(let[u,p]of oT(s))a.has(u)||a.set(u,s.identityMode==="preserve"?u:e.allocateId(u,p));iT(s,a);let l={idMap:a,addDiagnostic:u=>i.push(structuredClone(u))};e.preparePlan?.(s,l),Cr("allocate-identities",n),o="document-fields";for(let[u,p]of Object.entries(s.documentFields)){let f=Vs(u,s.intent);f.action==="preserve-host"||f.action==="derived"||f.action==="exempt"||e.applyDocumentField(u,f,structuredClone(p),l)}Cr("document-fields",n);let d=rT(s.nodes.map(u=>({planNodeId:u.planNodeId,id:a.get(u.planNodeId),type:u.serialized.type,state:structuredClone(u.serialized.state),parentId:u.parentPlanNodeId?a.get(u.parentPlanNodeId)??null:null,sourceOrder:u.sourceOrder})));o="canonical-nodes";for(let u of d)e.createCanonicalNode(u,l);if(Cr("canonical-nodes",n),o="projections",e.hydrateProjection)for(let u of d)e.hydrateProjection(u,l);return Cr("projections",n),o="references",e.applyReferences?.(s,l),Cr("references",n),o="commit",e.commit?.(l),Cr("commit",n),o="external-effects",n.authorizeExternalEffects&&e.executeExternalEffects?.(s,l),Cr("external-effects",n),{value:{createdIds:d.map(u=>u.id),idMap:Object.freeze(Object.fromEntries(a))},diagnostics:i}}catch(s){let a;if(o!=="validate")try{e.restoreRollbackState(r)}catch(u){a=u}let c=s instanceof Error?s.message:String(s),l=a===void 0?"":` Rollback also failed: ${a instanceof Error?a.message:String(a)}`,d={severity:"error",code:"application-rolled-back",source:t.source.kind,entrypoint:t.intent,message:`Ingestion rolled back after ${o}: ${c}.${l}`};throw i.push(d),new Gs(d.message,i,s)}}var sb=require("saxes"),K="http://www.w3.org/2000/svg",Zi=class extends Error{constructor(n,r,i){super(r);this.hostId=n;this.name="SvgXmlParserHostError",this.cause=i}hostId;cause};function Bf(t,e){let n=null;for(let r=e;r<t.length;r++){let i=t[r];if(n){i===n&&(n=null);continue}if(i==='"'||i==="'")n=i;else if(i===">")return r+1}return t.length}function jf(t){let e=0,n=t.toLowerCase(),r=[];for(;e<t.length;){let s=t.indexOf("<",e);if(s<0)break;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);if(g<0)break;e=g+3;continue}if(t.startsWith("<![CDATA[",s)){let g=t.indexOf("]]>",s+9);if(g<0)break;e=g+3;continue}if(t.startsWith("<?",s)){let g=t.indexOf("?>",s+2);if(g<0)break;e=g+2;continue}let a=Bf(t,s+1),l=/^<\s*([^\s/>]+)/.exec(t.slice(s,a))?.[1]??"";if(l.split(":").at(-1)?.toLowerCase()!=="style"||t.slice(s,a).startsWith("</")){e=a;continue}let u=`</${l.toLowerCase()}`,p=n.indexOf(u,a);if(p<0)break;let f=t.slice(a,p);if(!f.includes("<")||f.includes("<![CDATA[")){e=Bf(t,p+2);continue}let m=`<![CDATA[${f.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;r.push({start:a,end:p,value:m}),e=Bf(t,p+2)}if(r.length===0)return t;let i="",o=0;for(let s of r)i+=t.slice(o,s.start),i+=s.value,o=s.end;return i+t.slice(o)}var sT=256,aT=64*1024,cT=32*1024*1024,Uf=String.raw`[\p{L}_:][\p{L}\p{N}\p{M}_.:\-]*`,lT=new RegExp(`^${Uf}$`,"u"),dT="http://www.w3.org/1999/xlink",uT=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu,pT=/(?:^|;)\s*([^\s;]+?)\.(?:begin|end|repeat\(\d+\))/gu,fT=new Set(["aria-labelledby","aria-describedby"]),mT=new RegExp(String.raw`<!ENTITY\s+(?!%)(${Uf})\s+(?:"([^"]*)"|'([^']*)')\s*>`,"gu"),ib=new RegExp(String.raw`&(#x[0-9A-Fa-f]+|#[0-9]+|${Uf});`,"gu"),gT=Object.freeze({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});function hT(t){let e=t.startsWith("#x")?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return e===9||e===10||e===13||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111?String.fromCodePoint(e):null}function yT(t,e,n){let r=new Map;for(let a of e.matchAll(mT)){if(r.size>=sT)return;r.set(a[1],a[2]??a[3]??"")}let i=new Map,o=(a,c)=>{let l=gT[a];if(l!==void 0)return l;let d=i.get(a);if(d!==void 0)return d;let u=r.get(a);if(u===void 0||c.has(a))return null;let p=new Set(c);p.add(a);let f=!0,m=u.replace(ib,(g,h)=>{let y=h.startsWith("#")?hT(h):o(h,p);return y===null?(f=!1,""):y});return!f||m.length>aT?null:(i.set(a,m),m)};for(let a of r.keys())o(a,new Set);let s=0;for(let a of n.matchAll(ib)){let c=i.get(a[1]);if(c!==void 0&&(s+=c.length,s>cT))return}for(let[a,c]of i)t.ENTITIES[a]=c}function ab(t){return t&&t.length>0?t:null}function ST(t,e){return{name:t.name,localName:t.local,prefix:t.prefix.length>0?t.prefix:null,namespaceUri:ab(t.uri),value:t.value,span:e}}var Hf={id:"saxes",parse(t){let e=[],n=[],r=[],i=0,o=[],s=0,a=0,c=new sb.SaxesParser({xmlns:!0,position:!0}),l=u=>{let p=n.at(-1);p?p.children.push(u):e.push(u)};c.on("error",u=>{r.push(u.message)}),c.on("opentagstart",()=>{i=t.lastIndexOf("<",Math.max(0,c.position-1)),o=[],s=c.position;let u=n.at(-1);u?u.contentOffset=i:a=i}),c.on("attribute",u=>{let p=t.indexOf(u.name,s),f=p>=0&&p<c.position?p:s;o.push({start:f,end:c.position}),s=c.position}),c.on("opentag",u=>{let p=Object.values(u.attributes).map((m,g)=>ST(m,o[g]??{start:i,end:c.position})),f={kind:"element",name:u.name,localName:u.local,prefix:u.prefix.length>0?u.prefix:null,namespaceUri:ab(u.uri),attributes:p,children:[],span:{start:i,end:c.position},startOffset:i,contentOffset:c.position};l(f),n.push(f)}),c.on("closetag",()=>{let u=n.pop();if(!u)return;u.rawXml=t.slice(u.startOffset,c.position),u.span.end=c.position;let p=n.at(-1);p?p.contentOffset=c.position:a=c.position});let d=(u,p,f,m)=>{l({kind:u,value:p,span:{start:f,end:m}});let g=n.at(-1);g?g.contentOffset=m:a=m};c.on("text",u=>{let p=n.at(-1)?.contentOffset??a,f=t.lastIndexOf("<",Math.max(0,c.position-1)),m=f>=p?f:c.position;d("text",u,p,m)}),c.on("comment",u=>{let p=t.lastIndexOf("<!--",c.position),f=t.indexOf("-->",Math.max(0,p));d("comment",u,Math.max(0,p),f>=0?f+3:c.position)}),c.on("cdata",u=>{let p=t.lastIndexOf("<![CDATA[",c.position),f=t.indexOf("]]>",Math.max(0,p));d("cdata",u,Math.max(0,p),f>=0?f+3:c.position)}),c.on("processinginstruction",({target:u,body:p})=>{let f=t.lastIndexOf("<?",c.position),m=t.indexOf("?>",Math.max(0,f));d("processing-instruction",p.length>0?`${u} ${p}`:u,Math.max(0,f),m>=0?m+2:c.position)}),c.on("doctype",u=>{yT(c,u,t);let p=t.lastIndexOf("<!DOCTYPE",c.position),f=t.indexOf(">",Math.max(0,p));d("doctype",u,Math.max(0,p),f>=0?f+1:c.position)});try{c.write(t).close()}catch(u){r.push(u instanceof Error?u.message:String(u))}return r.length>0?{error:r[0]}:{nodes:e}}};function ob(t,e,n){return{severity:"error",code:e,source:t.source,entrypoint:t.entrypoint,message:n,documentPath:"/",elementName:"svg"}}function Gf(t,e,n,r){return{severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,message:n,capability:"source-envelope",...r}}function Vf(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Le(t){let e=Vf(t,"href",null);if(e)return{value:e.value,namespace:"svg2"};let n=Vf(t,"href",dT);return n?{value:n.value,namespace:"xlink"}:null}function bT(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function vT(t,e){let n=e.filter(g=>g.kind==="element"),r=new Map(n.map(g=>[g.sourceNodeId,g])),i=new Map,o=new Map,s=new Map,a=(g,h)=>{s.set(g.sourceNodeId,h);let y=g.children.filter(v=>v.kind==="element");o.set(g.sourceNodeId,Object.freeze(y));let b=new Map;for(let v of y){i.set(v.sourceNodeId,g);let I=(b.get(v.name)??0)+1;b.set(v.name,I),a(v,`${h}/${v.name}[${I}]`)}};a(t,`/${t.name}[1]`);let c=new Map,l=[];for(let g of n){let h=Vf(g,"id",null)?.value;if(h===void 0)continue;let y=c.get(h)??[],b=Object.freeze({authoredId:h,sourceNodeId:g.sourceNodeId,elementOrder:g.elementOrder,occurrenceIndex:y.length,primary:y.length===0,validXmlId:h.length>0&&!/\s/u.test(h)&&lT.test(h)});y.push(b),c.set(h,y),l.push(b)}let d=[],u=new Map,p=(g,h,y,b,v)=>{let I=c.get(b)??[],x=Object.freeze({sourceReferenceId:`reference:${d.length}`,fromSourceNodeId:g.sourceNodeId,channel:h,...v!==void 0?{attributeName:v}:{},authoredValue:y,targetAuthoredId:b,targetSourceNodeId:I[0]?.sourceNodeId??null,resolution:I.length===0?"missing":I.length===1?"resolved":"ambiguous-first"});d.push(x);let k=u.get(g.sourceNodeId)??[];k.push(x),u.set(g.sourceNodeId,k)},f=(g,h,y,b)=>{for(let v of y.matchAll(uT))p(g,h,y,v[2],b)};for(let g of n){let h=Le(g);h?.value.startsWith("#")&&h.value.length>1&&p(g,h.namespace==="svg2"?"href":"xlink-href",h.value,h.value.slice(1),h.namespace==="svg2"?"href":"xlink:href"),g.localName.toLowerCase()==="style"&&f(g,"stylesheet-url",bT(g));for(let y of g.attributes)if(y.namespaceUri===null){if(y.localName==="style"?f(g,"inline-style-url",y.value,y.name):y.value.includes("url(")&&f(g,"presentation-url",y.value,y.name),y.localName==="begin"||y.localName==="end")for(let b of y.value.matchAll(pT))p(g,"smil-syncbase",y.value,b[1],y.name);if(fT.has(y.localName))for(let b of y.value.trim().split(/\s+/u).filter(Boolean))p(g,"idref-list",y.value,b,y.name)}}for(let g of c.values())Object.freeze(g);for(let g of u.values())Object.freeze(g);return Object.freeze(n),Object.freeze(l),Object.freeze(d),Object.freeze({elements:n,idOccurrences:l,localReferences:d,element(g){return r.get(g)??null},parent(g){return i.get(g)??null},children(g){return o.get(g)??Object.freeze([])},sourcePath(g){return s.get(g)??"/"},occurrences(g){return c.get(g)??Object.freeze([])},resolveAuthoredId(g){return c.get(g)?.[0]??null},referencesFrom(g){return u.get(g)??Object.freeze([])}})}function xT(t){let e=n=>{if(!(n===null||typeof n!="object"||Object.isFrozen(n))){for(let r of Object.values(n))e(r);Object.freeze(n)}};return e(t),t}function tn(t,e,n=Hf){let r=jf(t),i;try{i=n.parse(r)}catch(y){throw new Zi(n.id,`SVG XML parser host ${n.id} failed.`,y)}if(i===null||typeof i!="object"||!("error"in i)&&!("nodes"in i))throw new Zi(n.id,`SVG XML parser host ${n.id} returned no result.`);if("error"in i)return{value:null,diagnostics:[ob(e,"malformed-source",`SVG XML parsing failed: ${i.error}`)]};let o=i.nodes.find(y=>y.kind==="element"),s=o?.namespaceUri===K||o?.namespaceUri===null;if(!o||o.localName!=="svg"||!s)return{value:null,diagnostics:[ob(e,"missing-svg-root","The XML document element is not an SVG root in the SVG namespace.")]};let a=[],c=0,l=0,d=y=>{let b=c++,v=`source:${b}`;if(y.kind!=="element"){let T={kind:y.kind,sourceNodeId:v,documentOrder:b,value:y.value,span:y.span};return a.push(T),T}let I=l++,x=[],k={kind:"element",sourceNodeId:v,documentOrder:b,elementOrder:I,name:y.name,localName:y.localName,prefix:y.prefix,namespaceUri:y.namespaceUri,attributes:y.attributes.map(T=>({...T})),children:x,span:y.span,...y.rawXml!==void 0?{rawXml:y.rawXml}:{}};return a.push(k),x.push(...y.children.map(d)),k},u=null,p=i.nodes.map(y=>{let b=d(y);return y===o&&(u=b),b});if(!u)throw new Error("The validated SVG document element was not projected.");let f=vT(u,a),m=new Map;for(let y of f.idOccurrences){let b=m.get(y.authoredId)??[];b.push(y.sourceNodeId),m.set(y.authoredId,b)}let g=Object.freeze(Object.fromEntries([...m].map(([y,b])=>[y,Object.freeze(b)]))),h=[];o.namespaceUri===null&&h.push(Gf(e,"missing-svg-namespace","The namespace-less SVG root was accepted as compatibility input; authored SVG should declare the SVG namespace.",{documentPath:"/svg[1]",elementName:"svg"}));for(let[y,b]of m){let v=f.occurrences(y);if(v.length>1&&h.push(Gf(e,"duplicate-svg-id",`SVG id ${JSON.stringify(y)} occurs ${b.length} times; references resolve to the first element-order occurrence.`,{documentPath:v.map(I=>f.sourcePath(I.sourceNodeId)).join(", "),elementName:f.element(v[0].sourceNodeId)?.name??"svg",sourceId:y})),v.some(I=>!I.validXmlId)){let I=v.find(x=>!x.validXmlId);h.push(Gf(e,"invalid-svg-attribute",`SVG id ${JSON.stringify(y)} is not a non-empty XML Name without whitespace; it remains available for exact first-element reference processing.`,{documentPath:f.sourcePath(I.sourceNodeId),elementName:f.element(I.sourceNodeId)?.name??"svg",sourceId:y}))}}return{value:xT({root:u,documentNodes:p,nodes:a,idIndex:g,index:f,rawSource:t,parserSource:r}),diagnostics:h}}function C(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName===e)?.value??null}function mt(t,e){return t.attributes.some(n=>n.namespaceUri===null&&n.localName===e)}var xl="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",IT=new RegExp(`^\\s*(${xl})(?:\\s*,\\s*|\\s+)(${xl})(?:\\s*,\\s*|\\s+)(${xl})(?:\\s*,\\s*|\\s+)(${xl})\\s*$`);function nt(t){let e=IT.exec(t);if(!e)return null;let[n,r,i,o]=e.slice(1).map(Number);return[n,r,i,o].every(Number.isFinite)?{x:n,y:r,width:i,height:o}:null}function wT(t){return t==="none"||/^x(Min|Mid|Max)Y(Min|Mid|Max)$/.test(t)}function Ji(t){if(t==null)return{align:"xMidYMid",meetOrSlice:"meet"};let e=t.trim().split(/\s+/).filter(Boolean);return e.length<1||e.length>2||!wT(e[0])||e.length===2&&e[1]!=="meet"&&e[1]!=="slice"?{align:"xMidYMid",meetOrSlice:"meet"}:{align:e[0],meetOrSlice:e[1]==="slice"?"slice":"meet"}}function Wf(t,e){return t==="none"?0:e==="x"?t.includes("xMax")?1:t.includes("xMid")?.5:0:t.includes("YMax")?1:t.includes("YMid")?.5:0}function cb(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function lb(t,e,n,r){return t==null?e??null:!Number.isFinite(t)||t<0?(r.push({code:"invalid-viewport-length",message:`Nested SVG ${n} ${String(t)} is invalid and falls back to auto (100%).`}),e??null):t}function kT(t,e){return Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==void 0}function PT(t){let e=["viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight"],n=e.filter(i=>kT(t,i));return n.length===0?"absent":n.length!==e.length||!e.map(i=>t[i]).every(i=>typeof i=="number"&&Number.isFinite(i))?"partial":t.viewBoxWidth<0||t.viewBoxHeight<0?"negative-invalid":t.viewBoxWidth===0||t.viewBoxHeight===0?"zero-disabled":"valid"}function TT(t,e,n){let{align:r,meetOrSlice:i}=Ji(n),o=t.width/e.viewBoxWidth,s=t.height/e.viewBoxHeight,a=t.x-e.viewBoxX*o,c=t.y-e.viewBoxY*s;if(r!=="none"){let l=i==="slice"?Math.max(o,s):Math.min(o,s),d=e.viewBoxWidth*l,u=e.viewBoxHeight*l;o=l,s=l,a=t.x+(t.width-d)*Wf(r,"x")-e.viewBoxX*l,c=t.y+(t.height-u)*Wf(r,"y")-e.viewBoxY*l}return ft(o,0,0,s,a,c)}function Qi(t,e){let n=[],r=cb(t.x,0),i=cb(t.y,0),o=lb(t.width,e?.width,"width",n),s=lb(t.height,e?.height,"height",n),a=o===null||s===null?null:{x:r,y:i,width:o,height:s},c=PT(t);if((o===0||s===0)&&(c="zero-disabled"),c==="zero-disabled")return{status:c,renders:!1,frame:a,contentMatrix:null,childPercentBasis:null,diagnostics:n};if(c==="partial"?n.push({code:"invalid-viewbox",message:"Nested SVG viewBox is partial or non-finite and is ignored."}):c==="negative-invalid"&&n.push({code:"invalid-viewbox",message:"Nested SVG viewBox has a negative dimension and is ignored."}),c!=="valid")return{status:c,renders:!0,frame:a,contentMatrix:ft(1,0,0,1,r,i),childPercentBasis:a?{width:a.width,height:a.height}:null,diagnostics:n};if(!a)return n.push({code:"unresolved-viewport-size",message:"Nested SVG with a valid viewBox needs a parent viewport to resolve auto dimensions."}),{status:c,renders:!1,frame:null,contentMatrix:null,childPercentBasis:null,diagnostics:n};let l={viewBoxX:t.viewBoxX,viewBoxY:t.viewBoxY,viewBoxWidth:t.viewBoxWidth,viewBoxHeight:t.viewBoxHeight};return{status:c,renders:!0,frame:a,contentMatrix:TT(a,l,t.preserveAspectRatio),childPercentBasis:{width:l.viewBoxWidth,height:l.viewBoxHeight},diagnostics:n}}var RT=new Set(["animate","animatetransform","animatemotion","set"]),CT="http://www.w3.org/1999/xlink";function db(t,e){let n=C(t,"style");if(n){let r=n.replace(/\/\*[\s\S]*?\*\//g,""),i=new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]*)`,"gi"),o=null,s;for(;(s=i.exec(r))!==null;)o=s[1];if(o!==null){let a=o.replace(/\s*!\s*important\s*$/i,"").trim(),c=pt(a);if(c&&c.value>=0&&(c.unit!==""||c.value===0))return a}}return C(t,e)}function $T(t,e){return{severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,message:e,documentPath:"/svg[1]/@viewBox",elementName:"svg",capability:"root-viewport-frame"}}function ub(t){for(let e of t.children)if(e.kind==="element"&&(e.localName.toLowerCase()==="view"||ub(e)))return!0;return!1}function NT(t,e){let n=t.attributes.find(i=>i.localName==="href"&&(i.namespaceUri===null||i.namespaceUri===CT))?.value;if(n===void 0)return!0;let r=C(e,"id");return r!==null&&n===`#${r}`}function Il(t,e){let n=[],r=Ut(db(t,"width")),i=Ut(db(t,"height")),o=r!==void 0&&r>=0?r:void 0,s=i!==void 0&&i>=0?i:void 0,a=C(t,"preserveAspectRatio"),c=a&&a.trim().length>0?a.trim():void 0,l=mt(t,"viewBox"),d=C(t,"viewBox"),u=d!==null?nt(d):null,p=u!==null&&u.width>=0&&u.height>=0?u:null;l&&!p&&n.push($T(e,`Root SVG viewBox ${JSON.stringify(d)} is invalid per SVG 2 section 8.6 and was ignored.`));let f=t.children.some(v=>v.kind==="element"&&RT.has(v.localName.toLowerCase())&&NT(v,t)),m=p!==null||f||ub(t);if(p)return{value:{viewBoxX:p.x,viewBoxY:p.y,viewBoxWidth:p.width,viewBoxHeight:p.height,...o!==void 0?{width:o}:{},...s!==void 0?{height:s}:{},...c!==void 0?{preserveAspectRatio:c}:{},sizingMode:"explicit",targetedPasteWrapper:m},diagnostics:n};let g=o!==void 0,h=s!==void 0,y=g?o:300,b=h?s:150;return{value:{viewBoxX:0,viewBoxY:0,viewBoxWidth:y,viewBoxHeight:b,...g||h?{width:y,height:b}:{},...c!==void 0?{preserveAspectRatio:c}:{},sizingMode:g||h?"sized":"implicit",targetedPasteWrapper:m},diagnostics:n}}function AT(t){return t.localName.toLowerCase()==="view"&&(t.namespaceUri===K||t.namespaceUri===null)}function ET(t,e,n,r){let i=C(e,"id");return{severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`SVG viewBox ${JSON.stringify(r)} is invalid per SVG 2 section 8.6 and the view was ignored.`,documentPath:`${t.index.sourcePath(e.sourceNodeId)}/@viewBox`,elementName:"view",...i?{sourceId:i}:{},sourceNodeId:e.sourceNodeId,capability:"views"}}function MT(t){return Object.freeze(t.state),Object.freeze(t)}function wl(t,e){let n=[],r=[];for(let i of t.index.elements){if(!AT(i))continue;let o=C(i,"viewBox");if(o===null||o.trim().length===0)continue;let s=nt(o);if(!s||s.width<0||s.height<0){r.push(ET(t,i,e,o));continue}let a={viewName:C(i,"id")??"",viewBoxX:s.x,viewBoxY:s.y,viewBoxWidth:s.width,viewBoxHeight:s.height},c=C(i,"preserveAspectRatio");c&&(a.viewPreserveAspectRatio=c);let l=C(i,"zoomAndPan");(l==="disable"||l==="magnify")&&(a.viewZoomAndPan=l);let d=C(i,"viewTarget");d&&(a.viewTarget=d),n.push(MT({sourceNodeId:i.sourceNodeId,elementOrder:i.elementOrder,parentSourceNodeId:t.index.parent(i.sourceNodeId)?.sourceNodeId??null,state:a}))}return{value:Object.freeze(n),diagnostics:Object.freeze(r.map(i=>Object.freeze(i)))}}function fb(t){return t.localName.toLowerCase()==="svg"&&(t.namespaceUri===K||t.namespaceUri===null)}function mb(t,e){let n=C(t,"style");if(!n)return null;let r=null;for(let i of ai(n,";")){let[o,...s]=ai(i,":");if(o?.trim().toLowerCase()!==e.toLowerCase())continue;let a=s.join(":").trim(),c=/\s*!\s*important\s*$/iu.test(a),l=a.replace(/\s*!\s*important\s*$/iu,"").trim();(!r||c||!r.important)&&(r={value:l,important:c})}return r}function OT(t,e){let n=mb(t,e);if(n){if(n.value.toLowerCase()==="auto")return{kind:"auto"};let r=pt(n.value);if(r&&r.value>=0)return{kind:"value",value:n.value}}return mt(t,e)?{kind:"value",value:C(t,e)??""}:{kind:"absent"}}function DT(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){let r=Ut(mb(n,"font-size")?.value??null);if(r!==void 0)return r;let i=Ut(C(n,"font-size"));if(i!==void 0)return i;n=t.index.parent(n.sourceNodeId)}return 16}function gb(t,e,n,r,i){let o=C(e,"id");return{severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`Embedded SVG ${r} ${JSON.stringify(i)} is invalid and was ignored.`,documentPath:`${t.index.sourcePath(e.sourceNodeId)}/@${r}`,elementName:"svg",...o?{sourceId:o}:{},sourceNodeId:e.sourceNodeId,capability:"embedded-svg"}}function pb(t){let e=t.root,n=C(e,"viewBox"),r=n===null?null:nt(n);if(r&&r.width>=0&&r.height>=0)return{width:r.width,height:r.height};let i=a=>{let c=OT(e,a);return c.kind==="value"?Ut(c.value):void 0},o=i("width"),s=i("height");return{width:o!==void 0&&o>=0?o:300,height:s!==void 0&&s>=0?s:150}}function zT(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){if(fb(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function kl(t,e,n,r,i,o){if(!mt(e,n))return;let s=C(e,n)??"",a={percentBasis:n==="x"||n==="width"?r.width:r.height,viewportWidth:r.width,viewportHeight:r.height,fontSize:DT(t,e),rootFontSize:16},c=Pe(s,a),l=(n==="width"||n==="height")&&(c??0)<0;if(c===void 0||l){o.push(gb(t,e,i,n,s));return}return c}function Pl(t,e){let n=[],r=[],i=new Map([[t.root.sourceNodeId,pb(t)]]);for(let o of t.index.elements){if(!fb(o)||o.sourceNodeId===t.root.sourceNodeId)continue;let s=zT(t,o),a=(s&&i.get(s.sourceNodeId))??pb(t),c={},l=kl(t,o,"x",a,e,r),d=kl(t,o,"y",a,e,r),u=kl(t,o,"width",a,e,r),p=kl(t,o,"height",a,e,r);l!==void 0&&(c.svgX=l),d!==void 0&&(c.svgY=d),u!==void 0&&(c.svgWidth=u),p!==void 0&&(c.svgHeight=p);let f=C(o,"viewBox"),m=f===null?null:nt(f),g=m&&m.width>=0&&m.height>=0?m:null;f!==null&&!g&&r.push(gb(t,o,e,"viewBox",f)),g&&(c.svgViewBoxX=g.x,c.svgViewBoxY=g.y,c.svgViewBoxWidth=g.width,c.svgViewBoxHeight=g.height),mt(o,"preserveAspectRatio")&&(c.svgPreserveAspectRatio=C(o,"preserveAspectRatio")??"");let h=u??a.width,y=p??a.height;i.set(o.sourceNodeId,{width:g?.width??h,height:g?.height??y}),Object.freeze(c),n.push(Object.freeze({sourceNodeId:o.sourceNodeId,elementOrder:o.elementOrder,parentSourceNodeId:t.index.parent(o.sourceNodeId)?.sourceNodeId??null,state:c}))}return{value:Object.freeze(n),diagnostics:Object.freeze(r.map(o=>Object.freeze(o)))}}function _T(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function Kf(t,e){return _T(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function FT(t,e,n){if(n.namespaceUri!==K||e.role==="definition")return null;let r=n.localName.toLowerCase();return r==="g"?"group":r==="a"?"hyperlink":r==="switch"?"switch":r!=="svg"||e.usePath.length===0&&n.sourceNodeId===t.root.sourceNodeId?null:"embedded-svg"}function hb(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:i,source:r.source,entrypoint:r.entrypoint,capability:i==="empty-hyperlink-dropped"?"containers":"hierarchy",sourceId:C(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:o})}function Tl(t,e,n){let r=new Map(e.occurrences.map(h=>[h.occurrenceId,h])),i=new Map,o=new Map;for(let h of e.occurrences){let y=t.index.element(h.correspondingSourceNodeId);if(!y)throw new Error(`SVG occurrence ${h.occurrenceId} has no source element.`);i.set(h.occurrenceId,y);let b=FT(t,h,y);b&&o.set(h.occurrenceId,b)}let s=[],a=new Set;for(let h of n.materializedOccurrenceIds){if(a.has(h))continue;a.add(h);let y=r.get(h);if(!y)throw new Error(`Unknown materialized SVG occurrence ${h}.`);if(y.role==="definition")throw new Error(`Definition occurrence ${h} cannot be materialized in the scene.`);s.push(y)}s.sort(Kf);for(let h of s){let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);b.add(y);let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);v.role==="use-carrier"&&o.set(y,"group"),y=v.parentOccurrenceId}}let c=new Set;for(let h of s){let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);b.add(y);let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);o.has(y)&&c.add(y),y=v.parentOccurrenceId}}let l=[],d=new Set,u=[...c].map(h=>r.get(h)).sort(Kf),p=h=>{let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))return!1;b.add(y);let v=r.get(y);if(!v)return!1;if(o.get(y)==="hyperlink")return!0;y=v.parentOccurrenceId}return!1};for(let h of u){if(o.get(h.occurrenceId)==="hyperlink"&&p(h)){let b=i.get(h.occurrenceId);l.push(hb(t,h,b,n,"nested-hyperlink-flattened","Nested SVG hyperlinks are invalid; the inner hyperlink was flattened."));continue}d.add(h.occurrenceId)}for(let h of e.occurrences){if(o.get(h.occurrenceId)!=="hyperlink"||c.has(h.occurrenceId)||p(h))continue;let y=i.get(h.occurrenceId);l.push(hb(t,h,y,n,"empty-hyperlink-dropped","The SVG hyperlink has no materializable content and was dropped."))}let f=h=>{let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);if(b.add(y),d.has(y))return y;let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);y=v.parentOccurrenceId}return null},m=u.filter(h=>d.has(h.occurrenceId)).map(h=>Object.freeze({occurrenceId:h.occurrenceId,sourceNodeId:h.correspondingSourceNodeId,kind:o.get(h.occurrenceId),parentContainerOccurrenceId:f(h),orderKey:Object.freeze([...h.orderKey])})),g=s.map(h=>Object.freeze({occurrenceId:h.occurrenceId,sourceNodeId:h.correspondingSourceNodeId,parentContainerOccurrenceId:f(h),orderKey:Object.freeze([...h.orderKey])}));return l.sort((h,y)=>{let b=h.occurrenceId?r.get(h.occurrenceId):void 0,v=y.occurrenceId?r.get(y.occurrenceId):void 0;return!b||!v?0:Kf(b,v)}),Object.freeze({value:Object.freeze({containers:Object.freeze(m),placements:Object.freeze(g)}),diagnostics:Object.freeze(l)})}var Yf="http://www.w3.org/1999/xhtml",qf="http://www.w3.org/1998/Math/MathML",Sb=Object.freeze([Yf,qf]),Rl=Object.freeze(["systemLanguage","requiredExtensions","requiredFeatures"]),LT=/[\t\n\f\r ]+/,BT=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function Xf(t,e){return C(t,e)}function GT(t){if(t.namespaceUri!==K)return null;let e=Xf(t,"systemLanguage"),n=Xf(t,"requiredExtensions"),r=Xf(t,"requiredFeatures");return e===null&&n===null&&r===null?null:Object.freeze({sourceNodeId:t.sourceNodeId,elementName:t.localName,systemLanguage:e,requiredExtensions:n,requiredFeatures:r})}function VT(t,e,n){return Object.freeze({severity:"warning",code:"required-features-dropped",source:n.source,entrypoint:n.entrypoint,capability:"conditional-processing",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:"Dropped requiredFeatures because SVG 2 removed the feature test."})}function Cl(t,e){let n=[],r=[];for(let a of t.index.elements){let c=GT(a);c&&(n.push(c),c.requiredFeatures!==null&&r.push(VT(t,a,e)))}let i=Object.freeze(n),o=new Map(i.map(a=>[a.sourceNodeId,a])),s=Object.freeze({candidates:i,condition:a=>o.get(a)??null});return Object.freeze({value:s,diagnostics:Object.freeze(r)})}function yb(t){let e=t.replace(BT,"");if(e.length===0)return null;try{return new Intl.Locale(e).toString().toLowerCase()}catch{return null}}function bb(t,e){if(t.requiredExtensions!==null){let i=t.requiredExtensions.split(LT).filter(Boolean);if(i.length===0||!i.every(o=>e.supportedExtensions.has(o)))return!1}if(t.systemLanguage===null)return!0;let n=t.systemLanguage.split(",").map(yb).filter(i=>i!==null);return n.length===0?!1:e.preferredLanguages.map(yb).filter(i=>i!==null).some(i=>n.some(o=>o===i||o.startsWith(`${i}-`)))}var jT=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol","view"]),UT=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol"]),HT=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu;function vb(t){let e=t.trim();return/^-?[_A-Za-z][\w:.-]*$/u.test(e)?e:e.replace(/[^\w:.-]+/gu,"_").replace(/^[^_A-Za-z]+/u,"")||"svg-resource"}function WT(t,e){let n=1;for(;e.has(`${t}-${n}`);)n++;let r=`${t}-${n}`;return e.add(r),r}function Zf(t,e,n){let r=t.trim(),i=r.length>0?vb(r):vb(e);return t===i&&!n.has(i)||!n.has(i)?(n.add(i),i):WT(i,n)}function xb(t,e){return t.replace(HT,(n,r,i)=>{let o=e.get(i);return!o||o===i?n:`url(${r}#${o}${r})`})}function KT(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function Ib(t,e){switch(t.localName.toLowerCase()){case"clippath":return"clipPath";case"mask":return"mask";case"lineargradient":return"linearGradient";case"radialgradient":return"radialGradient";case"pattern":return"pattern";case"filter":return"filter";case"marker":return"marker";case"symbol":return"symbol";case"view":return"view";default:return e?"hrefTarget":"other"}}function XT(t){for(let e of t.elementIds)Object.freeze(e);for(let e of t.resourceIds)Object.freeze(e);for(let e of t.generatedIds)Object.freeze(e);for(let e of t.rewrites)Object.freeze(e);return Object.freeze(t.elementOrder),Object.freeze(t.elementIds),Object.freeze(t.resourceIds),Object.freeze(t.generatedIds),Object.freeze(t.rewrites),Object.freeze(t)}function $l(t,e={}){let n=t.index.elements,r=h=>{let y=t.index.parent(h.sourceNodeId);for(;y;){if(y.localName.toLowerCase()==="defs")return!0;y=t.index.parent(y.sourceNodeId)}return!1},i=new Set;for(let h of n)C(h,"id")!==null&&(jT.has(h.localName.toLowerCase())||r(h))&&i.add(h.sourceNodeId);for(let h of t.index.localReferences)h.channel!=="href"&&h.channel!=="xlink-href"||h.targetSourceNodeId&&i.add(h.targetSourceNodeId);let o=new Set(e.claimedIds??[]),s=new Map,a=new Map,c=[];for(let h of n){let y=C(h,"id");if(y===null)continue;let b=Ib(h,r(h)),v=Zf(y,b,o);s.has(y)||s.set(y,v),a.set(h.sourceNodeId,v),c.push({sourceNodeId:h.sourceNodeId,authoredId:y,liveId:v})}let l=[];for(let h of n){if(!i.has(h.sourceNodeId))continue;let y=C(h,"id");if(y===null)continue;let b=Ib(h,r(h)),v=a.get(h.sourceNodeId);v&&l.push({sourceNodeId:h.sourceNodeId,authoredId:y,sourceId:y.length>0?y:v,liveId:v,kind:b,restoreSourceId:v!==y&&UT.has(h.localName.toLowerCase())})}let d=[],u=new Set,p=0;for(let h of n){if(h.namespaceUri!=="http://www.w3.org/2000/svg")continue;let y=h.localName.toLowerCase();if(!["animate","animatemotion","animatetransform","discard","set"].includes(y)||Le(h))continue;let b=t.index.parent(h.sourceNodeId);if(!b||u.has(b.sourceNodeId))continue;let v=b,I=!1;for(;v;){if(v.namespaceUri==="http://www.w3.org/2000/svg"&&["clippath","mask"].includes(v.localName.toLowerCase())){I=!0;break}v=t.index.parent(v.sourceNodeId)}if(!I||C(b,"id"))continue;let k=`svgsketch-smil-target-${p++}`,T=Zf(k,"other",o);u.add(b.sourceNodeId),d.push({sourceNodeId:b.sourceNodeId,liveId:T,reason:"clip-mask-animation-target"})}let f=0,m=new Set(e.cssAnimationTargetSourceNodeIds??[]);for(let h of n){if(!m.has(h.sourceNodeId)||u.has(h.sourceNodeId)||C(h,"id"))continue;let y=`svgsketch-css-animation-target-${f++}`,b=Zf(y,"other",o);u.add(h.sourceNodeId),d.push({sourceNodeId:h.sourceNodeId,liveId:b,reason:"clip-mask-css-animation-target"})}let g=[];for(let h of n){if(h.localName.toLowerCase()==="style"){let b=KT(h),v=xb(b,s);v!==b&&g.push({sourceNodeId:h.sourceNodeId,target:"text-content",value:v})}let y=Le(h);for(let b of h.attributes){if(b.localName==="id"&&b.namespaceUri===null||b.name==="data-source-id")continue;let v=b.value;if((y?.namespace==="svg2"?b.localName==="href"&&b.namespaceUri===null:y?.namespace==="xlink"?b.localName==="href"&&b.namespaceUri!==null:!1)&&v.startsWith("#")){let x=s.get(v.slice(1));x&&x!==v.slice(1)&&(v=`#${x}`)}else b.namespaceUri===null&&v.includes("url(")&&(v=xb(v,s));v!==b.value&&g.push({sourceNodeId:h.sourceNodeId,target:"attribute",name:b.name,value:v})}}return XT({elementOrder:n.map(h=>h.sourceNodeId),elementIds:c,resourceIds:l,generatedIds:d,rewrites:g,liveIdForSourceId(h){return s.get(h)},liveIdForSourceNodeId(h){return a.get(h)}})}var Be=t=>({authority:"core",by:t}),Jf={geometry:Be("ingest/svg-leaf-geometry.ts"),containers:Be("ingest/svg-container-hierarchy.ts"),"source-order":Be("ingest/svg-source.ts and ingest/svg-use-occurrences.ts"),hierarchy:Be("ingest/svg-container-hierarchy.ts"),"root-viewport-frame":Be("ingest/root-frame.ts"),"common-presentation":Be("ingest/svg-style-cascade.ts and svg-property-semantics.ts"),"conditional-processing":Be("ingest/svg-conditional-processing.ts"),"authored-attributes":Be("ingest/svg-authored-attributes.ts"),gradients:Be("ingest/svg-gradients.ts"),patterns:Be("ingest/svg-patterns.ts"),filters:Be("ingest/svg-filters.ts"),"paint-server-definitions":Be("ingest/svg-paint-server-definitions.ts"),markers:Be("ingest/svg-markers.ts"),symbols:Be("ingest/svg-symbol-uses.ts"),"use-and-linked-references":Be("ingest/svg-use-occurrences.ts and ingest/svg-symbol-uses.ts"),"clip-definitions":Be("ingest/svg-clip-masks.ts"),"mask-definitions":Be("ingest/svg-clip-masks.ts"),"clip-mask-membership":Be("ingest/svg-clip-masks.ts"),"smil-animation":Be("ingest/svg-animations.ts and smil-value-syntax.ts"),"css-animation":Be("ingest/svg-animations.ts and css-animation-syntax.ts"),metadata:Be("ingest/svg-metadata.ts"),scripts:Be("ingest/svg-scripts.ts"),styles:Be("ingest/svg-style-cascade.ts"),"custom-properties":Be("ingest/svg-style-cascade.ts custom-property environments"),views:Be("ingest/svg-views.ts"),"embedded-svg":Be("ingest/svg-embedded-frames.ts"),fonts:Be("ingest/svg-external-effects.ts"),"external-assets":Be("ingest/svg-external-effects.ts")};function wb(t=Ds,e=Jf){if(t.length===0)throw new Error("SVG import capability roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("SVG import capability roster contains duplicate features.");let n=new Set(t);for(let r of t){let i=e[r];if(!i)throw new Error(`${r} lacks an SVG import parser owner.`);if(i.authority!=="core")throw new Error(`${r} retains noncanonical editor parser authority.`);if(i.by.trim().length<8)throw new Error(`${r} lacks a substantive SVG import parser owner.`)}for(let r of Object.keys(e))if(!n.has(r))throw new Error(`Unknown SVG import capability ${r}.`)}var YT=64,qT=1e5,Nl="http://www.w3.org/2000/svg",ZT=new Set(["circle","ellipse","line","path","polygon","polyline","rect","text"]);function kb(t,e){return t===void 0||!Number.isFinite(t)?e:Math.max(1,Math.floor(t))}var Qf=new Set(["defs","clippath","mask","marker","pattern","lineargradient","radialgradient","filter","symbol"]);function JT(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function QT(t,e){return JT(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function Pb(t,e,n){let r=e.map(i=>i.sourceReferenceId).join("/");return`occurrence:${r?`${r}/`:""}${t}:${n}`}function eR(t,e){let n=Le(e);if(!n?.value.startsWith("#")||n.value.length<=1)return null;let r=n.namespace==="svg2"?"href":"xlink-href";return t.index.referencesFrom(e.sourceNodeId).find(i=>i.channel===r&&i.authoredValue===n.value)??null}function tR(t,e){let n=Le(e);if(!n||n.value.length===0||n.value==="#")return Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:null,targetSourceNodeId:null,status:"empty"});if(!n.value.startsWith("#"))return Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:null,targetSourceNodeId:null,status:"external"});let r=eR(t,e),i=r?.targetSourceNodeId?t.index.element(r.targetSourceNodeId):null;return!r||!i?Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r?.sourceReferenceId??null,targetSourceNodeId:null,status:"missing"}):i.namespaceUri!==Nl?Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r.sourceReferenceId,targetSourceNodeId:i.sourceNodeId,status:"invalid"}):Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r.sourceReferenceId,targetSourceNodeId:i.sourceNodeId,status:"resolved"})}function nR(t,e){let n=e;for(;n&&n!==t.root;){if(Qf.has(n.localName.toLowerCase()))return!0;n=t.index.parent(n.sourceNodeId)}return!1}function eo(t){return t.namespaceUri===Nl&&t.localName.toLowerCase()==="use"}function rR(t,e){let n=new Map;for(let v of t.index.idOccurrences){let I=t.index.element(v.sourceNodeId);I&&n.set(I.sourceNodeId,I)}let r=new Map;for(let v of n.keys())r.set(v,new Set);for(let v of t.index.elements){if(v.namespaceUri!==Nl||v.localName.toLowerCase()!=="use")continue;let I=e.get(v.sourceNodeId);if(I?.status!=="resolved"||!I.targetSourceNodeId||!n.has(I.targetSourceNodeId))continue;let x=v;for(;x;)n.has(x.sourceNodeId)&&r.get(x.sourceNodeId)?.add(I.targetSourceNodeId),x=t.index.parent(x.sourceNodeId)}let i=(v,I)=>(n.get(v)?.elementOrder??0)-(n.get(I)?.elementOrder??0),o=[...n.keys()].sort(i),s=new Map(o.map(v=>[v,[...r.get(v)??[]].sort(i)])),a=new Map(o.map(v=>[v,[]]));for(let[v,I]of s)for(let x of I)a.get(x)?.push(v);for(let v of a.values())v.sort(i);let c=[],l=new Set;for(let v of o){if(l.has(v))continue;l.add(v);let I=[{sourceNodeId:v,targetIndex:0}];for(;I.length>0;){let x=I[I.length-1],T=(s.get(x.sourceNodeId)??[])[x.targetIndex];if(T!==void 0){x.targetIndex++,l.has(T)||(l.add(T),I.push({sourceNodeId:T,targetIndex:0}));continue}c.push(x.sourceNodeId),I.pop()}}let d=[],u=new Set;for(let v=c.length-1;v>=0;v--){let I=c[v];if(u.has(I))continue;let x=[],k=[I];for(u.add(I);k.length>0;){let T=k.pop();x.push(T);let w=a.get(T)??[];for(let P=w.length-1;P>=0;P--){let N=w[P];u.has(N)||(u.add(N),k.push(N))}}x.sort(i),d.push(x)}let p=new Map;d.forEach((v,I)=>{v.forEach(x=>p.set(x,I))});let f=d.map(()=>new Set);for(let[v,I]of r){let x=p.get(v);for(let k of I){let T=p.get(k);x!==T&&f[x].add(T)}}let m=d.map(v=>n.get(v[0])?.elementOrder??Number.MAX_SAFE_INTEGER),g=(v,I)=>m[v]-m[I],h=d.map((v,I)=>I).sort(g),y=[],b=new Set;for(let v of h){if(b.has(v))continue;b.add(v);let I=[{componentIndex:v,dependencyIndex:0,dependencies:[...f[v]].sort(g)}];for(;I.length>0;){let x=I[I.length-1],k=x.dependencies[x.dependencyIndex];if(k!==void 0){x.dependencyIndex++,b.has(k)||(b.add(k),I.push({componentIndex:k,dependencyIndex:0,dependencies:[...f[k]].sort(g)}));continue}y.push(x.componentIndex),I.pop()}}return y.map(v=>{let I=d[v],x=I.length>1||(r.get(I[0])?.has(I[0])??!1);return Object.freeze({componentId:`definition-component:${I[0]}`,memberSourceNodeIds:Object.freeze([...I]),circular:x})})}function to(t,e,n,r,i){return Object.freeze({severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,capability:"use-and-linked-references",sourceId:C(r,"id")??void 0,sourceNodeId:r.sourceNodeId,occurrenceId:i,elementName:r.name,message:n})}function Al(t,e){let n=kb(e.maxDepth,YT),r=kb(e.maxOccurrences,qT),i=t.index.elements.filter(w=>w.namespaceUri===Nl&&w.localName.toLowerCase()==="use").map(w=>tR(t,w)),o=new Map(i.map(w=>[w.useSourceNodeId,w])),s=[],a=new Map,c=new Map,l=[],d=[],u=[],p=new Map,f=new Set;for(let w of e.resourceRoots??[]){let P=`${w.capability}\0${w.sourceNodeId}`;if(f.has(P))continue;f.add(P);let N=t.index.element(w.sourceNodeId),R=[];if(N&&w.capability==="clip-path")for(let A of t.index.children(N.sourceNodeId)){if(!eo(A))continue;let O=o.get(A.sourceNodeId),G=O?.targetSourceNodeId?t.index.element(O.targetSourceNodeId):null;(O?.status!=="resolved"||!G||!ZT.has(G.localName.toLowerCase()))&&(R.push(A.sourceNodeId),d.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:e.source,entrypoint:e.entrypoint,capability:"clip-definitions",sourceId:C(N,"id")??void 0,sourceNodeId:A.sourceNodeId,elementName:A.name,documentPath:t.index.sourcePath(A.sourceNodeId),message:"A clipPath child use must directly reference a path, text, or basic shape. The clipPath is ignored."})))}let $=Object.freeze({resourceRootSourceNodeId:w.sourceNodeId,capability:w.capability,status:R.length===0?"valid":"invalid",invalidUseSourceNodeIds:Object.freeze(R)});u.push($),p.has(w.sourceNodeId)||p.set(w.sourceNodeId,$)}let m=new Set,g=0,h=!1,y=(w,P,N,R,$)=>{let A=Pb(w.sourceNodeId,P,0),O=a.get(A);if(O)return O;let G=Object.freeze({occurrenceId:A,correspondingSourceNodeId:w.sourceNodeId,usePath:Object.freeze(P.map(M=>Object.freeze({...M}))),role:$,parentOccurrenceId:N,orderKey:Object.freeze([...R]),productIndex:0});return s.push(G),a.set(A,G),P.length===0?c.set(w.sourceNodeId,G):g++,G};for(let w of t.index.elements){let P=t.index.parent(w.sourceNodeId),N=P?Pb(P.sourceNodeId,[],0):null,R=eo(w)?"use-carrier":nR(t,w)?"definition":"source";y(w,[],N,[w.elementOrder],R)}let b=(w,P)=>{h||(h=!0,d.push(to(e,"use-expansion-limit-exceeded",`SVG use expansion exceeded depth ${n} or ${r} shadow occurrences.`,w,P.occurrenceId)))},v=(w,P,N)=>{if(m.has(P.occurrenceId))return;m.add(P.occurrenceId);let R=Le(w),$=o.get(w.sourceNodeId);if(!$||$.status==="empty"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"empty"}),d.push(to(e,"unresolved-reference","The SVG use element has no local target.",w,P.occurrenceId));return}if($.status==="external"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"external"}),d.push(to(e,"unresolved-reference",`External SVG use target "${R?.value??""}" is not materialized by local import.`,w,P.occurrenceId));return}if($.status==="missing"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"missing"}),d.push(to(e,"unresolved-reference",`SVG use target "${R?.value??""}" does not exist.`,w,P.occurrenceId));return}if($.status==="invalid"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:$.targetSourceNodeId,status:"invalid"}),d.push(to(e,"unresolved-reference",`SVG use target "${R?.value??""}" is outside the SVG namespace.`,w,P.occurrenceId));return}let A=$.targetSourceNodeId?t.index.element($.targetSourceNodeId):null;if(!A||!$.sourceReferenceId)return;let O={sourceReferenceId:$.sourceReferenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId},G=[...P.usePath,O];if(N.has(A.sourceNodeId)){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"circular"}),d.push(to(e,"circular-use-reference",`SVG use target "${R?.value??""}" closes a circular shadow-tree reference.`,w,P.occurrenceId));return}if(G.length>n||g>=r){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"limit"}),b(w,P);return}let M={useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"resolved"};l.push(M);let V=()=>{M.status="limit",b(w,P)},X=new Set(N),Y=(U,te,Z)=>{if(g>=r){V();return}X.add(U.sourceNodeId);let ne=eo(U)?"use-carrier":"shadow-instance",F=y(U,G,te,Z,ne);if(eo(U))v(U,F,X);else if(!Qf.has(U.localName.toLowerCase())||U.localName.toLowerCase()==="symbol"){for(let j of t.index.children(U.sourceNodeId))if(Y(j,F.occurrenceId,[...Z,j.elementOrder]),g>=r){V();break}}X.delete(U.sourceNodeId)};Y(A,P.occurrenceId,[...P.orderKey,A.elementOrder])},I=(w,P)=>{if(Qf.has(w.localName.toLowerCase()))return;let N=new Set(P);N.add(w.sourceNodeId);let R=c.get(w.sourceNodeId);if(eo(w)){v(w,R,P);return}for(let $ of t.index.children(w.sourceNodeId))I($,N)};I(t.root,new Set);let x=(w,P)=>{let N=new Set(P);N.add(w.sourceNodeId);let R=c.get(w.sourceNodeId);if(eo(w)){v(w,R,P);return}for(let $ of t.index.children(w.sourceNodeId))x($,N)};for(let w of e.resourceRoots??[]){if(p.get(w.sourceNodeId)?.status==="invalid")continue;let N=t.index.element(w.sourceNodeId);if(!N)continue;let R=new Set,$=t.index.parent(N.sourceNodeId);for(;$;)R.add($.sourceNodeId),$=t.index.parent($.sourceNodeId);x(N,R)}s.sort(QT);let k=l.map(w=>Object.freeze({...w})),T=rR(t,o);return Object.freeze(i),Object.freeze(s),Object.freeze(k),Object.freeze(T),Object.freeze(u),Object.freeze(d),Object.freeze({occurrences:s,sourceResolutions:i,resolutions:k,definitionComponents:T,resourcePolicies:u,diagnostics:d,occurrence(w){return a.get(w)??null},direct(w){return c.get(w)??null},sourceResolution(w){return o.get(w)??null},resourcePolicy(w){return p.get(w)??null}})}var q="all-svg-elements",Tb=[["alignment-baseline",!1,"auto",q],["baseline-shift",!1,"0",q],["clip",!1,"auto",q],["clip-path",!1,"none",q],["clip-rule",!0,"nonzero",q],["color",!0,"black",q],["color-interpolation",!0,"sRGB",q],["color-interpolation-filters",!0,"linearRGB",q],["color-rendering",!0,"auto",q],["cursor",!0,"auto",q],["direction",!0,"ltr",q],["display",!1,"inline",q],["dominant-baseline",!0,"auto",q],["fill",!0,"black",q],["fill-opacity",!0,"1",q],["fill-rule",!0,"nonzero",q],["filter",!1,"none",q],["flood-color",!1,"black",q],["flood-opacity",!1,"1",q],["font-family",!0,"serif",q],["font-feature-settings",!0,"normal",q],["font-kerning",!0,"auto",q],["font-size",!0,"medium",q],["font-size-adjust",!0,"none",q],["font-stretch",!0,"normal",q],["font-style",!0,"normal",q],["font-variant",!0,"normal",q],["font-variant-caps",!0,"normal",q],["font-variant-east-asian",!0,"normal",q],["font-variant-ligatures",!0,"normal",q],["font-variant-numeric",!0,"normal",q],["font-variant-position",!0,"normal",q],["font-weight",!0,"normal",q],["image-rendering",!0,"auto",q],["letter-spacing",!0,"normal",q],["lighting-color",!1,"white",q],["line-height",!0,"normal",q],["marker-end",!0,"none",q],["marker-mid",!0,"none",q],["marker-start",!0,"none",q],["mask",!1,"none",q],["mask-image",!1,"none",q],["opacity",!1,"1",q],["overflow",!1,"visible",q],["paint-order",!0,"normal",q],["pointer-events",!0,"auto",q],["shape-rendering",!0,"auto",q],["stop-color",!1,"black",q],["stop-opacity",!1,"1",q],["stroke",!0,"none",q],["stroke-dasharray",!0,"none",q],["stroke-dashoffset",!0,"0",q],["stroke-linecap",!0,"butt",q],["stroke-linejoin",!0,"miter",q],["stroke-miterlimit",!0,"4",q],["stroke-opacity",!0,"1",q],["stroke-width",!0,"1px",q],["text-anchor",!0,"start",q],["text-decoration",!1,"none",q],["text-rendering",!0,"auto",q],["text-transform",!0,"none","none"],["transform",!1,"none",q],["transform-box",!1,"view-box","none"],["transform-origin",!1,"50% 50%",q],["unicode-bidi",!1,"normal",q],["vector-effect",!1,"none",q],["visibility",!0,"visible",q],["word-spacing",!0,"normal",q],["writing-mode",!0,"horizontal-tb",q]],iR=new Map(Tb.map(([t,e,n,r="none"])=>[t,Object.freeze({name:t,inherited:e,initialValue:n,presentationAttribute:r})])),js=Object.freeze(Tb.filter(t=>(t[3]??"none")!=="none").map(t=>t[0]));function $r(t){return iR.get(t.toLowerCase())??null}function El(t){return($r(t)?.presentationAttribute??"none")!=="none"}var em=new Set(["circle","ellipse","image","line","path","polygon","polyline","rect","text"]),oR=new Set([...em,"a","g","use"]),sR=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),aR=new Set(["clippath","filter","marker","mask","pattern"]),cR=new Set(["defs"]),Rb=new Set([...sR,"flowregion"]),lR=new Set(["class","clip-path","color","display","fill","fill-opacity","fill-rule","filter","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","visibility"]),dR=new Set(["data-shape-id","height","href","id","style","transform","width","x","xlink:href","xmlns","xmlns:xlink","y"]),uR=["animation","transition","-moz-animation","-moz-transition","-o-animation","-o-transition","-webkit-animation","-webkit-transition"],pR=new Set(["height","id","preserveaspectratio","refx","refy","viewbox","width","x","y"]);function Nr(t){return t.localName.toLowerCase()}function $b(t,e){let n=[],r=new Set,i=t.index.parent(e.sourceNodeId);for(;i&&!r.has(i.sourceNodeId);)r.add(i.sourceNodeId),n.push(i),i=t.index.parent(i.sourceNodeId);return n}function Ol(t,e,n){return $b(t,e).some(r=>n.has(Nr(r)))}function fR(t,e){let n=Nr(e);return n==="symbol"?!0:Ol(t,e,cR)?n==="g"||n==="use"||em.has(n):!1}function Cb(t){let e=t.toLowerCase();return uR.some(n=>e===n||e.startsWith(`${n}-`))}function mR(t){let e={};for(let n of["x","y","width","height"])mt(t,n)&&(e[n]=C(t,n)??"");return Object.keys(e).length===0?null:Object.freeze(e)}function gR(t,e,n,r){let i=e;for(;i&&Nr(i)!=="svg";)i=t.index.parent(i.sourceNodeId);let o=i?nt(C(i,"viewBox")??""):null,s=i?Pe(C(i,"width"),{}):void 0,a=i?Pe(C(i,"height"),{}):void 0,c=o?.width??s,l=o?.height??a,d=Pe(n.value(r,"font-size"),{viewportWidth:c,viewportHeight:l,percentBasis:16,fontSize:16,rootFontSize:16});return{viewportWidth:c,viewportHeight:l,fontSize:d??16,rootFontSize:16}}function hR(t,e){for(let n of $b(t,e))switch(Nr(n)){case"pattern":return C(n,"patternContentUnits")==="objectBoundingBox";case"clippath":return C(n,"clipPathUnits")==="objectBoundingBox";case"mask":return C(n,"maskContentUnits")==="objectBoundingBox";default:break}return!1}function Ml(t,e){if(t===null||t.trim()===""||t.trim().toLowerCase()==="auto")return e;let n=pt(t);return n?n.unit==="%"?n.value/100:n.unit===""?n.value:e:e}function yR(t,e,n,r){let i=hR(t,e),o=gR(t,e,r,n),s=C(e,"x"),a=C(e,"y"),c=i?Ml(s,0):Pe(s,{...o,percentBasis:o.viewportWidth})??0,l=i?Ml(a,0):Pe(a,{...o,percentBasis:o.viewportHeight})??0,d=C(e,"width"),u=C(e,"height"),p=d===null||d.trim()===""||d.trim().toLowerCase()==="auto"?null:i?Ml(d,0):Pe(d,{...o,percentBasis:o.viewportWidth})??null,f=u===null||u.trim()===""||u.trim().toLowerCase()==="auto"?null:i?Ml(u,0):Pe(u,{...o,percentBasis:o.viewportHeight})??null;return Object.freeze({authored:mR(e),x:c,y:l,width:p,height:f})}function SR(t,e,n){let r=C(t,"transform"),i=n.style(e)?.cascadedValues.transform?.value??null,o=r??i;if(o===null||o.trim()===""||o.trim().toLowerCase()==="none")return Object.freeze({authored:o,matrix:ft(1,0,0,1,0,0),valid:!0,pureTranslation:!0});let s=Zt(o),a=s!==null&&Math.abs(s[0]-1)<1e-6&&Math.abs(s[1])<1e-6&&Math.abs(s[2])<1e-6&&Math.abs(s[3]-1)<1e-6;return Object.freeze({authored:o,matrix:s,valid:s!==null,pureTranslation:a})}function bR(t,e,n){let r={};for(let s of t.attributes){let a=s.name;dR.has(a)||s.value===""||Cb(a)||(r[a]=s.value)}let i=n.style(e.occurrenceId);for(let[s,a]of Object.entries(i?.cascadedValues??{}))s==="transform"||Cb(s)||(r[s]=a.value);let o=e.parentOccurrenceId?n.style(e.parentOccurrenceId):null;for(let[s,a]of Object.entries(i?.resolvedValues??{})){if(r[s]!==void 0||!$r(s)?.inherited||o?.resolvedValues[s]!==a)continue;o.cascadedValues[s]&&(r[s]=a)}return Object.freeze(r)}function vR(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&pR.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function xR(t){let e=vR(t),n=Nr(t);return n==="g"||n==="symbol"?e:e.transform===void 0?Object.freeze({}):Object.freeze({transform:e.transform})}function IR(t,e){return t.find(n=>n.memberSourceNodeIds.includes(e))??null}function wR(t,e,n,r,i,o){let s=i.get(`${n.occurrenceId}\0${r.sourceNodeId}`);if(!s)return null;let a=IR(e.definitionComponents,r.sourceNodeId),c=o(s.occurrenceId),l=C(r,"viewBox");return Object.freeze({sourceNodeId:r.sourceNodeId,sourceId:C(r,"id"),defKind:Nr(r)==="symbol"?"symbol":em.has(Nr(r))?"shape":"group",productKey:`symbol-product:${r.sourceNodeId}:${n.occurrenceId}`,productUseOccurrenceId:n.occurrenceId,productRootOccurrenceId:s.occurrenceId,contentOccurrenceIds:Object.freeze(c),componentId:a?.componentId??null,circular:a?.circular??!1,viewBox:l,parsedViewBox:l===null?null:nt(l),preserveAspectRatio:C(r,"preserveAspectRatio"),x:C(r,"x"),y:C(r,"y"),width:C(r,"width"),height:C(r,"height"),refX:C(r,"refX"),refY:C(r,"refY"),rootAttributes:xR(r)})}function kR(t,e,n,r,i,o){if(r.usePath.length!==0||!i.valid||!oR.has(Nr(n))||Ol(t,e,Rb)||Ol(t,n,Rb))return!1;for(let s of lR)if(mt(e,s)||o.style(r.occurrenceId)?.cascadedValues[s])return!1;return!0}function Dl(t,e,n,r){let i=new Map,o=new Map;for(let f of e.occurrences){if(!f.parentOccurrenceId)continue;let m=`${f.parentOccurrenceId}\0${f.correspondingSourceNodeId}`;i.has(m)||i.set(m,f);let g=o.get(f.parentOccurrenceId)??[];g.push(f),o.set(f.parentOccurrenceId,g)}let s=new Map,a=f=>{let m=s.get(f);if(m)return m;let g=[],h=[...o.get(f)??[]].reverse(),y=new Set;for(;h.length>0;){let v=h.pop();if(y.has(v.occurrenceId))continue;y.add(v.occurrenceId),g.push(v.occurrenceId);let I=o.get(v.occurrenceId)??[];for(let x=I.length-1;x>=0;x--)h.push(I[x])}let b=Object.freeze(g);return s.set(f,b),b},c=[],l=[],d=new Map,u=new Map;for(let f of e.resolutions){let m=e.occurrence(f.useOccurrenceId),g=t.index.element(f.useSourceNodeId);if(!m||!g||g.namespaceUri!==K)continue;let h=f.targetSourceNodeId?t.index.element(f.targetSourceNodeId):null,y=yR(t,g,m.occurrenceId,n),b=SR(g,m.occurrenceId,n),v=bR(g,m,n),I=f.status==="resolved"?"flattened":f.status,x=null;if(f.status==="resolved"&&h){let T=Ol(t,g,aR);if(fR(t,h)){let w=wR(t,e,m,h,i,a);w&&(c.push(w),d.set(w.productKey,w),T||(x=w.productKey,I="symbol-instance"))}else!T&&kR(t,g,h,m,b,n)&&(I="linked-reference")}let k=Object.freeze({useOccurrenceId:m.occurrenceId,useSourceNodeId:g.sourceNodeId,targetSourceNodeId:h?.sourceNodeId??null,targetElementName:h?.name??null,status:I,definitionProductKey:x,geometry:y,presentation:v,transform:b,orderKey:Object.freeze([...m.orderKey])});l.push(k),u.set(k.useOccurrenceId,k)}Object.freeze(c),Object.freeze(l);let p=Object.freeze([]);return Object.freeze({definitions:c,uses:l,diagnostics:p,definition(f){return d.get(f)??null},use(f){return u.get(f)??null}})}var PR=new Map([["lineargradient","gradient"],["radialgradient","gradient"],["pattern","pattern"],["filter","filter"],["marker","marker"],["clippath","clip-path"],["mask","mask"]]),Nb=new Map([["clip-path","clip-path"],["mask","mask-image"],["mask-image","mask-image"],["filter","filter"],["fill","paint"],["stroke","paint"],["marker","marker"],["marker-start","marker"],["marker-mid","marker"],["marker-end","marker"]]),TR=new Set(["animate","set"]),RR=new Set(["clippath","defs","desc","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]);function Ab(t){return!t||t.namespaceUri!==K?null:PR.get(t.localName.toLowerCase())??null}function Eb(t,e,n){if(!n||n.namespaceUri!==K)return!1;let r=n.localName.toLowerCase();return t==="paint"||t==="smil-animated-resource"&&["fill","stroke"].includes(e??"")?r==="lineargradient"||r==="radialgradient"||r==="pattern":t==="filter"||t==="smil-animated-resource"&&e==="filter"?r==="filter":t==="marker"||t==="smil-animated-resource"&&e?.startsWith("marker")?r==="marker":t==="clip-path"||t==="smil-animated-resource"&&e==="clip-path"?r==="clippath":t==="mask-image"||t==="smil-animated-resource"&&(e==="mask"||e==="mask-image")?r==="mask":t==="gradient-template"?r==="lineargradient"||r==="radialgradient":t==="pattern-template"?r==="pattern":t==="filter-image"}function CR(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function Mb(t,e){let n=e;for(;n;){if(Ab(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function Ob(t,e,n){if(!n)return"consumer";if(e.sourceNodeId===n.sourceNodeId)return"resource-product";let r=e;for(;r&&r.sourceNodeId!==n.sourceNodeId;){if(RR.has(r.localName.toLowerCase()))return"parked";r=t.index.parent(r.sourceNodeId)}return r?"resource-product":"parked"}function $R(t){let e=[];for(let n of zn(t,";")){let r=t.slice(n.start,n.end),i=zn(r,":",!0);if(i.length<2)continue;let o=r.slice(i[0].start,i[0].end).trim().toLowerCase();if(!o)continue;let s=n.start+i[1].start,a=n.end;for(;s<a&&/\s/u.test(t[s]);)s++;for(;a>s&&/\s/u.test(t[a-1]);)a--;s!==a&&e.push({propertyName:o,valueStart:s,valueEnd:a})}return e}function Db(t,e,n,r,i,o){let s=t.index.referencesFrom(e.sourceNodeId).find(a=>o.has(a.sourceReferenceId)||a.targetAuthoredId!==n||a.authoredValue!==r?!1:i===null||a.attributeName===i);return s&&o.add(s.sourceReferenceId),s??null}function NR(t,e,n){return(t.get(e)?.elementOrder??Number.MAX_SAFE_INTEGER)-(t.get(n)?.elementOrder??Number.MAX_SAFE_INTEGER)}function AR(t,e,n){let r=(b,v)=>NR(n,b,v),i=[...t].sort(r),o=new Map(i.map(b=>[b,[...e.get(b)??[]].sort(r)])),s=new Map(i.map(b=>[b,[]]));for(let[b,v]of o)for(let I of v)s.get(I)?.push(b);for(let b of s.values())b.sort(r);let a=[],c=new Set;for(let b of i){if(c.has(b))continue;c.add(b);let v=[{nodeId:b,targetIndex:0}];for(;v.length>0;){let I=v[v.length-1],x=o.get(I.nodeId)?.[I.targetIndex];x!==void 0?(I.targetIndex++,c.has(x)||(c.add(x),v.push({nodeId:x,targetIndex:0}))):(a.push(I.nodeId),v.pop())}}let l=[],d=new Set;for(let b=a.length-1;b>=0;b--){let v=a[b];if(d.has(v))continue;let I=[],x=[v];for(d.add(v);x.length>0;){let k=x.pop();I.push(k);let T=s.get(k)??[];for(let w=T.length-1;w>=0;w--){let P=T[w];d.has(P)||(d.add(P),x.push(P))}}I.sort(r),l.push(I)}let u=new Map;l.forEach((b,v)=>{b.forEach(I=>u.set(I,v))});let p=l.map(()=>new Set);for(let[b,v]of e){let I=u.get(b);if(I!==void 0)for(let x of v){let k=u.get(x);k!==void 0&&I!==k&&p[I].add(k)}}let f=l.map(b=>n.get(b[0])?.elementOrder??Number.MAX_SAFE_INTEGER),m=(b,v)=>f[b]-f[v],g=l.map((b,v)=>v).sort(m),h=[],y=new Set;for(let b of g){if(y.has(b))continue;y.add(b);let v=[{component:b,dependencyIndex:0,dependencies:[...p[b]].sort(m)}];for(;v.length>0;){let I=v[v.length-1],x=I.dependencies[I.dependencyIndex];x!==void 0?(I.dependencyIndex++,y.has(x)||(y.add(x),v.push({component:x,dependencyIndex:0,dependencies:[...p[x]].sort(m)}))):(h.push(I.component),v.pop())}}return h.map(b=>{let v=l[b];return Object.freeze({componentId:`resource-component:${v[0]}`,memberSourceNodeIds:Object.freeze([...v]),circular:v.length>1||(e.get(v[0])?.has(v[0])??!1)})})}function zb(t,e){let n=t.index.occurrences(e),r=n[0]?.sourceNodeId??null;return{targetSourceNodeId:r,target:r?t.index.element(r):null,resolution:n.length===0?"missing":n.length===1?"resolved":"ambiguous-first"}}function zl(t,e,n,r,i,o,s,a,c,l=n.length,d=null){let u=c??Nb.get(r);if(!u)return[];let p=Mb(t,e);return _n(n.slice(s,l)).map((f,m)=>{let g=zb(t,f.targetAuthoredId);return{sourceReferenceId:(i==="authored-direct"?Db(t,e,f.targetAuthoredId,n,o,a):null)?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:d,containingResourceSourceNodeId:p?.sourceNodeId??null,participation:Ob(t,e,p),binding:i,kind:u,propertyName:r,attributeName:o,authoredValue:n,propertyValue:n.slice(s,l),tokenIndex:m,tokenStart:s+f.targetStart,tokenEnd:s+f.targetEnd,targetAuthoredId:f.targetAuthoredId,targetSourceNodeId:g.targetSourceNodeId,targetElementName:g.target?.localName??null,resolution:g.resolution,validity:g.resolution==="missing"?"missing":Eb(u,r,g.target)?"valid":"invalid-target",componentId:null}})}function tm(t,e,n,r){let i=Le(e);if(!i||!i.value.startsWith("#")||i.value.length<=1)return null;let o=i.value.slice(1),s=zb(t,o),a=i.namespace==="svg2"?"href":"xlink:href",c=Db(t,e,o,i.value,a,r),l=Mb(t,e);return{sourceReferenceId:c?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:null,containingResourceSourceNodeId:l?.sourceNodeId??null,participation:Ob(t,e,l),binding:"authored-direct",kind:n,propertyName:null,attributeName:a,authoredValue:i.value,propertyValue:i.value,tokenIndex:0,tokenStart:1,tokenEnd:i.value.length,targetAuthoredId:o,targetSourceNodeId:s.targetSourceNodeId,targetElementName:s.target?.localName??null,resolution:s.resolution,validity:s.resolution==="missing"?"missing":Eb(n,null,s.target)?"valid":"invalid-target",componentId:null}}function nm(t){let e=t.trim().toLowerCase();return Nb.has(e)?e:null}function ER(t,e){let n=[];for(let r of t.index.elements){if(r.namespaceUri!==K)continue;let i=r.localName.toLowerCase();if(i==="lineargradient"||i==="radialgradient"){let o=tm(t,r,"gradient-template",e);o&&n.push(o)}else if(i==="pattern"){let o=tm(t,r,"pattern-template",e);o&&n.push(o)}else if(i==="feimage"){let o=tm(t,r,"filter-image",e);o&&n.push(o)}if(TR.has(i)){let o=nm(C(r,"attributeName")??"");if(o)for(let s of["values","from","to","by"]){let a=r.attributes.find(c=>c.namespaceUri===null&&c.localName===s);a&&n.push(...zl(t,r,a.value,o,"authored-direct",a.name,0,e,"smil-animated-resource"))}continue}for(let o of r.attributes){if(o.namespaceUri!==null)continue;if(o.localName==="style"){for(let a of $R(o.value)){let c=nm(a.propertyName);c&&n.push(...zl(t,r,o.value,c,"authored-direct",o.name,a.valueStart,e,void 0,a.valueEnd))}continue}let s=nm(o.localName);s&&n.push(...zl(t,r,o.value,s,"authored-direct",o.name,0,e))}}return n}function MR(t,e,n){return e.flatMap(r=>{let i=t.index.element(r.fromSourceNodeId);if(!i)throw new Error(`Applied SVG resource declaration references unknown source node ${r.fromSourceNodeId}.`);return zl(t,i,r.value,r.propertyName,"applied-css",null,0,n,void 0,r.value.length,r.occurrenceId??null)})}function OR(t){let e=[];for(let n of t.index.elements){if(n.namespaceUri!==K||n.localName.toLowerCase()!=="style")continue;let r=CR(n);_n(r).forEach((i,o)=>{e.push(Object.freeze({styleSourceNodeId:n.sourceNodeId,authoredValue:r,tokenIndex:o,tokenStart:i.targetStart,tokenEnd:i.targetEnd,targetAuthoredId:i.targetAuthoredId}))})}return e}function DR(t,e,n){if(t.validity==="valid")return null;let r=t.validity==="circular",i=t.validity==="missing";return Object.freeze({severity:"warning",code:r?"circular-resource-reference":"unresolved-reference",source:e.source,entrypoint:e.entrypoint,capability:t.kind,sourceNodeId:t.fromSourceNodeId,sourceId:n?C(n,"id")??void 0:void 0,elementName:n?.name,message:r?`Circular ${t.kind} reference to #${t.targetAuthoredId} is invalid.`:i?`${t.kind} reference #${t.targetAuthoredId} is unresolved.`:`${t.kind} reference #${t.targetAuthoredId} targets an invalid ${t.targetElementName??"element"}.`})}function _l(t,e){let n=new Map(t.index.elements.map(x=>[x.sourceNodeId,x])),r=t.index.elements.flatMap(x=>{let k=Ab(x);return k?[Object.freeze({sourceNodeId:x.sourceNodeId,kind:k,authoredId:C(x,"id")})]:[]}),i=new Set(r.map(x=>x.sourceNodeId)),o=new Set,s=[...ER(t,o),...MR(t,e.appliedDeclarations??[],o)],a=new Map(r.map(x=>[x.sourceNodeId,new Set]));for(let x of s)x.validity==="valid"&&x.participation==="resource-product"&&x.containingResourceSourceNodeId&&x.targetSourceNodeId&&i.has(x.targetSourceNodeId)&&a.get(x.containingResourceSourceNodeId)?.add(x.targetSourceNodeId);let c=AR(r.map(x=>x.sourceNodeId),a,n),l=new Map;for(let x of c)for(let k of x.memberSourceNodeIds)l.set(k,x);let d=s.map((x,k)=>{let T=x.containingResourceSourceNodeId?l.get(x.containingResourceSourceNodeId):void 0,w=x.targetSourceNodeId?l.get(x.targetSourceNodeId):void 0,P=!!(x.validity==="valid"&&T?.circular&&T===w);return Object.freeze({resourceReferenceId:`resource-reference:${k}`,...x,validity:P?"circular":x.validity,componentId:T?.componentId??null})}),u=new Map;for(let x of d){let k=u.get(x.fromSourceNodeId)??[];k.push(x),u.set(x.fromSourceNodeId,k)}let p=d.flatMap(x=>{let k=DR(x,e,n.get(x.fromSourceNodeId)??null);return k?[k]:[]}),f=new Map;for(let x of p){if(!x.sourceNodeId)continue;let k=f.get(x.sourceNodeId)??[];k.push(x),f.set(x.sourceNodeId,k)}let m=new Map(d.map(x=>[x.resourceReferenceId,x])),g=new Map;for(let x of d){if(!x.containingResourceSourceNodeId||x.participation!=="resource-product")continue;let k=g.get(x.containingResourceSourceNodeId)??[];k.push(x),g.set(x.containingResourceSourceNodeId,k)}let h=x=>x.validity==="valid"||x.validity==="circular",y=x=>Object.freeze([...new Set(x.flatMap(k=>f.get(k.fromSourceNodeId)??[]))]),b=x=>{let k=x.map(F=>{let j=m.get(F.resourceReferenceId);if(!j)throw new Error(`SVG resource edge ${F.resourceReferenceId} does not belong to this dependency plan.`);return j}),T=new Set,w=new Set,P=new Set,N=new Map,R=[],$=[],A=new Map,O=F=>{if(T.add(F.resourceReferenceId),!(!h(F)||!F.targetSourceNodeId)){if(i.has(F.targetSourceNodeId)){if(w.has(F.targetSourceNodeId))return;w.add(F.targetSourceNodeId),N.set(F.targetSourceNodeId,F.resourceReferenceId),R.push(F.targetSourceNodeId);return}F.kind!=="filter-image"||P.has(F.targetSourceNodeId)||(P.add(F.targetSourceNodeId),N.set(F.targetSourceNodeId,F.resourceReferenceId),$.push(F.targetSourceNodeId))}};for(k.forEach(O);R.length>0||$.length>0;){for(;R.length>0;){let F=R.shift();for(let j of g.get(F)??[])O(j)}for(;$.length>0;){let F=$.shift(),j=[],H=[F],oe=new Set;for(;H.length>0;){let re=H.pop();if(!oe.has(re)){oe.add(re);for(let xe of u.get(re)??[])xe.containingResourceSourceNodeId===null&&(j.push(xe),O(xe));H.push(...t.index.children(re).map(xe=>xe.sourceNodeId))}}A.set(F,j)}}let G=[],M=new Set,V=new Set,X=F=>{!h(F)||!F.targetSourceNodeId||(w.has(F.targetSourceNodeId)?Y(F.targetSourceNodeId):P.has(F.targetSourceNodeId)&&U(F.targetSourceNodeId))},Y=F=>{let j=`resource:${F}`;if(!(M.has(j)||V.has(j))){V.add(j);for(let H of g.get(F)??[])X(H);V.delete(j),M.add(j),G.push(Object.freeze({sourceNodeId:F,role:"resource",viaResourceReferenceId:N.get(F)??null}))}},U=F=>{let j=`fragment:${F}`;if(!(M.has(j)||V.has(j))){V.add(j);for(let H of A.get(F)??[])X(H);V.delete(j),M.add(j),G.push(Object.freeze({sourceNodeId:F,role:"referenced-fragment",viaResourceReferenceId:N.get(F)??null}))}};for(let F of k)X(F);let te=d.filter(F=>T.has(F.resourceReferenceId)),Z=G.flatMap(F=>F.role==="resource"?[F.sourceNodeId]:[]),ne=c.filter(F=>F.memberSourceNodeIds.some(j=>w.has(j)));return Object.freeze({edges:Object.freeze(te),components:Object.freeze(ne),resourceSourceNodeIds:Object.freeze(Z),materializations:Object.freeze(G),diagnostics:y(te)})};for(let x of u.values())Object.freeze(x);Object.freeze(r),Object.freeze(d),Object.freeze(c),Object.freeze(p);let v=Object.freeze(OR(t));return Object.freeze({resources:r,edges:d,unboundStylesheetReferences:v,components:c,diagnostics:p,direct(x){return u.get(x)??Object.freeze([])},closureFromEdges(x){return b(x)},resolvePropertyValue(x,k,T){return Object.freeze((u.get(x)??[]).filter(w=>w.propertyName===k&&w.propertyValue===T))},templateChain(x){let k=[],T=new Set,w=x;for(;w&&!T.has(w);){T.add(w);let P=(u.get(w)??[]).find(N=>N.fromSourceNodeId===w&&(N.kind==="gradient-template"||N.kind==="pattern-template"));if(!P||(k.push(P),!P.targetSourceNodeId||!i.has(P.targetSourceNodeId)||P.validity==="missing"||P.validity==="invalid-target"))break;w=P.targetSourceNodeId}return Object.freeze(k)},closure(x){let k=x.map(M=>n.get(M)).filter(M=>!!M),T=new Set(k.filter(M=>i.has(M.sourceNodeId)).map(M=>M.sourceNodeId)),w=new Set;for(let M of k){let V=[M];for(;V.length>0;){let X=V.pop();w.has(X.sourceNodeId)||(w.add(X.sourceNodeId),V.push(...t.index.children(X.sourceNodeId)))}}let P=new Set;for(let M of w){i.has(M)&&!T.has(M)&&P.add(M);for(let V of u.get(M)??[])V.validity==="valid"&&V.targetSourceNodeId&&i.has(V.targetSourceNodeId)&&!T.has(V.targetSourceNodeId)&&P.add(V.targetSourceNodeId)}let N=[...T,...P];for(;N.length>0;){let M=N.pop();for(let V of a.get(M)??[])T.has(V)||P.has(V)||(P.add(V),N.push(V))}let R=c.filter(M=>M.memberSourceNodeIds.some(V=>P.has(V))),$=R.flatMap(M=>M.memberSourceNodeIds.filter(V=>P.has(V))),A=new Set([...T,...P]),O=d.filter(M=>w.has(M.fromSourceNodeId)||M.containingResourceSourceNodeId!==null&&A.has(M.containingResourceSourceNodeId)),G=[...new Set(O.flatMap(M=>f.get(M.fromSourceNodeId)??[]))];return Object.freeze({edges:Object.freeze(O),components:Object.freeze(R),resourceSourceNodeIds:Object.freeze($),materializations:Object.freeze($.map(M=>Object.freeze({sourceNodeId:M,role:"resource",viaResourceReferenceId:null}))),diagnostics:Object.freeze(G)})}})}function _b(t,e,n){let r=e.flatMap(s=>{let a=n.get(s.resourceReferenceId);if(a===void 0)return[];if(s.authoredValue!==t)throw new Error(`Resource edge ${s.resourceReferenceId} does not belong to the supplied value.`);return[{start:s.tokenStart,end:s.tokenEnd,replacement:a}]});r.sort((s,a)=>a.start-s.start||a.end-s.end);let i=t,o=t.length;for(let s of r){if(s.start<0||s.end<s.start||s.end>o)throw new Error("Overlapping or invalid SVG resource reference rewrite spans.");i=`${i.slice(0,s.start)}${s.replacement}${i.slice(s.end)}`,o=s.start}return i}var zR="http://www.w3.org/2000/xmlns/",_R="http://www.w3.org/XML/1998/namespace",Fb="http://www.w3.org/1999/xlink",FR=new Set(["class","id","lang","role","tabindex","xml:base","xml:lang","xml:space"]),LR=new Set(["cx","cy","d","dx","dy","height","inline-size","pathlength","points","r","rx","ry","shape-inside","textlength","width","x","x1","x2","y","y1","y2"]),BR=new Set(["crossorigin","decoding","href","preserveaspectratio","refx","refy","requiredextensions","requiredfeatures","systemlanguage","target","type","viewbox","zoomandpan"]);function GR(t,e,n,r){let i=e.toLowerCase(),o=n.toLowerCase();return r===zR||i==="xmlns"||i.startsWith("xmlns:")?"namespace":r!==null&&r!==_R&&r!==Fb||t!==K&&t!==null?"foreign":FR.has(i)?"metadata":i.startsWith("aria-")?"aria":i.startsWith("data-")?"data":/^on[a-z]/u.test(i)?"event-handler":Rl.some(s=>s.toLowerCase()===i)?"conditional":i==="style"?"style":r===null&&El(i)?"presentation":r===null&&LR.has(o)?"geometry":r===Fb||r===null&&BR.has(o)?"element-specific":"passthrough"}function Fl(t){let e=t.index.elements.flatMap(i=>i.attributes.map((o,s)=>Object.freeze({sourceNodeId:i.sourceNodeId,attributeOrder:s,name:o.name,localName:o.localName,prefix:o.prefix,namespaceUri:o.namespaceUri,value:o.value,span:o.span,classification:GR(i.namespaceUri,o.name,o.localName,o.namespaceUri)}))),n=Object.freeze(e),r=new Map;for(let i of n){let o=r.get(i.sourceNodeId)??[];o.push(i),r.set(i.sourceNodeId,o)}for(let[i,o]of r)r.set(i,Object.freeze(o));return Object.freeze({attributes:n,forElement:i=>r.get(i)??Object.freeze([])})}var jb=require("css-select"),Mt=require("css-what"),Si=require("css-tree");function Ll(t,e){return`${t}\0${e}`}function VR(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`var\\(\\s*${n}(?:\\s*[,)]|\\s)`,"u").test(t)}function Vl(t){let e=[];for(let a of t.rules)for(let c of a.declarations)c.propertyName.startsWith("--")&&e.push({name:c.propertyName,value:c.value});for(let a of t.elements)for(let[c,l]of Object.entries(a.inlineDeclarations))c.startsWith("--")&&e.push({name:c,value:l});let n=new Map;for(let a of e){let c=n.get(a.name)??new Set;c.add(a.value),n.set(a.name,c)}let r=new Set;for(let a of t.elements)for(let[c,l]of Object.entries(a.customProperties))Object.entries(a.specifiedValues).some(([u,p])=>!u.startsWith("--")&&VR(p,c))&&r.add(Ll(c,l));let i=new Map,o={},s=new Map;for(let a of e){let c=Ll(a.name,a.value);if(i.has(c))continue;let l=n.get(a.name)?.size??0,d=t.elements.some(m=>m.inlineDeclarations[a.name]===a.value);if(l>1&&!r.has(c)&&!d)continue;let u=a.name.slice(2),p=s.get(u)??1,f=p===1?u:`${u}-${p}`;s.set(u,p+1),i.set(c,f),o[f]=a.value}return Object.freeze({variableNameByPair:i,variables:Object.freeze(o),assignedName:(a,c)=>i.get(Ll(a,c))??null,rewriteValue(a,c){let l=t.style(a);return!l||!c.includes("var(")?c:c.replace(/var\(\s*(--[A-Za-z_][A-Za-z0-9_-]*)/gu,(d,u)=>{let p=l.customProperties[u];if(p===void 0)return d;let f=i.get(Ll(u,p));return f?`var(--${f}`:d})}})}var Ub="\0svgsketch-element-namespace",im="\0svgsketch-attribute-namespace\0",jR=new Set(["clip-path","mask","mask-image","filter","fill","stroke","marker","marker-start","marker-mid","marker-end"]),Hb=new Set(["inherit","initial","unset","revert","revert-layer"]),ro=Object.freeze({a:0,b:0,c:0});function Ln(t){return t?.children?.toArray()??[]}function Er(t){return typeof t=="string"?t:t?(0,Si.generate)(t):""}function om(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=(t[r]??-1)-(e[r]??-1);if(i!==0)return i}return 0}function Wb(t,e){return t.a-e.a||t.b-e.b||t.c-e.c}function no(t,e){return{a:t.a+e.a,b:t.b+e.b,c:t.c+e.c}}function Us(t){return t.reduce((e,n)=>Wb(n,e)>0?n:e,ro)}function sm(t){let e=ro;for(let n of t){if(n.type===Mt.SelectorType.Tag||n.type===Mt.SelectorType.PseudoElement){e=no(e,{a:0,b:0,c:1});continue}if(n.type===Mt.SelectorType.Attribute){let i=n.name==="id"&&n.action===Mt.AttributeAction.Equals&&n.ignoreCase==="quirks";e=no(e,i?{a:1,b:0,c:0}:{a:0,b:1,c:0});continue}if(n.type!==Mt.SelectorType.Pseudo)continue;let r=n.name.toLowerCase();if(r!=="where"){if((r==="is"||r==="not"||r==="has")&&Array.isArray(n.data)){e=no(e,Us(n.data.map(i=>sm(i))));continue}if((r==="nth-child"||r==="nth-last-child")&&typeof n.data=="string"){let i=ro,o=/\bof\s+(.+)$/iu.exec(n.data);if(o)try{i=Us((0,Mt.parse)(o[1]).map(sm))}catch{i=ro}e=no(no(e,{a:0,b:1,c:0}),i);continue}e=no(e,{a:0,b:1,c:0})}}return e}function UR(t){return{type:Mt.SelectorType.Attribute,name:Ub,action:Mt.AttributeAction.Equals,value:t,namespace:null,ignoreCase:!1}}function Lb(t,e){if(t==="")return"";let n=e.get(t);if(n===void 0)throw new Error(`Unknown CSS namespace prefix ${t}.`);return n}function Kb(t,e){let n=[];for(let r of t){if(r.type===Mt.SelectorType.Tag||r.type===Mt.SelectorType.Universal){let i={...r,namespace:null};n.push(i);let o=r.namespace??(e.has("")?"":null);o!==null&&o!=="*"&&n.push(UR(Lb(o,e)));continue}if(r.type===Mt.SelectorType.Attribute&&r.namespace!==null){if(r.namespace==="*")throw new Error("Wildcard attribute namespaces require an explicit namespace prefix.");let i=Lb(r.namespace,e);n.push({...r,name:`${im}${i}\0${r.name}`,namespace:null});continue}if(r.type===Mt.SelectorType.Pseudo&&Array.isArray(r.data)&&["is","where","not","has"].includes(r.name.toLowerCase())){n.push({...r,data:r.data.map(i=>Kb(i,e))});continue}n.push({...r})}return n}function HR(t){return t.children.filter(e=>e.kind!=="element").map(e=>e.value).join("")}function WR(t,e){let n=new Map;for(let o of e.occurrences){let s=t.index.element(o.correspondingSourceNodeId);s&&n.set(o.occurrenceId,{kind:"element",occurrence:o,element:s,parent:null,children:[]})}let r=[];for(let o of n.values()){let s=o.occurrence.parentOccurrenceId?n.get(o.occurrence.parentOccurrenceId)??null:null;o.parent=s,s?s.children.push(o):r.push(o);for(let a of o.element.children)a.kind!=="element"&&o.children.push({kind:"text",value:a.value,parent:o})}let i=(o,s)=>o.kind==="text"||s.kind==="text"?o.kind===s.kind?0:o.kind==="text"?1:-1:om(o.occurrence.orderKey,s.occurrence.orderKey);for(let o of n.values())o.children.sort(i);return r.sort((o,s)=>om(o.occurrence.orderKey,s.occurrence.orderKey)),{roots:Object.freeze(r),byOccurrenceId:n}}function Xb(t){return t.kind==="text"?t.value:t.children.map(Xb).join("")}function Gl(t){return t.kind==="text"?[]:[t,...t.children.flatMap(Gl)]}function KR(t){let e=new Set(t);return t.filter(n=>{let r=n.parent;for(;r;){if(e.has(r))return!1;r=r.parent}return!0})}function Bb(t,e){if(e===Ub)return t.element.namespaceUri??"";if(e.startsWith(im)){let[n,r]=e.slice(im.length).split("\0");return t.element.attributes.find(i=>(i.namespaceUri??"")===n&&i.localName===r)?.value}return t.attributeOverrides&&Object.prototype.hasOwnProperty.call(t.attributeOverrides,e)?t.attributeOverrides?.[e]??void 0:t.element.attributes.find(n=>n.namespaceUri===null&&n.localName===e)?.value}function XR(t){return{adapter:{isTag:n=>n.kind==="element",existsOne:(n,r)=>r.some(i=>Gl(i).some(n)),getAttributeValue:Bb,getChildren:n=>n.kind==="element"?n.children:[],getName:n=>n.element.localName,getParent:n=>n.parent,getSiblings:n=>n.parent?.children??[n],prevElementSibling:n=>{let r=n.parent?.children??[],i=r.indexOf(n);for(let o=i-1;o>=0;o--)if(r[o].kind==="element")return r[o];return null},getText:Xb,hasAttrib:(n,r)=>Bb(n,r)!==void 0,removeSubsets:KR,findAll:(n,r)=>r.flatMap(Gl).filter(n),findOne:(n,r)=>r.flatMap(Gl).find(n)??null,equals:(n,r)=>n===r,isHovered:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"hover")===!0,isVisited:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"visited")===!0,isActive:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"active")===!0},xmlMode:!0,lowerCaseAttributeNames:!1,lowerCaseTags:!1,cacheResults:!0}}function YR(t,e,n){try{let i=(0,Mt.parse)(t).map(o=>{let s=Kb(o,e),a=(0,jb.compile)([s],n);return Object.freeze({matches:c=>a(c),specificity:Object.freeze(sm(o))})});return Object.freeze(i)}catch{return null}}function qR(t){let e=[],n=0,r=null,i=!1,o=0,s=a=>{let c=t.slice(n,a).trim();c&&e.push(c)};for(let a=0;a<t.length;a++){let c=t[a];if(r){i?i=!1:c==="\\"?i=!0:c===r&&(r=null);continue}if(c==='"'||c==="'"){r=c;continue}c==="("?o++:c===")"?o=Math.max(0,o-1):o===0&&(/[\t\n\f\r ]/u.test(c)||c==="/")&&(s(a),c==="/"&&e.push("/"),n=a+1)}return s(t.length),e}function ZR(t){let e=qR(t),n=/^(?:xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large|larger|smaller|(?:\d*\.)?\d+(?:%|[a-z]+))$/iu,r=e.findIndex(u=>n.test(u));if(r<0)return null;let i="normal",o="normal",s="normal",a="normal";for(let u of e.slice(0,r)){let p=u.toLowerCase();p==="italic"||p==="oblique"?i=u:p==="small-caps"?o=u:p==="bold"||p==="bolder"||p==="lighter"||/^\d{1,4}$/u.test(p)?s=u:/^(?:ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded)$/u.test(p)&&(a=u)}let c=r+1,l="normal";e[c]==="/"&&(l=e[c+1]??"normal",c+=2);let d=e.slice(c).join(" ").trim();return d?Object.freeze({"font-style":i,"font-variant":o,"font-weight":s,"font-stretch":a,"font-size":e[r],"line-height":l,"font-family":d}):null}function JR(t){let e=t.propertyName;if(e==="marker")return["marker-start","marker-mid","marker-end"].map(n=>({...t,propertyName:n}));if(e==="font"){let n=ZR(t.value);return n?Object.entries(n).map(([r,i])=>({...t,propertyName:r,value:i,authoredValue:i})):[]}return e==="all"&&Hb.has(t.value.toLowerCase())?js.map(n=>({...t,propertyName:n})):[t]}function QR(t,e){let n=e.trim().toLowerCase();if(t==="color-rendering")return n==="auto"||n==="optimizespeed"||n==="optimizequality";if(t==="color-interpolation")return n==="auto"||n==="srgb"||n==="linearrgb";if(t!=="clip-path")return!1;if(Hb.has(n)||n==="none")return!0;let r="(?:fill-box|stroke-box|view-box|content-box|border-box|margin-box|padding-box)",i="(?:inset|circle|ellipse|polygon|path|shape|rect|xywh)\\([\\s\\S]*\\)";return new RegExp(`^(?:url\\([\\s\\S]*\\)|${i}(?:\\s+${r})?|${r}(?:\\s+${i})?)$`,"iu").test(e.trim())}function cm(t){let e;try{e=(0,Si.parse)(t,{context:"declarationList",positions:!0})}catch{return{declarations:Object.freeze([]),raw:Object.freeze({})}}let n=[],r={};for(let[i,o]of Ln(e).entries()){if(o.type!=="Declaration"||typeof o.property!="string"||!o.value)continue;let s=o.property,a=s.startsWith("--")?s:s.toLowerCase(),c=typeof o.value!="string"&&o.value.loc?t.slice(o.value.loc.start.offset,o.value.loc.end.offset).trim():Er(o.value).trim();r[a]=c;let l=a.startsWith("--"),d=/(?:^|[^-_a-z0-9])var\(/iu.test(c);if(!(l||d||Si.lexer.matchProperty(a,o.value).matched||QR(a,c)))continue;let p={propertyName:a,authoredPropertyName:s,value:c,authoredValue:c,important:!!o.important,order:i};n.push(...JR(p))}return{declarations:Object.freeze(n),raw:Object.freeze(r)}}function Yb(t){if(!t)return Object.freeze({values:Object.freeze({}),importantProperties:Object.freeze([])});let e=cm(t),n=new Map;for(let o of e.declarations)n.get(o.propertyName)?.important&&!o.important||n.set(o.propertyName,o);let r={...e.raw},i=[];for(let[o,s]of n)r[o]=s.value,s.important&&i.push(o);return Object.freeze({values:Object.freeze(r),importantProperties:Object.freeze(i)})}function Bl(t,e){let n=cm(t),r=n.declarations.map((i,o)=>Object.freeze({...i,declarationId:`${e.ruleId??e.sourceNodeId}:${e.origin}:${i.order}:${o}`,sourceNodeId:e.sourceNodeId,origin:e.origin,sourceOrder:Object.freeze([...e.sourceOrder,i.order,o]),ruleId:e.ruleId,layerRank:e.layerRank}));return{templates:Object.freeze(r),raw:n.raw}}function rm(t,e,n){return Object.freeze({declarationId:t.declarationId,sourceNodeId:t.sourceNodeId,occurrenceId:e,propertyName:t.propertyName,authoredPropertyName:t.authoredPropertyName,value:t.value,authoredValue:t.authoredValue,important:t.important,origin:t.origin,specificity:Object.freeze({...n}),sourceOrder:t.sourceOrder,ruleId:t.ruleId})}function eC(t){let e=Ln(t.prelude);if(e.length===0)return null;let n=e[e.length-1],r=(n.type==="Url"||n.type==="String")&&typeof n.value=="string"?n.value:null;if(r===null)return null;let i=e[0];return{prefix:e.length>1&&i.type==="Identifier"&&typeof i.name=="string"?i.name:"",uri:r}}function tC(t){return Er(t.prelude).split(",").map(e=>e.trim()).filter(Boolean)}var nC=new Set(["default","inherit","initial","none","revert","revert-layer","unset"]);function rC(t){let e=Ln(t.prelude);if(e.length!==1)return null;let n=e[0];return n.type==="String"&&typeof n.value=="string"?n.value===""?null:n.value:n.type!=="Identifier"||typeof n.name!="string"||nC.has(n.name.toLowerCase())?null:n.name}function iC(t){let e=t.trim().toLowerCase();if(e==="from")return 0;if(e==="to")return 1;let n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)%$/iu.exec(e);if(!n)return null;let r=Number(n[1]);return Number.isFinite(r)&&r>=0&&r<=100?r/100:null}function oC(t){return t.important?!1:t.propertyName==="animation-timing-function"||t.propertyName!=="animation"&&!t.propertyName.startsWith("animation-")}function sC(t,e,n){let r=rC(t);if(!r||!t.block)return null;let i=`${e.sourceNodeId}:keyframes:${n}`,o=new Map;for(let[a,c]of Ln(t.block).entries()){if(c.type!=="Rule"||!c.prelude||!c.block)continue;let l=Er(c.prelude).split(",").map(iC).filter(p=>p!==null);if(l.length===0)continue;let d=Ln(c.block).filter(p=>p.type==="Declaration").map(p=>Er(p)).join(";"),u=cm(d).declarations.filter(oC);for(let p of l){let f=o.get(p)??new Map;for(let[m,g]of u.entries())f.set(g.propertyName,Object.freeze({declarationId:`${i}:${a}:${g.order}:${m}`,propertyName:g.propertyName,authoredPropertyName:g.authoredPropertyName,value:g.value,authoredValue:g.authoredValue,sourceOrder:Object.freeze([n,a,g.order,m])}));o.set(p,f)}}let s=[...o.entries()].sort(([a],[c])=>a-c).map(([a,c])=>Object.freeze({offset:a,declarations:Object.freeze([...c.values()]),properties:am([...c].map(([l,d])=>[l,d.value]))}));return Object.freeze({keyframesId:i,stylesheetSourceNodeId:e.sourceNodeId,name:r,sourceOrder:n,stops:Object.freeze(s)})}function aC(t,e,n,r){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,capability:"styles",sourceNodeId:e.sourceNodeId,sourceId:C(e,"id")??void 0,elementName:e.name,documentPath:n.index.sourcePath(e.sourceNodeId),message:r})}function Gb(t,e){return t.matchesMedia(e)===!0}function cC(t,e){return t.supportsCondition(e)===!0}function Vb(t,e,n){let r=Number(t.declaration.important)-Number(e.declaration.important);if(r!==0)return r;let i=c=>c.declaration.important?c.layerRank===null?-1:n-c.layerRank:c.layerRank===null?n+1:c.layerRank,o=i(t)-i(e);if(o!==0)return o;let s=t.originRank-e.originRank;return s!==0?s:Wb(t.declaration.specificity,e.declaration.specificity)||om(t.declaration.sourceOrder,e.declaration.sourceOrder)}function lC(t){let e=null,n=!1,r=0;for(let i=0;i<t.length;i++){let o=t[i];if(e){n?n=!1:o==="\\"?n=!0:o===e&&(e=null);continue}if(o==='"'||o==="'")e=o;else if(o==="(")r++;else if(o===")")r=Math.max(0,r-1);else if(o===","&&r===0)return i}return-1}function Ar(t,e,n=new Set){let r=xn(t);if(r.length===0)return t.trim();let i=t;for(let o of[...r].reverse()){let s=t.slice(o.argumentsStart,o.argumentsEnd),a;if(o.name==="var"){let c=lC(s),l=(c<0?s:s.slice(0,c)).trim(),d=c<0?null:s.slice(c+1).trim();if(!l.startsWith("--")||n.has(l))a=d?Ar(d,e,n):null;else{let u=e[l];if(u===void 0)a=d?Ar(d,e,n):null;else{let p=new Set(n);p.add(l),a=Ar(u,e,p),a===null&&d&&(a=Ar(d,e,n))}}}else{let c=Ar(s,e,n);a=c===null?null:`${t.slice(o.tokenStart,o.argumentsStart)}${c})`}if(a===null)return null;i=`${i.slice(0,o.tokenStart)}${a}${i.slice(o.tokenEnd)}`}return i.trim()}function am(t){return Object.freeze(Object.fromEntries(t))}function jl(t,e,n){let r=[],i=WR(t,e),o=XR(n.environment),s=[],a=[],c=[],l=[],d=new Map,u=0,p=0,f=0,m=P=>{let N=d.get(P);if(N!==void 0)return N;let R=d.size;return d.set(P,R),R},g=(P,N,R,$)=>{for(let A of P){if(A.type==="Atrule"){let Z=A.name?.toLowerCase();if(Z==="keyframes"){let ne=sC(A,N,f++);ne&&(c.push(ne),N.keyframesIds.push(ne.keyframesId));continue}if(Z==="namespace"){let ne=eC(A);ne&&R.set(ne.prefix,ne.uri);continue}if(Z==="layer"){let ne=tC(A);if(!A.block){for(let H of ne)m(H);continue}let F=ne[0]??`__anonymous_${u++}`,j=$?`${$}.${F}`:F;m(j),g(Ln(A.block),N,new Map(R),j);continue}if(Z==="media"){let ne=Er(A.prelude).trim();A.block&&Gb(n.environment,ne)&&g(Ln(A.block),N,new Map(R),$);continue}if(Z==="supports"){let ne=Er(A.prelude).trim();A.block&&cC(n.environment,ne)&&g(Ln(A.block),N,new Map(R),$);continue}continue}if(A.type!=="Rule"||!A.prelude||!A.block)continue;let O=Er(A.prelude).trim(),G=YR(O,R,o);if(!G)continue;let M=`${N.sourceNodeId}:rule:${p}`,V=Ln(A.block).filter(Z=>Z.type==="Declaration").map(Z=>Er(Z)).join(";"),X=$===null?null:m($),Y=Bl(V,{sourceNodeId:N.sourceNodeId,origin:"stylesheet",ruleId:M,sourceOrder:[N.sourceNodeId===t.root.sourceNodeId?-1:p,p],layerRank:X}),U=Y.templates.map(Z=>rm(Z,"",Us(G.map(ne=>ne.specificity)))),te=Object.freeze({ruleId:M,stylesheetSourceNodeId:N.sourceNodeId,selectorText:O,specificities:Object.freeze(G.map(Z=>Z.specificity)),layer:$,declarations:Object.freeze(U)});a.push(te),l.push(Object.freeze({plan:te,selectors:G,templates:Y.templates})),N.ruleIds.push(M),p++}};for(let P of t.index.elements){if(P.namespaceUri!==K||P.localName.toLowerCase()!=="style")continue;let N=HR(P),R=C(P,"type"),$=C(P,"media"),A=R===null||R.trim()===""||R.trim().toLowerCase()==="text/css",O=$===null||$.trim()===""||Gb(n.environment,$),G=[],M=[],V={sourceNodeId:P.sourceNodeId,authoredText:N,id:C(P,"id"),type:R,media:$,title:C(P,"title"),applicable:A&&O,ruleIds:G,keyframesIds:M};if(s.push(V),!V.applicable){Object.freeze(G),Object.freeze(M),Object.freeze(V);continue}try{let X=(0,Si.parse)(N,{positions:!0});g(Ln(X),V,new Map,null)}catch{r.push(aC(n,P,t,"The SVG style element contains malformed CSS."))}Object.freeze(G),Object.freeze(M),Object.freeze(V)}let h=new Map;for(let P of c)h.set(P.name,P);let y=new Map,b=new Map,v=P=>{let N=y.get(P.occurrence.occurrenceId);if(N)return N;let R=P.parent?v(P.parent):null,$=new Map,A=[],O=[],G=(F,j,H)=>{let oe=rm(F,P.occurrence.occurrenceId,j);A.push(oe);let re=$.get(oe.propertyName)??[];re.push({declaration:oe,layerRank:F.layerRank,originRank:H}),$.set(oe.propertyName,re)};for(let[F,j]of P.element.attributes.entries()){if(j.namespaceUri!==null||!$r(j.localName))continue;let H={sourceNodeId:P.element.sourceNodeId,origin:"presentation",ruleId:null,sourceOrder:[P.element.elementOrder,-2,F],layerRank:null},oe=Bl(`${j.localName}:${j.value}`,H).templates,re=j.localName==="font-size"?pt(j.value):null;oe.length===0&&re?.unit===""&&re.value>=0&&(oe=Bl(`font-size:${re.value}px`,H).templates.map(xe=>Object.freeze({...xe,value:j.value,authoredValue:j.value})));for(let xe of oe)xe.important||G(xe,ro,0)}for(let F of l){let j=F.selectors.filter(oe=>oe.matches(P));if(j.length===0)continue;O.push(F.plan.ruleId);let H=Us(j.map(oe=>oe.specificity));for(let oe of F.templates)G(oe,H,1)}let M=C(P.element,"style");if(M!==null){let F=Bl(M,{sourceNodeId:P.element.sourceNodeId,origin:"style-attribute",ruleId:null,sourceOrder:[P.element.elementOrder,Number.MAX_SAFE_INTEGER],layerRank:null});b.set(P.occurrence.occurrenceId,F.raw);for(let j of F.templates)G(j,ro,2)}let V=new Map,X=new Map;for(let[F,j]of $){j.sort((oe,re)=>Vb(oe,re,d.size)),V.set(F,j[j.length-1].declaration);let H=j.filter(oe=>oe.declaration.origin==="stylesheet");H.length>0&&X.set(F,H[H.length-1].declaration)}let Y={...R?.customProperties??{}};for(let[F,j]of V){if(!F.startsWith("--"))continue;let H=j.value.trim().toLowerCase();H==="inherit"||H==="unset"?R?.customProperties[F]===void 0?delete Y[F]:Y[F]=R.customProperties[F]:H==="initial"||H==="revert"||H==="revert-layer"?delete Y[F]:Y[F]=j.value}let U={},te={},Z=new Set([...js,...[...V.keys()].filter(F=>!F.startsWith("--"))]);for(let F of Z){let j=$r(F),H=V.get(F),oe=R?.resolvedValues[F],re=j?.initialValue,xe;if(H){let rt=H.value.trim().toLowerCase();rt==="inherit"?xe=oe??re:rt==="initial"||rt==="revert"||rt==="revert-layer"?xe=re:rt==="unset"?xe=j?.inherited?oe??re:re:xe=H.value}else j?.inherited?xe=oe??re:xe=re;if(xe===void 0)continue;U[F]=xe;let Ze=Ar(xe,Y);Ze===null&&(Ze=j?.inherited?oe??re??null:re??null),Ze!==null&&(Ze.trim().toLowerCase()==="currentcolor"&&(Ze=F==="color"?R?.resolvedValues.color??"black":te.color??R?.resolvedValues.color??"black"),te[F]=Ze)}let ne=Object.freeze({occurrenceId:P.occurrence.occurrenceId,correspondingSourceNodeId:P.occurrence.correspondingSourceNodeId,matchedRuleIds:Object.freeze(O),declarations:Object.freeze(A),cascadedValues:am(V),stylesheetCascadedValues:am(X),specifiedValues:Object.freeze(U),resolvedValues:Object.freeze(te),customProperties:Object.freeze(Y),inlineDeclarations:b.get(P.occurrence.occurrenceId)??Object.freeze({})});return y.set(P.occurrence.occurrenceId,ne),ne};for(let P of i.byOccurrenceId.values())v(P);let I=Object.freeze(e.occurrences.map(P=>y.get(P.occurrenceId)).filter(P=>P!==void 0)),x=new Map;for(let P of e.occurrences){if(P.usePath.length!==0)continue;let N=y.get(P.occurrenceId);N&&x.set(P.correspondingSourceNodeId,N)}let k=[];for(let P of I)for(let[N,R]of Object.entries(P.resolvedValues)){if(!jR.has(N)||!R.toLowerCase().includes("url("))continue;let $=P.cascadedValues[N];k.push(Object.freeze({fromSourceNodeId:P.correspondingSourceNodeId,occurrenceId:P.occurrenceId,propertyName:N,value:R,origin:$?$.origin==="style-attribute"?"inline-style":"matched-stylesheet":"inherited-stylesheet"}))}let T=(P,N)=>{let R=i.byOccurrenceId.get(P);if(!R)return Object.freeze({});let $={...R,attributeOverrides:Object.freeze({class:N})},A=new Map;for(let U of l){let te=U.selectors.filter(ne=>ne.matches($));if(te.length===0)continue;let Z=Us(te.map(ne=>ne.specificity));for(let ne of U.templates){let F=rm(ne,P,Z),j=A.get(F.propertyName)??[];j.push({declaration:F,layerRank:ne.layerRank,originRank:1}),A.set(F.propertyName,j)}}let O=new Map;for(let[U,te]of A)te.sort((Z,ne)=>Vb(Z,ne,d.size)),O.set(U,te[te.length-1].declaration);let G=R.parent?y.get(R.parent.occurrence.occurrenceId):null,M={...G?.customProperties??{}};for(let[U,te]of O){if(!U.startsWith("--"))continue;let Z=te.value.trim().toLowerCase();if(Z==="inherit"||Z==="unset"){let ne=G?.customProperties[U];ne===void 0?delete M[U]:M[U]=ne}else Z==="initial"||Z==="revert"||Z==="revert-layer"?delete M[U]:M[U]=te.value}let V={},X=O.get("color"),Y=X?Ar(X.value,M):G?.resolvedValues.color??"black";for(let[U,te]of O){if(U.startsWith("--"))continue;let Z=Ar(te.value,M);Z!==null&&(Z.trim().toLowerCase()==="currentcolor"&&(Z=Y??"black"),V[U]=Z)}return Object.freeze(V)},w=Object.freeze({stylesheets:Object.freeze(s),rules:Object.freeze(a),keyframes:Object.freeze(c),elements:I,appliedResourceDeclarations:Object.freeze(k),keyframesRule:P=>h.get(P)??null,ownStyle:P=>x.get(P)??null,style:P=>y.get(P)??null,value:(P,N)=>y.get(P)?.resolvedValues[N.toLowerCase()]??null,stylesheetValuesWithClass:T});return Object.freeze({value:w,diagnostics:Object.freeze(r)})}function lm(t,e,n,r,i,o){if(n<=0||r<=0)return null;if(i<=0||o<=0)return`M${t},${e}h${n}v${r}h${-n}Z`;let s=t+n,a=e+r;return`M${t+i},${e}H${s-i}A${i},${o} 0 0 1 ${s},${e+o}V${a-o}A${i},${o} 0 0 1 ${s-i},${a}H${t+i}A${i},${o} 0 0 1 ${t},${a-o}V${e+o}A${i},${o} 0 0 1 ${t+i},${e}Z`}function qb(t,e,n,r){return n<=0||r<=0?null:`M${t+n},${e}A${n},${r} 0 0 1 ${t},${e+r}A${n},${r} 0 0 1 ${t-n},${e}A${n},${r} 0 0 1 ${t},${e-r}A${n},${r} 0 0 1 ${t+n},${e}Z`}function Ul(t){let e=t.state;if(typeof e.d=="string")return e.d;let n=Qt(t);if(!n)return null;switch(n.kind){case"path":return n.d||null;case"rectangle":return n.pathData??lm(n.x,n.y,n.width,n.height,n.rx,n.ry);case"circle":return qb(n.cx,n.cy,n.r,n.r);case"ellipse":return qb(n.cx,n.cy,n.rx,n.ry);case"line":return`M${n.x1},${n.y1}L${n.x2},${n.y2}`;case"polyline":{if(n.points.length<2||n.points.some(i=>!Number.isFinite(i.x)||!Number.isFinite(i.y)))return null;let r=n.points.map((i,o)=>`${o===0?"M":"L"}${i.x},${i.y}`).join("");return n.closed?`${r}Z`:r}default:return null}}var dC=new Map([["animate","animate"],["animatetransform","animateTransform"],["animatemotion","animateMotion"],["set","set"],["discard","discard"]]);function uC(t){return Object.freeze(Object.fromEntries(t.attributes.map(e=>[e.name,e.value])))}function pC(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function fC(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&pC(r,e))??t.direct(n)}function mC(t,e,n,r){let i=Le(n);if(!i)return null;if(i.value===""||i.value==="#")return{status:"empty",sourceNodeId:null,occurrenceId:null};if(!i.value.startsWith("#"))return{status:"external",sourceNodeId:null,occurrenceId:null};let o=i.value.slice(1),s=t.index.resolveAuthoredId(o);if(!s)return{status:"missing",sourceNodeId:null,occurrenceId:null};let a=t.index.element(s.sourceNodeId);if(!a||a.namespaceUri!==K&&a.namespaceUri!==null)return{status:"invalid",sourceNodeId:s.sourceNodeId,occurrenceId:null};let c=fC(e,r,a.sourceNodeId);return{status:c?"resolved":"missing",sourceNodeId:a.sourceNodeId,occurrenceId:c?.occurrenceId??null}}function gC(t,e,n){let r=n.parentOccurrenceId?e.occurrence(n.parentOccurrenceId):null,i=r?t.index.element(r.correspondingSourceNodeId):null;return i?.localName.toLowerCase()==="textpath"&&r?.parentOccurrenceId&&(r=e.occurrence(r.parentOccurrenceId),i=r?t.index.element(r.correspondingSourceNodeId):null),i&&r?{status:"resolved",sourceNodeId:i.sourceNodeId,occurrenceId:r.occurrenceId}:{status:"missing",sourceNodeId:null,occurrenceId:null}}function hC(t,e,n,r){let i=t.index.children(n.sourceNodeId).find(u=>(u.namespaceUri===K||u.namespaceUri===null)&&u.localName.toLowerCase()==="mpath");if(!i)return{sourceNodeId:null,data:C(n,"path")};let o=Le(i);if(!o?.value.startsWith("#")||o.value.length<=1)return{sourceNodeId:null,data:null};let s=t.index.resolveAuthoredId(o.value.slice(1)),a=s?t.index.element(s.sourceNodeId):null;if(!a)return{sourceNodeId:s?.sourceNodeId??null,data:null};if(a.localName.toLowerCase()==="path")return{sourceNodeId:a.sourceNodeId,data:C(a,"d")};let c=e.direct(a.sourceNodeId),l=c?r?.candidate(c.occurrenceId):null;if(!l||l.status!=="materialized"||!l.canonicalType)return{sourceNodeId:a.sourceNodeId,data:null};let d={id:l.occurrenceId,type:l.canonicalType,state:l.state};return{sourceNodeId:a.sourceNodeId,data:Ul(d)}}function yC(t,e,n,r){let i=[];for(let o of e.occurrences){let s=t.index.element(o.correspondingSourceNodeId);if(!s||s.namespaceUri!==K&&s.namespaceUri!==null)continue;let a=dC.get(s.localName.toLowerCase());if(!a)continue;let c=mC(t,e,s,o)??gC(t,e,o),l=uC(s),d={values:l.values,from:l.from,to:l.to,by:l.by,additive:l.additive,dur:l.dur,keyTimes:l.keyTimes,calcMode:l.calcMode,keySplines:l.keySplines,repeatCount:l.repeatCount,repeatDur:l.repeatDur,fill:l.fill},u=a==="animateMotion"?hC(t,e,s,r):null,p=c.sourceNodeId?t.index.element(c.sourceNodeId):null,f=(c.occurrenceId?n.style(c.occurrenceId)?.cascadedValues.transform?.value:void 0)??(p?C(p,"transform"):null),m=ml(d);i.push(Object.freeze({animationId:`smil:${o.occurrenceId}`,sourceNodeId:s.sourceNodeId,occurrenceId:o.occurrenceId,kind:a,sourceAnimationId:C(s,"id"),targetStatus:c.status,targetSourceNodeId:c.sourceNodeId,targetOccurrenceId:c.occurrenceId,attributeName:C(s,"attributeName"),attributes:l,duration:gl(d),additive:m,...a==="animateTransform"&&m==="replace"&&f!==null&&f.trim().toLowerCase()!=="none"?{replacesCarrierBase:!0}:{},fill:l.fill==="freeze"?"freeze":"remove",motionPathSourceNodeId:u?.sourceNodeId??null,motionPathData:u?.data??null}))}return Object.freeze(i)}function SC(t){let e=t.parsedEasing?Object.freeze({...t.parsedEasing,..."points"in t.parsedEasing?{points:Object.freeze([...t.parsedEasing.points])}:{}}):null;return Object.freeze({...t,parsedEasing:e})}function bC(t){let e=[];for(let n of t.elements){let r=n.resolvedValues,i=r.animation||gf(r);if(i)for(let[o,s]of gs(i).entries()){let a=Oc(s);if(!a){let l=hs(r["animation-name"],o);l&&l!=="none"&&(a=Oc(`${s} ${l}`))}if(!a)continue;mf(a,r,o);let c=t.keyframesRule(a.name);!c||c.stops.length===0||e.push(Object.freeze({animationId:`css:${n.occurrenceId}:${o}`,sourceNodeId:n.correspondingSourceNodeId,occurrenceId:n.occurrenceId,animationIndex:o,animation:SC(a),keyframes:c}))}}return Object.freeze(e)}function Zb(t){let e=new Map;for(let n of t){let r=e.get(n.occurrenceId)??[];r.push(n),e.set(n.occurrenceId,r)}for(let n of e.values())Object.freeze(n);return e}function Hl(t,e,n,r){let i=yC(t,e,n,r.leafGeometry),o=bC(n),s=i.filter(d=>d.targetStatus!=="resolved").map(d=>{let u=t.index.element(d.sourceNodeId);return Object.freeze({severity:"warning",code:"unresolved-reference",source:r.source,entrypoint:r.entrypoint,capability:"smil-animation",sourceId:d.sourceAnimationId??void 0,sourceNodeId:d.sourceNodeId,occurrenceId:d.occurrenceId,elementName:u?.name,documentPath:t.index.sourcePath(d.sourceNodeId),message:`The SVG animation target is ${d.targetStatus} and cannot be materialized.`})});for(let d of o)for(let u of d.keyframes.stops){let p=u.properties.transform??u.properties["-webkit-transform"]??u.properties["-moz-transform"];if(p===void 0)continue;let f=If(p);f&&s.push(Object.freeze({severity:"warning",code:f==="unsupported-perspective"?"unsupported-ingest-capability":"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"css-animation",sourceNodeId:d.sourceNodeId,occurrenceId:d.occurrenceId,documentPath:t.index.sourcePath(d.sourceNodeId),message:f==="unsupported-perspective"?"A projective CSS transform cannot be represented by the native affine timeline.":"A CSS transform keyframe has invalid function syntax and was not materialized."}))}let a=Zb(i),c=Zb(o),l=Object.freeze({smil:i,css:o,smilForOccurrence:d=>a.get(d)??Object.freeze([]),cssForOccurrence:d=>c.get(d)??Object.freeze([])});return Object.freeze({value:l,diagnostics:Object.freeze(s)})}var vC=new Set(["circle","ellipse","flowroot","foreignobject","image","line","path","polygon","polyline","rect","text"]),xC=Object.freeze({});function Kl(t){if(Array.isArray(t))return Object.freeze(t.map(Kl));if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))e[n]=Kl(r);return Object.freeze(e)}return t}function IC(t){return Kl(t)}function wC(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function kC(t,e){return wC(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function PC(t,e,n,r,i){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"geometry",sourceId:C(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:i})}function Ge(t,e,n,r,i={},o){return Object.freeze({occurrenceId:t.occurrenceId,sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),elementName:e.localName,canonicalType:n,status:r,state:Object.keys(i).length===0?xC:IC(i),...o?{authoredTextStructure:Kl(o)}:{}})}function Mr(t,e,n,r){let i=t.style(e.occurrenceId);return i?.cascadedValues[r]?i.resolvedValues[r]??i.specifiedValues[r]??null:C(n,r)}function TC(t,e,n){let r=t.value(e.occurrenceId,"font-size");if(!r||r==="medium")return n.rootFontSize;let i=Pe(r,{percentBasis:n.rootFontSize,viewportWidth:n.viewport.width,viewportHeight:n.viewport.height,fontSize:n.rootFontSize,rootFontSize:n.rootFontSize});return i!==void 0&&i>=0?i:n.rootFontSize}function um(t,e,n){return{percentBasis:t==="x"?n.viewport.width:t==="y"?n.viewport.height:Math.hypot(n.viewport.width,n.viewport.height)/Math.SQRT2,viewportWidth:n.viewport.width,viewportHeight:n.viewport.height,fontSize:e,rootFontSize:n.rootFontSize}}function pm(t){if(t===null)return null;let e=/\S+/.exec(t.trim());return e?e[0].replace(/,$/,""):null}function dm(t,e,n,r,i,o,s){return Pe(pm(Mr(t,e,n,r)),um(i,o,s))}function Hs(t){if(t===null||t.trim()==="")return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function RC(t){if(!t)return{points:[],odd:!1};let n=(t.match(/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/g)??[]).map(Number).filter(Number.isFinite),r=n.length%2!==0,i=[];for(let o=0;o+1<n.length;o+=2)i.push({x:n[o],y:n[o+1]});return{points:i,odd:r}}function CC(t){let e=C(t,"transform");if(!e||e.trim()==="")return{rotation:0};let n=Ht(e);return Et(n)?{rotation:0}:{transformMatrix:tt(n)}}function Bn(t,e,n,r){let i=t.type===t.type.toLowerCase();return[t.params[e]+(i?n:0),t.params[e+1]+(i?r:0)]}function ev(t){let e=[],n=0,r=0,i=0,o=0,s=0,a=0,c="",l=!1,d=!1;for(let u of t){let p=u.type.toUpperCase(),f=u.type===u.type.toLowerCase(),m=c.toUpperCase()==="Z",g=e.length;if(!(p==="B"||p==="R")){if(p==="Z"){n=i,r=o,l=!0,d||=e.length>1,c=u.type;continue}if(p==="M"){let[h,y]=Bn(u,0,n,r),b={x:h,y,pointType:"corner"};e.length>0&&(b.isSubpathStart=!0),e.push(b),n=i=h,r=o=y,c=u.type;continue}if(p==="H")n=u.params[0]+(f?n:0),e.push({x:n,y:r,pointType:"corner",segmentType:"HORIZONTAL"}),d=!0;else if(p==="V")r=u.params[0]+(f?r:0),e.push({x:n,y:r,pointType:"corner",segmentType:"VERTICAL"}),d=!0;else if(p==="L")[n,r]=Bn(u,0,n,r),e.push({x:n,y:r,pointType:"corner"}),d=!0;else if(p==="C"){let h=n,y=r,[b,v]=Bn(u,0,h,y),[I,x]=Bn(u,2,h,y),[k,T]=Bn(u,4,h,y),w=e.at(-1);w&&(w.pointType="smooth",w.handleOut={x:b,y:v}),e.push({x:k,y:T,handleIn:{x:I,y:x},pointType:"smooth"}),n=k,r=T,s=I,a=x,d=!0}else if(p==="S"){let h=n,y=r,[b,v]=Bn(u,0,h,y),[I,x]=Bn(u,2,h,y),k=e.at(-1);k&&(k.pointType="smooth",k.handleOut=/^[CcSs]$/.test(c)?{x:2*h-s,y:2*y-a}:{x:h,y}),e.push({x:I,y:x,handleIn:{x:b,y:v},pointType:"smooth",segmentType:"SMOOTH_CUBIC"}),n=I,r=x,s=b,a=v,d=!0}else if(p==="Q"||p==="T"){let h=n,y=r,b=p==="T",[v,I]=b?/^[QqTt]$/.test(c)?[2*h-s,2*y-a]:[h,y]:Bn(u,0,h,y),[x,k]=Bn(u,b?0:2,h,y),T=e.at(-1);T&&(T.pointType="smooth",T.handleOut={x:v,y:I});let w={x,y:k,pointType:"smooth",segmentType:b?"SMOOTH_QUADRATIC":"QUADRATIC"};e.push(w),n=x,r=k,s=v,a=I,d=!0}else if(p==="A"){let h=n,y=r,[b,v]=Bn(u,5,h,y),I=Math.abs(u.params[0]),x=Math.abs(u.params[1]),k={x:b,y:v,pointType:"corner"};I!==0&&x!==0&&(b!==n||v!==r)&&(k.segmentType="ARC",k.arcParams={rx:I,ry:x,rotation:u.params[2],largeArc:u.params[3]===1,sweep:u.params[4]===1}),(b!==n||v!==r)&&(e.push(k),d=!0),n=b,r=v}m&&e.length>g&&(e[g].isSubpathStart=!0),c=u.type}}return{points:e,closed:l,drawn:d}}function $C(t){return t.replace(/[\t\n\r ]+/g," ").trim()}function tv(t){let e=[];for(let n of t.children)if(n.kind==="text"||n.kind==="cdata"){let r=$C(n.value);r&&e.push(r)}else if(n.kind==="element"){let r=tv(n);r&&e.push(r)}return e.join(" ")}function NC(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function AC(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&NC(r,e))??t.direct(n)}function EC(t,e){let n=e;for(;n;){let r=n.attributes.find(i=>i.prefix==="xml"&&i.localName==="space")?.value;if(r)return r;n=t.index.parent(n.sourceNodeId)}return null}function MC(t,e,n,r){let i=r.style(n.occurrenceId)?.cascadedValues["white-space"]?r.value(n.occurrenceId,"white-space"):null;return i==="pre"||i==="pre-wrap"||i==="pre-line"?{mode:"preserve-newlines",authored:i}:EC(t,e)==="preserve"?{mode:"preserve-spaces",authored:null}:{mode:"collapse",authored:i==="normal"?"normal":null}}function oo(t,e){return e==="preserve-newlines"?t.replace(/\r\n?/g,`
10
+ `):e==="preserve-spaces"?t.replace(/\r?\n[ \t\r]*/g,""):t.replace(/[ \t\r\n]+/g," ")}function so(t,e){return t.children.map(n=>n.kind==="text"||n.kind==="cdata"?oo(n.value,e):n.kind==="element"?so(n,e):"").join("")}function OC(t,e,n){let r=[],i="";for(let o of t.children){if(o.kind==="comment")continue;if(o.kind==="text"||o.kind==="cdata"){let l=oo(o.value,n);if(n==="collapse"&&(l!==l.trim()||/ {2,}/u.test(l)))return;i+=l;continue}if(o.kind!=="element"||o.localName.toLowerCase()!=="tspan"||!C(o,"id")||o.attributes.some(l=>!(l.namespaceUri===null&&l.localName==="id"))||o.children.some(l=>l.kind==="element"))return;let a=oo(so(o,n),n);if(n==="collapse"&&(a!==a.trim()||/ {2,}/u.test(a)))return;let c=i.length;i+=a,r.push({start:c,end:i.length,sourceNodeId:o.sourceNodeId})}return r.length>0&&i===e?{text:e,spans:r}:void 0}function DC(t,e,n){let r=e;for(;r&&r.sourceNodeId!==t.root.sourceNodeId;){if(r.localName.toLowerCase()==="svg"){let i=nt(C(r,"viewBox")??"");if(i&&i.width>0&&i.height>0)return{width:i.width,height:i.height}}r=t.index.parent(r.sourceNodeId)}return n.viewport}function mm(t,e,n){return t.attributes.find(r=>r.prefix===e&&r.localName===n)?.value??null}function vt(t,e,n,r,i,o=r*.5){let s=ci(t).at(0);if(s)return rr(s,{percentBasis:e==="x"?n.width:n.height,viewportWidth:n.width,viewportHeight:n.height,fontSize:r,rootFontSize:i,xHeight:o})}function zC(t,e,n,r,i,o){let s=t.children.filter(b=>b.kind==="element"&&b.localName.toLowerCase()==="tspan"),a=b=>oo(b,e);if(s.length===0){let b=a(so(t,e));e==="collapse"&&(b=b.replace(/ {2,}/g," ").replace(/^ +| +$/g,""));let v=b.split(`
11
+ `).map(I=>({text:I,x:0,dy:0}));return{text:b,lines:v,linePositions:null}}let c=.001,l=vt(C(t,"x"),"x",n,r,i,o)??0,d=vt(C(t,"y"),"y",n,r,i,o)??null,u=[],p=!1,f=(b,v)=>{if(e!=="collapse")return b;let I=b.replace(/ {2,}/g," ");return v&&(I=I.replace(/^ +/,"")),I.replace(/ +$/,"")},m=(b,v,I,x)=>{if(!b)return;let k=I===null?0:(vt(I,"x",n,r,i,o)??l)-l,T=e==="preserve-newlines"?b.split(`
12
+ `):[b];for(let w=0;w<T.length;w++){let P=T[w],N=w>0,R=w===0&&v||N;!P&&!N||(R&&p?u.push({text:P,x:w===0?k:0,dy:w===0?x:0}):p?u[u.length-1].text+=P:u.push({text:P,x:w===0?k:0,dy:0}),P&&(p=!0))}},g=b=>{let v=C(b,"x");if(mm(b,"sodipodi","role")==="line"){let T=vt(C(b,"y"),"y",n,r,i,o),w=T!==void 0&&d!==null&&Math.abs(T-d)>.5?T-d:0;return{brk:!0,x:v,dy:w}}let x=C(b,"dy");if(x!==null){let T=vt(x,"y",n,r,i,o)??0;if(T>c||T<-c&&v!==null)return{brk:!0,x:v,dy:T}}let k=vt(C(b,"y"),"y",n,r,i,o);if(k!==void 0&&d!==null&&Math.abs(k-d)>.5)return{brk:!0,x:v,dy:k-d};if(v!==null&&p){let T=vt(v,"x",n,r,i,o);if(T!==void 0&&T<=l+.5)return{brk:!0,x:v,dy:0}}return{brk:!1,x:null,dy:0}},h=(b,v)=>{let I=!1;for(let x of b.children){if(x.kind==="text"||x.kind==="cdata"){let N=a(x.value);if(!N)continue;if(e!=="preserve-newlines"&&/^ +$/.test(N)){if(p&&u.length>0){let $=u[u.length-1].text;e==="collapse"?$.endsWith(" ")||(u[u.length-1].text+=" "):u[u.length-1].text+=N}continue}let R=v.active&&!I;m(N,R,R?v.x:null,R?v.dy:0),I=!0;continue}if(x.kind!=="element"||x.localName.toLowerCase()!=="tspan")continue;let k=g(x),T=vt(C(x,"y"),"y",n,r,i,o);T!==void 0&&(d=T);let w={active:v.active&&!I||k.brk,x:k.brk?k.x:v.active&&!I?v.x:null,dy:k.brk?k.dy:v.active&&!I?v.dy:0};x.children.some(N=>N.kind==="element"&&N.localName.toLowerCase()==="tspan")?h(x,w):m(a(so(x,e)),w.active,w.x,w.dy),I=!0}};h(t,{active:!1,x:null,dy:0});for(let b=0;b<u.length;b++)u[b].text=f(u[b].text,b===0);let y=u.some((b,v)=>v>0&&Math.abs(b.dy)>c||Math.abs(b.x)>c)?u.map(b=>({x:b.x,dy:b.dy})):null;return{text:u.map(b=>b.text).join(`
13
+ `),lines:u,linePositions:y}}function nv(t){return t&&t.split(",").map(n=>n.trim().replace(/^['"]|['"]$/g,"").trim()).filter(Boolean).join(", ")||null}function _C(t,e,n,r,i,o){let s=io(t,e,n,"font-size"),a=Ut(s);return a!==void 0&&a>=0?a:r}function Jb(t,e,n,r){let i=n;for(;i;){if(t.style(i.occurrenceId)?.cascadedValues[r])return!0;i=i.parentOccurrenceId?e.occurrence(i.parentOccurrenceId)??void 0:void 0}return!1}function io(t,e,n,r){let i=C(n,r),o=t.style(e.occurrenceId),s=o?.cascadedValues[r];return s?o?.specifiedValues[r]??s.value:i!==null?i:o?.resolvedValues[r]??null}function rv(t){if(!t)return 400;if(t==="normal"||t==="bold")return t;let e=Number(t);return Number.isFinite(e)?e:400}function FC(t){let e=rv(t);return e===400||e==="normal"?"normal":e===700||e==="bold"?"bold":e}function Qb(t,e,n){let r=w=>e?t.value(e.occurrenceId,w):null,i=r("text-decoration")?.toLowerCase()??"",o=nv(r("font-family"))??"Arial",s=r("font-style"),a=s==="italic"||s==="oblique"?s:"normal",c=r("line-height"),l=c?Number(c):NaN,d=r("fill"),u=(w,P)=>Ut(r(w))??P,p=r("font-variant")??"",f=r("baseline-shift"),m=f?Ut(f):void 0,g=f==="baseline"||f==="super"||f==="sub"?f:m??"baseline",h=r("dominant-baseline"),y=new Set(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),b=r("writing-mode"),v=b==="tb"||b==="tb-rl"?"vertical-rl":b==="lr"||b==="lr-tb"||b==="rl"||b==="rl-tb"?"horizontal-tb":b,I=r("direction"),x=r("unicode-bidi"),k=r("text-anchor"),T=r("text-transform");return{...Qr,textDecoration:{underline:i.includes("underline"),strikethrough:i.includes("line-through"),overline:i.includes("overline")},fontVariationSettings:{},fontFamily:o,fontSize:n,fontWeight:FC(r("font-weight")),fontStyle:a,fontVariant:p,fontVariantLigatures:r("font-variant-ligatures")??"",fontVariantPosition:r("font-variant-position")??"",fontVariantCaps:r("font-variant-caps")??"",fontVariantNumeric:r("font-variant-numeric")??"",fontVariantEastAsian:r("font-variant-east-asian")??"",fill:!d||d.toLowerCase()==="black"?"#000000":d,stroke:r("stroke")??"none",lineHeight:Number.isFinite(l)?l:1.2,textTransform:T==="capitalize"||T==="uppercase"||T==="lowercase"?T:"none",baselineShift:g,dominantBaseline:y.has(h)?h:"auto",writingMode:v==="vertical-rl"||v==="vertical-lr"?v:"horizontal-tb",whiteSpace:r("white-space")==="pre"||r("white-space")==="pre-wrap"||r("white-space")==="pre-line"||r("white-space")==="nowrap"||r("white-space")==="break-spaces"?r("white-space"):"normal",direction:I==="rtl"?"rtl":"ltr",unicodeBidi:x==="embed"||x==="bidi-override"||x==="isolate"||x==="isolate-override"||x==="plaintext"?x:"normal",textAnchor:k==="middle"||k==="end"?k:"start",letterSpacing:u("letter-spacing",0),wordSpacing:u("word-spacing",0),fillOpacity:Number(r("fill-opacity")??1),strokeWidth:u("stroke-width",0),strokeOpacity:Number(r("stroke-opacity")??1)}}function LC(t,e,n,r,i,o){let s=t.style(e.occurrenceId)?.cascadedValues["font-size"];if(!s)return n;let a=s.value.trim().toLowerCase();if(a==="inherit"||a==="unset")return n;if(a==="initial"||a==="revert"||a==="revert-layer"||a==="medium")return o;let c=t.value(e.occurrenceId,"font-size"),l=Pe(c,{percentBasis:n,viewportWidth:i.width,viewportHeight:i.height,fontSize:n,rootFontSize:o,xHeight:r});return l!==void 0&&l>=0?l:n}function BC(t,e,n,r,i){let o=i?.measureXHeight(t.fontFamily,e);return o!==void 0&&Number.isFinite(o)&&o>=0?o:n>0?r*(e/n):e*.5}function GC(t){return fm(t).filter(e=>e.localName.toLowerCase()==="tspan"&&!e.children.some(n=>n.kind==="element"&&n.localName.toLowerCase()==="tspan"))}function Wl(t,e,n,r,i,o){return t?ci(t).map(s=>({value:rr(s,{percentBasis:e==="x"?n.width:n.height,viewportWidth:n.width,viewportHeight:n.height,fontSize:r,rootFontSize:i,xHeight:o})??null,raw:s.unit===""||s.unit==="px"?null:`${s.value}${s.unit}`})):[]}function VC(t){if(!t)return[];let e=t.trim().split(/[\s,]+/).filter(Boolean),n=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;return e.every(r=>n.test(r))?e.map(Number):[]}function jC(t,e,n,r,i,o,s){let a=GC(t),c=a.length>0?a:[t],l=Array.from(e,()=>({x:null,y:null,dx:0,dy:0,rotate:0})),d=0,u=!1;for(let p of c){let f=oo(so(p,n),n),m=a.length>0?Math.max(d,e.indexOf(f,d)):0,g=Wl(C(p,"dx"),"x",r,i,o,s),h=Wl(C(p,"dy"),"y",r,i,o,s),y=Wl(C(p,"x"),"x",r,i,o,s),b=Wl(C(p,"y"),"y",r,i,o,s),v=VC(C(p,"rotate")),I=v.at(-1)??0,x=g.length>1||h.length>1||y.length>1||b.length>1||v.length>1,k=mm(p,"sodipodi","role")==="line",T=h[0]?.value,w=a.length>0&&!x&&(k||T!=null&&(T>.001||T<-.001&&C(p,"x")!==null));for(let P=0;P<f.length&&m+P<l.length;P++){let N=l[m+P],R=a.length===0,$=w?null:R?P>0?y[P]?.value??null:null:x?y[P]?.value??null:P===0?y[0]?.value??null:null,A=w?null:R?P>0?b[P]?.value??null:null:x?b[P]?.value??null:P===0?b[0]?.value??null:null,O=w?0:x?g[P]?.value??0:P===0?g[0]?.value??0:0,G=w?0:x?h[P]?.value??0:P===0?h[0]?.value??0:0,M=v[P]??I;Object.assign(N,{x:$,y:A,dx:O,dy:G,rotate:M});let V={},X=R&&P===0?null:x?y[P]?.raw:P===0?y[0]?.raw:null,Y=R&&P===0?null:x?b[P]?.raw:P===0?b[0]?.raw:null,U=x?g[P]?.raw:P===0?g[0]?.raw:null,te=x?h[P]?.raw:P===0?h[0]?.raw:null;!w&&X&&(V.x=X),!w&&Y&&(V.y=Y),!w&&U&&(V.dx=U),!w&&te&&(V.dy=te),Object.keys(V).length>0&&(N.raw=V),($!==null||A!==null||O!==0||G!==0||M!==0)&&(u=!0)}d=Math.max(d,m+f.length)}return u?l:null}function UC(t,e,n){let r=e.children.find(g=>g.kind==="element"&&g.localName.toLowerCase()==="textpath");if(!r)return{isTextPath:!1};let i={isTextPath:!1},o=C(r,"side");o==="right"&&(i.textPathSide=o);let s=C(r,"method");(s==="align"||s==="stretch")&&(i.textPathMethod=s);let a=C(r,"spacing");(a==="auto"||a==="exact")&&(i.textPathSpacing=a);let c=C(r,"startOffset");if(c){let g=Number.parseFloat(c);Number.isFinite(g)&&(i.textPathStartOffset=g,i.textPathStartOffsetUnit=c.trim().endsWith("%")?"%":"user")}let l=C(r,"lengthAdjust");(l==="spacing"||l==="spacingAndGlyphs")&&(i.textPathLengthAdjust=l);let d=C(r,"textLength");if(d){let g=Number.parseFloat(d);Number.isFinite(g)&&g>=0&&(i.textPathLength=g,i.textPathLengthUnit=d.trim().endsWith("%")?"%":"user")}let u=C(r,"path");u&&(i.textPathInlineFormat="path-attr");let p=null;if(!u){let g=Le(r)?.value;if(!g){let h=r.children.find(y=>y.kind==="element"&&y.localName.toLowerCase()==="mpath");g=h?Le(h)?.value:void 0}if(g?.startsWith("#")){i.textPathImportRefId=g.slice(1);let h=t.index.resolveAuthoredId(g.slice(1));p=h?t.index.element(h.sourceNodeId):null,u=p?C(p,"d"):null}}if(!u)return i;let f=ev(kn(u).commands);if(f.points.length<2)return i;i.isTextPath=!0,i.textPathPoints=f.points;let m=Hs(p?C(p,"pathLength"):null);return m!==void 0&&m>=0&&(i.textPathPathLength=m),i.x=-n/2,i.y=-n/2,i}function HC(t,e,n,r,i,o,s,a,c,l,d,u){if(!t.children.some(w=>w.kind==="element"&&w.localName.toLowerCase()==="tspan"))return null;let f=Qb(r,e,s),m=[{segments:[]}],g=!1,h=!1,y=vt(C(t,"y"),"y",c,s,l,d)??null,b=vt(C(t,"x"),"x",c,s,l,d)??0,v=w=>oo(w,o),I=(w,P,N)=>{if(!w)return;let R=o==="preserve-newlines"?w.split(`
14
+ `):[w];for(let $=0;$<R.length;$++){let A=R[$],O=$>0;if(!A&&!O)continue;let G={text:A,style:Fi(f,P)};($===0&&N||O)&&g?m.push({segments:[G]}):m[m.length-1].segments.push(G),A&&(g=!0),Zn(P,f)||(h=!0)}},x=(w,P,N)=>{if(mm(w,"sodipodi","role")==="line")return!0;let R=C(w,"x"),$=C(w,"dy");if($!==null){let O=vt($,"y",c,P,l,N)??0;if(O>.001||O<-.001&&R!==null)return!0}let A=vt(C(w,"y"),"y",c,P,l,N);if(A!==void 0&&y!==null&&Math.abs(A-y)>.5)return!0;if(R!==null&&g){let O=vt(R,"x",c,P,l,N);if(O!==void 0&&O<=b+.5)return!0}return!1},k=(w,P,N,R,$)=>{let A=!1;for(let O of w.children){if(O.kind==="text"||O.kind==="cdata"){let ne=v(O.value);if(!ne)continue;if(o!=="preserve-newlines"&&/^ +$/.test(ne)){if(g){let F=m.at(-1)?.segments.at(-1);F&&(o==="collapse"?F.text.endsWith(" ")||(F.text+=" "):F.text+=ne)}continue}I(ne,P,N&&!A),A=!0;continue}if(O.kind!=="element"||O.localName.toLowerCase()!=="tspan")continue;let G=AC(n,e,O.sourceNodeId),M=G?LC(r,G,R,$,c,l):R,V=G?Qb(r,G,M):P,X=BC(V,M,R,$,u),Y=x(O,M,X),U=vt(C(O,"y"),"y",c,M,l,X);U!==void 0&&(y=U);let te=N&&!A||Y;O.children.some(ne=>ne.kind==="element"&&ne.localName.toLowerCase()==="tspan")?k(O,V,te,M,X):I(v(so(O,o)),V,te),A=!0}};if(k(t,f,!1,s,d),o==="collapse")for(let w=0;w<m.length;w++){let P=m[w],N=!1;for(let $ of P.segments)$.text=$.text.replace(/ {2,}/g," "),N&&$.text.startsWith(" ")&&($.text=$.text.slice(1)),N=$.text.endsWith(" ");if(w===0){let $=P.segments.find(A=>A.text.length>0);$&&($.text=$.text.replace(/^ +/,""))}let R=[...P.segments].reverse().find($=>$.text.length>0);R&&(R.text=R.text.replace(/ +$/,"")),P.segments=P.segments.filter($=>$.text.length>0)}return!h||m.map(w=>w.segments.map(P=>P.text).join("")).join(`
15
+ `)!==i?null:{lines:m,baseStyle:f,lineHeight:a}}function fm(t){let e=[],n=r=>{for(let i of r)i.kind==="element"&&(e.push(i),n(i.children))};return n(t.children),e}function WC(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){if(n.localName.toLowerCase()==="flowroot")return!0;n=t.index.parent(n.sourceNodeId)}return!1}var KC=[["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 XC(t,e,n){let r={},i=T=>io(t,e,n,T);for(let[T,w]of KC){let P=i(w);P&&P.trim()&&(r[T]=P.trim())}let o=i("text-decoration")??i("text-decoration-line");if(o&&o!=="none"){let T=o.toLowerCase();r.textDecoration={underline:T.includes("underline"),strikethrough:T.includes("line-through"),overline:T.includes("overline")}}let s=i("text-anchor"),a=i("text-align");s==="middle"||s==="end"?r.textAnchor=s:a==="center"?r.textAnchor="middle":a==="end"||a==="right"?r.textAnchor="end":(a==="justify"||s==="start")&&(r.textAnchor="start");let c=T=>{let w=i(T);if(w!=="normal")return Ut(w)},l=c("letter-spacing");l!==void 0&&(r.letterSpacing=l);let d=c("word-spacing");d!==void 0&&(r.wordSpacing=d);let u=i("text-transform");u&&(r.textTransform=u.trim());let p=i("baseline-shift");p&&(r.baselineShift=p.trim());let f=i("dominant-baseline");f&&(r.dominantBaseline=f.trim());let m=i("writing-mode");m&&(r.writingMode=m==="tb"||m==="tb-rl"?"vertical-rl":m==="vertical-lr"?"vertical-lr":"horizontal-tb");let g=Number.parseFloat(i("inline-size")??"");Number.isFinite(g)&&g>0&&(r.inlineSize=g);let y=i("shape-inside")?.match(/url\(\s*#([^)]+)\s*\)/)?.[1];y&&(r.shapeInsideImportRefId=y);let b=Number.parseFloat(i("shape-padding")??"");Number.isFinite(b)&&b>0&&(r.shapePadding=b);let v=i("overflow-wrap");(v==="break-word"||v==="anywhere")&&(r.overflowWrap=v);let I=i("direction");(I==="ltr"||I==="rtl")&&(r.textDirection=I);let x=i("unicode-bidi");(x==="normal"||x==="embed"||x==="bidi-override"||x==="isolate"||x==="isolate-override"||x==="plaintext")&&(r.unicodeBidi=x);let k=i("font-variation-settings");if(k&&k!=="normal"){let T={};for(let w of k.split(",")){let P=w.trim().match(/^['"](\w{4})['"]\s+([\d.eE+-]+)$/);if(!P)continue;let N=Number(P[2]);Number.isFinite(N)&&(T[P[1]]=N)}Object.keys(T).length>0&&(r.fontVariationSettings=T)}return r}function YC(t,e,n,r,i,o,s){let a=n.localName.toLowerCase(),c=TC(i,e,o),l=(m,g)=>dm(i,e,n,m,g,c,o),d=m=>{s.push(PC(t,e,n,o,m))},u=CC(n),p=Hs(C(n,"pathLength")),f=m=>(p===void 0||(p<0?d("Path length must not be negative."):m.pathLength=p),m);if(a==="rect"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x")??0,y=l("height","y")??0;if(h<0||y<0)return d("Rectangle width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let b=l("rx","x"),v=l("ry","y");(b!==void 0&&b<0||v!==void 0&&v<0)&&d("Rectangle corner radii must not be negative.");let I=b!==void 0&&b>=0,x=v!==void 0&&v>=0,k=Math.min(I?b:x?v:0,h/2),T=Math.min(x?v:I?b:0,y/2),w=f({x:m,y:g,width:h,height:y,rx:k,ry:T,cornerRadius:0});(k>0||T>0)&&Math.abs(k-T)<=1e-6&&(w.cornerRadius=k),Object.assign(w,u);let P=n.children.some(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&["x","y","width","height","rx","ry"].includes(C(R,"attributeName")??"")),N=Math.abs(h-y)<=1e-6&&Math.abs(k-T)<=1e-6&&!P?"square":"rectangle";return Ge(e,n,N,"materialized",w)}if(a==="circle"){let m=l("cx","x")??0,g=l("cy","y")??0,h=l("r","radius")??0;return h<0?(d("Circle radius must not be negative."),Ge(e,n,null,"invalid")):h===0?Ge(e,n,null,"empty"):Ge(e,n,"circle","materialized",f({x:m,y:g,radius:h,...u}))}if(a==="ellipse"){let m=l("cx","x")??0,g=l("cy","y")??0,h=l("rx","x"),y=l("ry","y");(h!==void 0&&h<0||y!==void 0&&y<0)&&d("Ellipse radii must not be negative.");let b=h!==void 0&&h>=0,v=y!==void 0&&y>=0,I=b?h:v?y:0,x=v?y:b?h:0;return I===0||x===0?Ge(e,n,null,"empty"):Math.abs(I-x)<=1e-6?Ge(e,n,"circle","materialized",f({x:m,y:g,radius:I,...u})):Ge(e,n,"ellipse","materialized",f({x:m,y:g,rx:I,ry:x,...u}))}if(a==="line"){let m={x1:l("x1","x")??0,y1:l("y1","y")??0,x2:l("x2","x")??0,y2:l("y2","y")??0};return f(m),Object.assign(m,u),Ge(e,n,"line","materialized",m)}if(a==="polyline"||a==="polygon"){let m=RC(C(n,"points"));if(m.odd&&d("The final unpaired polygon coordinate was ignored."),m.points.length===0)return Ge(e,n,"polyline","materialized",f({x:0,y:0,width:0,height:0,polylinePoints:[],polylineClosed:a==="polygon",...u}));let g=m.points.map(v=>v.x),h=m.points.map(v=>v.y),y=Math.min(...g),b=Math.min(...h);return Ge(e,n,"polyline","materialized",f({x:y,y:b,width:Math.max(...g)-y,height:Math.max(...h)-b,polylinePoints:m.points,polylineClosed:a==="polygon",...u}))}if(a==="path"){let m=Mr(i,e,n,"d")??"",g=/^path\(\s*(["'])([\s\S]*)\1\s*\)$/i.exec(m.trim()),h=g?g[2]:m;if(!h||h.trim().toLowerCase()==="none"){let N=n.children.find(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&C(R,"attributeName")==="d");N&&(h=C(N,"from")??C(N,"to")??"")}let y=kn(h);y.error&&d(`Invalid path data: ${y.error.message}.`);let b=ev(y.commands),v=["marker","marker-start","marker-mid","marker-end"].some(N=>{let R=Mr(i,e,n,N)?.trim().toLowerCase();return R!=null&&R!==""&&R!=="none"}),I=Mr(i,e,n,"stroke-linecap")?.trim(),x=Mr(i,e,n,"stroke")?.trim().toLowerCase(),k=dm(i,e,n,"stroke-width","radius",c,o),T=(I==="round"||I==="square")&&x!==void 0&&x!==null&&x!==""&&x!=="none"&&(k??1)>0;if(!b.drawn&&!(b.points.length>0&&(v||T)))return Ge(e,n,null,"empty");let w=fn(h);if(!w)return Ge(e,n,null,"empty");let P={x:w.minX,y:w.minY,width:w.maxX-w.minX,height:w.maxY-w.minY};return f(P),P.pathPoints=b.points,P.pathClosed=b.closed,P.pathCurveType=b.points.some(N=>N.segmentType)?"mixed":b.points.some(N=>N.handleIn||N.handleOut)?"cubic":"linear",P.pathTension=.5,Object.assign(P,u),Ge(e,n,"path","materialized",P)}if(a==="text"){let m=DC(t,n,o),g=MC(t,n,e,i),h=_C(i,e,n,c,m,o.rootFontSize),y=Jb(i,r,e,"font-family")?nv(io(i,e,n,"font-family"))??"Inter, sans-serif":"Inter, sans-serif",b=o.textMetricsHost?.measureXHeight(y,h),v=b!==void 0&&Number.isFinite(b)&&b>=0?b:h*.5,I=zC(n,g.mode,m,h,o.rootFontSize,v),x=I.text,k=Jb(i,r,e,"font-weight")?rv(io(i,e,n,"font-weight")):400,T=io(i,e,n,"font-style")??"normal",w=io(i,e,n,"line-height"),P=w?Ut(w)??Number(w):NaN,N=Number.isFinite(P)?P:1.2,R=vt(pm(Mr(i,e,n,"x")),"x",m,h,o.rootFontSize,v)??0,$=vt(pm(Mr(i,e,n,"y")),"y",m,h,o.rootFontSize,v)??0,A={};for(let[U,te]of[["x",R],["y",$]]){let Z=C(n,U),ne=Mr(i,e,n,U),F=ci(Z);if(Z===null||ne?.trim()!==Z.trim()||F.length!==1)continue;vt(Z,U,m,h,o.rootFontSize,v)===te&&(A[U]={raw:Z,resolved:te})}let O={x:R,y:$,textX:R,textY:$,text:x,fontSize:h,fontFamily:y,fontWeight:k,fontStyle:T,lineHeight:N,useRichText:!1,isTextPath:!1};Object.keys(A).length>0&&(O.authoredTextPosition=A),Object.assign(O,XC(i,e,n)),I.linePositions&&(O.linePositions=I.linePositions),g.authored&&g.authored!=="normal"&&(O.whiteSpace=g.authored);let G=jC(n,x,g.mode,m,h,o.rootFontSize,v);G&&(O.charOffsets=G);let M=G?null:HC(n,e,r,i,x,g.mode,h,N,m,o.rootFontSize,v,o.textMetricsHost);M&&(O.useRichText=!0,O.richTextRuns=Jn(M));let V=!G&&!M&&!I.linePositions?OC(n,x,g.mode):void 0,X=dm(i,e,n,"textLength","x",c,o);X!==void 0&&X>=0&&(O.textLength=X);let Y=C(n,"lengthAdjust");return(Y==="spacing"||Y==="spacingAndGlyphs")&&(O.lengthAdjust=Y),Object.assign(O,UC(t,n,h)),Object.assign(O,u),Ge(e,n,"text","materialized",O,V)}if(a==="flowroot"){let m=fm(n).filter(b=>b.localName.toLowerCase()==="flowpara").map(tv);if(m.every(b=>b.length===0))return Ge(e,n,null,"empty");let g=fm(n).find(b=>["rect","circle","ellipse","path"].includes(b.localName.toLowerCase())),h=0,y=0;return g?.localName.toLowerCase()==="rect"&&(h=Pe(C(g,"x"),um("x",c,o))??0,y=Pe(C(g,"y"),um("y",c,o))??0),Ge(e,n,"text","materialized",{x:h,y:y+c,text:m.join(`
16
+ `),fontSize:c,fontFamily:"Inter, sans-serif",fontWeight:400,fontStyle:"normal",lineHeight:1.2,useRichText:!1,isTextPath:!1,...u})}if(a==="image"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x"),y=l("height","y"),b=Le(n)?.value??"";if(!b||h===void 0||y===void 0)return Ge(e,n,null,"empty");if(h<0||y<0)return d("Image width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let v={x:m,y:g,width:h,height:y,...u};v.preserveAspectRatio=C(n,"data-preserve-aspect-ratio")!=="false";let I=C(n,"preserveAspectRatio")?.trim();return I&&I!=="none"&&(v.specPreserveAspectRatio=I),v.href=b,Ge(e,n,"image","materialized",v)}if(a==="foreignobject"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x")??0,y=l("height","y")??0;if(h<0||y<0)return d("Foreign-object width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let b=C(n,"data-shape-type")??C(n,"data-media-kind"),v=b==="audio"||b==="video"?b:null;if(v){let w=n.children.find(O=>O.kind==="element"&&O.localName.toLowerCase()===v),P={x:m,y:g,width:h,height:y,mediaKind:v,href:w?C(w,"src")??"":"",...u},N=[["begin","data-begin"],["trimStart","data-trim-start"],["trimEnd","data-trim-end"],["volume","data-volume"],["playbackRate","data-playback-rate"],["naturalDuration","data-natural-duration"],["originalWidth","data-media-original-width"],["originalHeight","data-media-original-height"],["fadeInDuration","data-fade-in"],["fadeOutDuration","data-fade-out"]];for(let[O,G]of N){let M=Hs(C(n,G));M!==void 0&&(P[O]=M)}if(P.originalWidth===void 0){let O=Hs(C(n,"data-original-width"));O!==void 0&&(P.originalWidth=O)}if(P.originalHeight===void 0){let O=Hs(C(n,"data-original-height"));O!==void 0&&(P.originalHeight=O)}let R=w?C(w,"type"):null;R&&(P.mediaMimeType=R);let $=C(n,"data-poster")??(v==="video"&&w?C(w,"poster"):null);$&&(P.posterHref=$);let A=(C(n,"data-source-rect")??"").trim().split(/[\s,]+/u).map(Number);return A.length===4&&A.every(Number.isFinite)&&(P.sourceRect={x:A[0],y:A[1],width:A[2],height:A[3]}),C(n,"data-loop")==="true"&&(P.loop=!0),C(n,"data-muted")==="true"&&(P.muted=!0),Ge(e,n,v,"materialized",P)}let I=n.rawXml??"",x=I.indexOf(">"),k=I.lastIndexOf("</"),T=x>=0&&k>x?I.slice(x+1,k):"";return Ge(e,n,"foreign-object","materialized",{x:m,y:g,width:h,height:y,rawContent:T,...u})}return Ge(e,n,null,"deferred")}function Xl(t,e,n,r){let i=[],o=[],s=new Set,a=[...e.occurrences].sort(kC);for(let d of a){if(s.has(d.occurrenceId))throw new Error(`Duplicate SVG geometry occurrence ${d.occurrenceId}.`);s.add(d.occurrenceId);let u=t.index.element(d.correspondingSourceNodeId);if(!u)throw new Error(`SVG occurrence ${d.occurrenceId} has no source element.`);if(!(u.namespaceUri===K||t.root.namespaceUri===null&&u.namespaceUri===null))continue;let f=u.localName.toLowerCase();vC.has(f)&&(f!=="flowroot"&&WC(t,u)||o.push(YC(t,d,u,e,n,r,i)))}let c=new Map(o.map(d=>[d.occurrenceId,d])),l=Object.freeze({candidates:Object.freeze(o),candidate(d){return c.get(d)??null}});return Object.freeze({value:l,diagnostics:Object.freeze(i)})}var iv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function ao(t){let e=iv[t.trim().toLowerCase()];return e===void 0?null:{r:e>>16&255,g:e>>8&255,b:e&255}}function Yl(t){return iv[t.trim().toLowerCase()]!==void 0}var Zl={color:"css-rgba",angle:"linear"},Ws={color:"opaque-rgb",angle:"shortest-arc"};function Ee(t,e,n){return t+(e-t)*n}function hm(t,e,n,r){if(r==="linear")return Ee(t,e,n);let i=((e-t)%360+540)%360-180;return t+i*n}function qC(t){let e=t.trim().toLowerCase();if(e==="transparent"||e==="none")return{r:0,g:0,b:0,a:0};if(t.startsWith("#")){let i=t.slice(1);if(i.length===3)return{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:1};if(i.length===6)return{r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16),a:1};if(i.length===8)return{r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16),a:parseInt(i.slice(6,8),16)/255}}let n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?/);if(n)return{r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10),a:n[4]!==void 0?parseFloat(n[4]):1};let r=ao(e);return r?{...r,a:1}:null}function dv(t){if(!t)return null;let e=t.trim();if(e.startsWith("#")){if(e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1};if(e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}}let n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return n?{r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10),a:1}:null}function Ks(t,e=Zl.color){return e==="css-rgba"?qC(t):dv(t)}function ZC(t,e=Zl.color){if(!t)return!1;if(e==="opaque-rgb")return dv(t)!==null;if(t.startsWith("#")||t.startsWith("rgb"))return!0;let n=t.trim().toLowerCase();return n==="transparent"||n==="none"?!0:Yl(n)}function ov(t,e,n){let r=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function ym(t,e,n,r=Zl.color){let i=Ks(t,r),o=Ks(e,r);if(!i||!o)return n<.5?t:e;if(r==="opaque-rgb")return ov(Ee(i.r,o.r,n),Ee(i.g,o.g,n),Ee(i.b,o.b,n));let s=i.a===0?o.r:i.r,a=i.a===0?o.g:i.g,c=i.a===0?o.b:i.b,l=o.a===0?i.r:o.r,d=o.a===0?i.g:o.g,u=o.a===0?i.b:o.b,p=Ee(s,l,n),f=Ee(a,d,n),m=Ee(c,u,n),g=Ee(i.a,o.a,n);return g>=.999?ov(p,f,m):`rgba(${Math.round(p)}, ${Math.round(f)}, ${Math.round(m)}, ${Math.round(g*1e3)/1e3})`}var uv="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",sv=/[MLHVCSQTAZmlhvcsqtaz]/g;function co(t){return t.match(new RegExp(uv,"g"))}function JC(t){return(co(t)??[]).map(Number)}function pv(t,e,n){let r=co(t),i=co(e);if(!r||!i||r.length!==i.length)return t;let o=r.map(Number),s=i.map(Number),a=0;return t.replace(new RegExp(uv,"g"),()=>{let c=Ee(o[a],s[a],n);return a++,String(Math.round(c*1e3)/1e3)})}function fv(t,e){let n=t.match(sv)??[],r=e.match(sv)??[];return n.length!==r.length?!1:n.every((i,o)=>i===r[o])}function QC(t,e,n){return n<=0?t:n>=1?e:fv(t,e)?pv(t,e,n):n<.5?t:e}function e$(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=co(t),i=co(e);return!r||!i||r.length!==i.length?n<.5?t:e:pv(t,e,n)}function t$(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=l=>{let d=l.trim().toLowerCase();if(!d||d==="none")return null;let u=(co(l)??[]).map(Number);return u.length===0||u.some(p=>!Number.isFinite(p)||p<0)?null:u},i=r(t),o=r(e);if(!i||!o)return n<.5?t:e;let s=(l,d)=>d===0?l:s(d,l%d),a=i.length*o.length/s(i.length,o.length),c=[];for(let l=0;l<a;l++)c.push(String(Ee(i[l%i.length],o[l%o.length],n)));return c.join(" ")}function cr(t){return Array.isArray(t)&&t.every(e=>typeof e=="number"&&Number.isFinite(e))}function ql(t,e,n){return t.map((r,i)=>Ee(r,e[i],n))}function mv(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>({x:Ee(r.x,e[i].x,n),y:Ee(r.y,e[i].y,n)}))}function gv(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>{let o=e[i],s={...r,x:Ee(r.x,o.x,n),y:Ee(r.y,o.y,n)};return r.handleIn&&o.handleIn&&(s.handleIn={x:Ee(r.handleIn.x,o.handleIn.x,n),y:Ee(r.handleIn.y,o.handleIn.y,n)}),r.handleOut&&o.handleOut&&(s.handleOut={x:Ee(r.handleOut.x,o.handleOut.x,n),y:Ee(r.handleOut.y,o.handleOut.y,n)}),s})}function hv(t,e,n,r=Ws.angle){return t.length!==e.length?n<.5?t:e:t.map((i,o)=>{let s=e[o],a={...i},c=(l,d)=>l==null||d==null?l??d??null:Ee(l,d,n);return("x"in i||"x"in s)&&(a.x=c(i.x,s.x)),("y"in i||"y"in s)&&(a.y=c(i.y,s.y)),typeof i.dx=="number"&&typeof s.dx=="number"&&(a.dx=Ee(i.dx,s.dx,n)),typeof i.dy=="number"&&typeof s.dy=="number"&&(a.dy=Ee(i.dy,s.dy,n)),typeof i.rotate=="number"&&typeof s.rotate=="number"&&(a.rotate=hm(i.rotate,s.rotate,n,r)),a})}function gm(t){if(typeof t!="object"||t===null)return!1;let e=t;return(e.type==="linear-gradient"||e.type==="radial-gradient")&&Array.isArray(e.stops)}function yv(t,e,n,r=Ws.color){if(t.type!==e.type||t.stops.length!==e.stops.length)return null;let i=t.stops.map((s,a)=>({offset:Ee(s.offset,e.stops[a].offset,n),color:ym(s.color,e.stops[a].color,n,r),opacity:Ee(s.opacity,e.stops[a].opacity,n)})),o={...t,stops:i};for(let s of Object.keys(e)){if(s==="stops"||s==="type"||s==="id"||s==="sourceId")continue;let a=t[s],c=e[s];typeof a=="number"&&typeof c=="number"&&(o[s]=Ee(a,c,n))}return o}function av(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.x!="number"||typeof e.y!="number"?!1:Object.keys(e).every(n=>n==="x"||n==="y")}function cv(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function Sv(t,e,n){let r={...t},i=new Set([...Object.keys(t),...Object.keys(e)]);for(let o of i){let s=t[o],a=e[o];typeof s=="number"&&typeof a=="number"?r[o]=Ee(s,a,n):cr(s)&&cr(a)&&s.length===a.length?r[o]=ql(s,a,n):r[o]=n<.5?s:a}return r}var n$=new Set(["fillColor","borderColor"]),r$=new Set(["polylinePoints"]),i$=new Set(["pathPoints","textPathPoints"]),o$=new Set(["rotation","shiftAngle","skewX","skewY"]),s$=new Set(["customPivot"]),lv=[1,0,0,1,0,0];function a$(t,e,n,r){if(!(s$.has(t)&&(e==null||n==null))){if(t==="children"&&Array.isArray(e)&&Array.isArray(n))return bv(e,n,r);if(t==="transformMatrix"){let i=cr(e)?e:e==null&&cr(n)?lv:null,o=cr(n)?n:n==null&&cr(e)?lv:null;if(i&&o&&i.length===o.length)return ql(i,o,r)}if(!(e==null&&n==null)){if(e==null)return n;if(n==null)return e;if(n$.has(t)&&typeof e=="string"&&typeof n=="string")return ym(e,n,r,Ws.color);if(o$.has(t)&&typeof e=="number"&&typeof n=="number")return hm(e,n,r,Ws.angle);if(typeof e=="number"&&typeof n=="number")return Ee(e,n,r);if(typeof e=="string"&&typeof n=="string"){let i=parseFloat(e),o=parseFloat(n);return Number.isFinite(i)&&Number.isFinite(o)&&String(i)===e&&String(o)===n?String(Ee(i,o,r)):r<.5?e:n}if(cr(e)&&cr(n)&&e.length===n.length)return ql(e,n,r);if(r$.has(t)&&Array.isArray(e)&&Array.isArray(n))return mv(e,n,r);if(i$.has(t)&&Array.isArray(e)&&Array.isArray(n))return gv(e,n,r);if(t==="charOffsets"&&Array.isArray(e)&&Array.isArray(n))return hv(e,n,r);if((t==="fillGradient"||t==="strokeGradient")&&gm(e)&&gm(n)){let i=yv(e,n,r);if(i)return i}return av(e)&&av(n)?{x:Ee(e.x,n.x,r),y:Ee(e.y,n.y,r)}:cv(e)&&cv(n)?Sv(e,n,r):r<.5?e:n}}}function c$(t,e,n){let r={...t},i=new Set([...Object.keys(t),...Object.keys(e)]);for(let o of i)r[o]=a$(o,t[o],e[o],n);return r}function bv(t,e,n){let r=Math.max(0,Math.min(1,n)),i=new Map(t.map(c=>[c.id,c])),o=new Map(e.map(c=>[c.id,c])),s=[],a=new Set;for(let c of e){let l=i.get(c.id);if(l&&l.type===c.type)a.add(c.id),s.push({...c,state:c$(l.state,c.state,r)});else{let d=c.state.opacity??1;s.push({...c,state:{...c.state,opacity:d*r}})}}for(let c of t){if(a.has(c.id))continue;let l=c.state.opacity??1,d=o.has(c.id)?vv(c,"__variant_from__"):c;s.push({...d,state:{...d.state,opacity:l*(1-r)}})}return s}function vv(t,e){let n=t.state.children;return{...t,id:`${e}${t.id}`,state:{...t.state,...Array.isArray(n)?{children:n.map(r=>vv(r,e))}:{}}}}function l$(t,e,n,r,i,o,s,a){if(t!=="mask"||e||n!=="userSpaceOnUse"||r.length!==1||!Et(s))return!1;let c=r[0],l=i.candidate(c.occurrenceId);if(!l||l.status!=="materialized"||l.canonicalType!=="rectangle"&&l.canonicalType!=="square")return!1;let d=l.state;if(d.transformMatrix!==void 0||d.rawTransform!==void 0)return!1;let u=Ks(o.value(c.occurrenceId,"fill")??"black");if(!u||u.r!==255||u.g!==255||u.b!==255||u.a!==1)return!1;let p=Number(o.value(c.occurrenceId,"fill-opacity")??1),f=Number(o.value(c.occurrenceId,"opacity")??1);if(p!==1||f!==1)return!1;let m=Number(d.x??0),g=Number(d.y??0),h=Number(d.width??d.size),y=Number(d.height??d.size),b=(v,I)=>Math.abs(v-I)<=1e-9;return b(m,0)&&b(g,0)&&b(h,a.viewport.width)&&b(y,a.viewport.height)}var vm=new Set(["animate","animatemotion","animatetransform","set"]),Ql=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),Iv=new Set(["a","g","switch","use"]),xm=new Set(["desc","metadata","title"]),d$=new Set([...vm,...xm,"circle","ellipse","line","path","polygon","polyline","rect","text","use"]);function Xs(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))Xs(e);return Object.freeze(t)}function wv(t){if(t.namespaceUri!==K)return null;let e=t.localName.toLowerCase();return e==="clippath"?"clip":e==="mask"?"mask":null}function Ys(t,e,n,r,i){let o=wv(e)??"clip";return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:o==="clip"?"clip-definitions":"mask-definitions",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`${e.name} ${r} value ${i} is invalid and uses its initial value.`})}function Sm(t,e,n,r,i,o){let s=C(e,i);return s===null||s===""?o:s==="userSpaceOnUse"||s==="objectBoundingBox"?s:(r.push(Ys(t,e,n,i,s)),o)}function bm(t,e,n,r,i,o,s,a,c){let l=r.value(n.occurrenceId,s)??C(e,s);if(l===null||l.trim()==="")return c;let d=l.trim();return a.includes(d)?d:(o.push(Ys(t,e,i,s,l)),c)}function u$(t,e,n,r){let i={x:C(e,"x"),y:C(e,"y"),width:C(e,"width"),height:C(e,"height")},{x:o,y:s,width:a,height:c}=i;if([o,s,a,c].every(u=>u===null))return null;let l={x:"-10%",y:"-10%",width:"120%",height:"120%"},d=Object.fromEntries(Object.entries(i).map(([u,p])=>p===null?[u,l[u]]:pt(p)?[u,p]:(r.push(Ys(t,e,n,u,p)),[u,l[u]])));return Object.freeze({x:d.x,y:d.y,width:d.width,height:d.height})}function xv(t){let e=pt(t);return!!(e&&e.value<=0)}function kv(t,e,n){let r=t.parentOccurrenceId,i=new Set;for(;r;){if(r===e.occurrenceId)return!0;if(i.has(r))return!1;i.add(r),r=n.get(r)?.parentOccurrenceId??null}return!1}function Pv(t,e,n){let r=t.index.parent(e);for(;r&&r.sourceNodeId!==n;){if(Ql.has(r.localName.toLowerCase()))return!0;r=t.index.parent(r.sourceNodeId)}return r===null}function Im(t,e,n){let r=new Map(n.map(i=>[i.occurrenceId,i]));return n.filter(i=>kv(i,e,r)?!(i.usePath.length===0&&Pv(t,i.correspondingSourceNodeId,e.correspondingSourceNodeId)):!1)}function wm(t,e,n,r){let i=t,o=new Set;for(;i&&i.occurrenceId!==e.occurrenceId;){if(o.has(i.occurrenceId)||(o.add(i.occurrenceId),r.value(i.occurrenceId,"display")==="none"))return!1;let s=r.value(i.occurrenceId,"visibility");if(s==="hidden"||s==="collapse")return!1;i=i.parentOccurrenceId?n.get(i.parentOccurrenceId):void 0}return i?.occurrenceId===e.occurrenceId}function p$(t,e,n,r,i){let o=n.occurrences,s=new Map(r.candidates.map(l=>[l.occurrenceId,l])),a=new Set(n.resolutions.map(l=>l.useOccurrenceId)),c=new Map(o.map(l=>[l.occurrenceId,l]));for(let l of Im(t,e,o)){if(!wm(l,e,c,i)){if(l.occurrenceId!==e.occurrenceId)return!0;continue}let d=t.index.element(l.correspondingSourceNodeId);if(!d)return!0;let u=d.localName.toLowerCase();if(vm.has(u)||u==="style"||u==="script"||["clip-path","mask","filter"].some(f=>(i.value(l.occurrenceId,f)??"").includes("url(")))return!0;if(xm.has(u))continue;if(Iv.has(u)){if(u!=="use")continue;return a.has(l.occurrenceId),!0}if(Ql.has(u)){if(l.usePath.length>0)return!0;continue}let p=s.get(l.occurrenceId);if(!p||p.status==="deferred")return!0}return!1}function f$(t,e,n,r,i){let o=new Map(r.candidates.map(l=>[l.occurrenceId,l])),s=new Set(n.resolutions.map(l=>l.useOccurrenceId)),a=new Map(n.occurrences.map(l=>[l.occurrenceId,l])),c=!1;for(let l of Im(t,e,n.occurrences)){if(!wm(l,e,a,i))continue;let d=t.index.element(l.correspondingSourceNodeId);if(!d)return!1;let u=d.localName.toLowerCase();if(xm.has(u))continue;if(vm.has(u)||u==="style"||u==="script"||["clip-path","mask","filter"].some(f=>(i.value(l.occurrenceId,f)??"").includes("url(")))return!1;if(u==="use"){if(l.parentOccurrenceId!==e.occurrenceId||l.usePath.length>0||C(d,"id")!==null||!s.has(l.occurrenceId))return!1;c=!0;continue}if(Iv.has(u)||Ql.has(u))return!1;let p=o.get(l.occurrenceId);if(!p||p.status!=="materialized")return!1}return c}function m$(t,e,n,r){let i=C(e,"transform");if(!i)return _e;let o=Zt(i);return o||(r.push(Ys(t,e,n,"transform",i)),_e)}function g$(t,e,n,r,i,o,s){let a=wv(e);if(!a)return null;let c=n.direct(e.sourceNodeId);if(!c)throw new Error(`SVG ${e.name} ${e.sourceNodeId} has no occurrence.`);let l=new Map(n.occurrences.map(A=>[A.occurrenceId,A])),d=i.candidates.flatMap(A=>{let O=l.get(A.occurrenceId);return!O||!kv(O,c,l)||O.usePath.length===0&&Pv(t,A.sourceNodeId,e.sourceNodeId)||!wm(O,c,l,r)?[]:A.status==="materialized"?[O]:[]}),u=a==="clip"&&n.resourcePolicy(e.sourceNodeId)?.status==="invalid",p=a==="clip"&&t.index.children(e.sourceNodeId).some(A=>!d$.has(A.localName.toLowerCase()));if(p&&s.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:o.source,entrypoint:o.entrypoint,capability:"clip-definitions",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:"A clipPath may directly contain only paths, text, basic shapes, use, animation, and descriptive elements."})),t.index.elements.some(A=>{if(A.namespaceUri!==K||A.localName.toLowerCase()!=="use")return!1;let O=t.index.parent(A.sourceNodeId);for(;O&&O.sourceNodeId!==e.sourceNodeId;){if(Ql.has(O.localName.toLowerCase()))return!1;O=t.index.parent(O.sourceNodeId)}return O?.sourceNodeId===e.sourceNodeId})&&n.resourcePolicy(e.sourceNodeId)===null)throw new Error(`SVG ${e.name} ${e.sourceNodeId} requires a matching use resource-root plan.`);let m=a==="mask"?u$(t,e,o,s):null,g=!!(m&&(xv(m.width)||xv(m.height))),h=p$(t,c,n,i,r),y=h&&!f$(t,c,n,i,r)?[]:d,b=u||p?"invalid":g||!h&&d.length===0?"empty":"materialized",v=a==="clip"?Sm(t,e,o,s,"clipPathUnits","userSpaceOnUse"):null,I=a==="clip"?bm(t,e,c,r,o,s,"clip-rule",["nonzero","evenodd"],"nonzero"):null,x=I==="evenodd"||r.style(c.occurrenceId)?.cascadedValues["clip-rule"]!==void 0?I:null,k=a==="mask"?Sm(t,e,o,s,"maskUnits","objectBoundingBox"):null,T=a==="mask"?Sm(t,e,o,s,"maskContentUnits","userSpaceOnUse"):null,w=a==="mask"?bm(t,e,c,r,o,s,"mask-type",["luminance","alpha"],"luminance"):null,P=m$(t,e,o,s),N=Xs({sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),type:a,status:b,representation:h?"raw":"decomposed",identity:l$(a,h,T,d,i,r,P,o),clipPathUnits:v,clipRule:x,maskUnits:k,maskContentUnits:T,maskType:w,region:m,geometrySourceNodeIds:Object.freeze(h?[]:d.map(A=>A.correspondingSourceNodeId)),rawDefinition:h?e.rawXml??"":null}),R=new Map,$=new Map;for(let A of Im(t,c,n.occurrences)){let O=t.index.element(A.correspondingSourceNodeId);if(O){if(!R.has(O.sourceNodeId)){let G=C(O,"transform");if(!G)R.set(O.sourceNodeId,_e);else{let M=Zt(G);M?R.set(O.sourceNodeId,M):(s.push(Ys(t,O,o,"transform",G)),R.set(O.sourceNodeId,_e))}}a==="clip"&&$.set(A.occurrenceId,bm(t,O,A,r,o,s,"clip-rule",["nonzero","evenodd"],N.clipRule??"nonzero"))}}return Object.freeze({definition:N,element:e,occurrence:c,rootTransform:P,transformBySourceNodeId:R,clipRuleByOccurrenceId:$,geometryOccurrences:Object.freeze(y)})}function h$(t){return t.edges.filter(e=>e.binding==="applied-css"&&e.participation==="consumer"&&(e.kind==="clip-path"&&e.propertyName==="clip-path"||e.kind==="mask-image"&&(e.propertyName==="mask"||e.propertyName==="mask-image")))}function y$(t,e,n){let r=t.occurrenceId??e.direct(t.fromSourceNodeId)?.occurrenceId;if(!r)return null;let i=t.propertyName==="clip-path"?"clip":"mask",o=t.targetSourceNodeId?n.get(t.targetSourceNodeId):void 0,s=t.validity==="valid"&&o?.definition.type===i&&o.definition.status!=="invalid";return Object.freeze({bindingId:`clip-mask-binding:${t.resourceReferenceId}:${r}`,resourceReferenceId:t.resourceReferenceId,consumerOccurrenceId:r,consumerSourceNodeId:t.fromSourceNodeId,propertyName:t.propertyName==="clip-path"?"clip-path":"mask",authoredValue:t.propertyValue,targetAuthoredId:t.targetAuthoredId,targetSourceNodeId:t.targetSourceNodeId,definitionSourceNodeId:s?t.targetSourceNodeId??null:null,status:s?"materialized":"invalid-reference"})}function S$(t){return ge(qe(t.x,t.y),li(t.width,t.height))}function b$(t,e){let r=(t.definition.type==="clip"?t.definition.clipPathUnits:t.definition.maskContentUnits)==="objectBoundingBox"?S$(e):_e;return ge(r,t.rootTransform)}function Jl(t,e,n,r,i){let o=n==="x"||n==="width",s=o?r.width:r.height,a=n==="x"?r.x:n==="y"?r.y:0;if(!pt(t))return null;if(e==="objectBoundingBox"){let d=Pe(t,{percentBasis:1,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return d===void 0?null:a+d*s}let l=Pe(t,{percentBasis:o?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return l===void 0?null:l}function v$(t,e,n){if(!t.region||!t.maskUnits)return null;let r=Jl(t.region.x,t.maskUnits,"x",e,n),i=Jl(t.region.y,t.maskUnits,"y",e,n),o=Jl(t.region.width,t.maskUnits,"width",e,n),s=Jl(t.region.height,t.maskUnits,"height",e,n);return r===null||i===null||o===null||s===null?null:Object.freeze({x:r,y:i,width:o,height:s})}function x$(t,e,n,r,i){let o=new Map(r.occurrences.map(u=>[u.occurrenceId,u])),s=[],a=n.parentOccurrenceId,c=new Set;for(;a&&a!==e.occurrence.occurrenceId&&!c.has(a);){c.add(a);let u=o.get(a);if(!u)break;s.push(u),a=u.parentOccurrenceId}let l=_e,d=e.definition.type==="clip"?e.definition.clipPathUnits:e.definition.maskContentUnits;for(let u of s.reverse()){let p=t.index.element(u.correspondingSourceNodeId);if(p&&(l=ge(l,e.transformBySourceNodeId.get(p.sourceNodeId)??_e),p.localName.toLowerCase()==="use")){let f=d==="objectBoundingBox"?1:i.viewport.width,m=d==="objectBoundingBox"?1:i.viewport.height,g=Pe(C(p,"x"),{percentBasis:f,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0,h=Pe(C(p,"y"),{percentBasis:m,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0;l=ge(l,qe(g,h))}}return l}function ed(t,e,n,r,i,o){let s=[],a=t.index.elements.flatMap(g=>{let h=g$(t,g,e,n,i,o,s);return h?[h]:[]}),c=new Map(a.map(g=>[g.definition.sourceNodeId,g])),l=h$(r).flatMap(g=>{let h=y$(g,e,c);return h?[h]:[]}),d=new Map;for(let g of l){let h=`${g.consumerOccurrenceId}\0${g.propertyName}`,y=d.get(h)??[];y.push(g),d.set(h,y)}let u=new Map([...d].map(([g,h])=>[g,Object.freeze(h)])),p=Object.freeze(a.map(g=>g.definition)),f=Object.freeze(l),m=Xs({definitions:p,bindings:f,definition(g){return c.get(g)?.definition??null},bindingsFor(g,h){return u.get(`${g}\0${h}`)??[]},binding(g,h,y){let b=u.get(`${g}\0${h}`)??[];return y===void 0?b[0]??null:b.find(v=>v.resourceReferenceId===y)??null},resolve(g,h){let y=g.definitionSourceNodeId?c.get(g.definitionSourceNodeId):void 0;if(!y||g.status!=="materialized")return Xs({status:"invalid-reference",contentMatrix:null,region:null,geometrySourceNodeIds:[],geometryPlacements:[],rawDefinition:null});let b=b$(y,h.consumerObjectBounds),v=(y.definition.clipPathUnits==="objectBoundingBox"||y.definition.maskContentUnits==="objectBoundingBox"||y.definition.maskUnits==="objectBoundingBox")&&(h.consumerObjectBounds.width===0||h.consumerObjectBounds.height===0),I=y.definition.status==="empty"||v,x=(I?[]:y.geometryOccurrences).map(k=>Object.freeze({occurrenceId:k.occurrenceId,sourceNodeId:k.correspondingSourceNodeId,matrix:ge(b,x$(t,y,k,e,o)),clipRule:y.definition.type==="clip"?y.clipRuleByOccurrenceId.get(k.occurrenceId)??y.definition.clipRule??"nonzero":null}));return Xs({status:I?"empty":g.status,contentMatrix:b,region:v$(y.definition,h.consumerObjectBounds,o),geometrySourceNodeIds:I?[]:y.definition.geometrySourceNodeIds,geometryPlacements:x,rawDefinition:y.definition.rawDefinition})}});return Object.freeze({value:m,diagnostics:Object.freeze(s)})}var I$=new Set(["id","viewbox","preserveaspectratio","refx","refy","markerwidth","markerheight","markerunits","orient"]),w$=new Set(["a","circle","ellipse","foreignobject","g","image","line","path","polygon","polyline","rect","svg","switch","text","use"]),k$=new Set(["animate","animatemotion","animatetransform","set"]),P$="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",T$=new RegExp(`^(${P$})(deg|grad|rad|turn)?$`,"i");function R$(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function C$(t,e){return R$(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function lo(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"markers",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Marker ${r} value ${i} ${o}.`})}function $$(t){let e=T$.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n))return null;switch((e[2]??"deg").toLowerCase()){case"deg":return n;case"grad":return n*.9;case"rad":return n*180/Math.PI;case"turn":return n*360;default:return null}}function N$(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length<1||e.length>2)return!1;let n=Ji(t);return e[0]!==n.align?!1:e.length===1||e[1]==="meet"||e[1]==="slice"}function A$(t,e){let n=C(e,"data-ssk-marker-name");if(n!==null)return n;let r=t??"marker";return r.replace(/^marker[-_]?/i,"").replace(/[-_]/g," ")||r}function E$(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&I$.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function M$(t,e,n){let r=t.parentOccurrenceId,i=new Set;for(;r;){if(r===e)return!0;if(i.has(r))return!1;i.add(r),r=n.get(r)?.parentOccurrenceId??null}return!1}function O$(t,e,n){let r=new Map(e.occurrences.map(d=>[d.occurrenceId,d])),i=e.occurrences.filter(d=>M$(d,n.occurrenceId,r)).sort(C$),o=new Set,s=[],a=[],c=d=>{let u=d.parentOccurrenceId;for(;u&&u!==n.occurrenceId&&!o.has(u);)u=r.get(u)?.parentOccurrenceId??null;return u===n.occurrenceId?null:u},l=d=>{if(d.usePath.length>0)return!1;let u=d.parentOccurrenceId;for(;u&&u!==n.occurrenceId;){let p=r.get(u);if(!p)return!1;if(t.index.element(p.correspondingSourceNodeId)?.localName.toLowerCase()==="defs")return!0;u=p.parentOccurrenceId}return!1};for(let d of i){let u=t.index.element(d.correspondingSourceNodeId);if(!u||u.namespaceUri!==K)continue;let p=u.localName.toLowerCase();if(k$.has(p)){a.push(Object.freeze({occurrenceId:d.occurrenceId,sourceNodeId:d.correspondingSourceNodeId,parentOccurrenceId:c(d),elementName:u.name,orderKey:Object.freeze([...d.orderKey])}));continue}if(!w$.has(p)||l(d))continue;let f=c(d);o.add(d.occurrenceId),s.push(Object.freeze({occurrenceId:d.occurrenceId,sourceNodeId:d.correspondingSourceNodeId,parentOccurrenceId:f,elementName:u.name,orderKey:Object.freeze([...d.orderKey])}))}return{content:Object.freeze(s),animations:Object.freeze(a)}}function td(t,e,n,r,i){let o=[],s=new Map,a=[],c=r.resources.filter(d=>d.kind==="marker").sort((d,u)=>{let p=t.index.element(d.sourceNodeId)?.elementOrder??0,f=t.index.element(u.sourceNodeId)?.elementOrder??0;return p-f});for(let d of c){let u=t.index.element(d.sourceNodeId);if(!u||u.namespaceUri!==K)continue;let p=e.occurrences.find(H=>H.correspondingSourceNodeId===d.sourceNodeId&&H.usePath.length===0);if(!p)continue;let f=C(u,"id"),m=n.style(p.occurrenceId),g=Pe(m?.resolvedValues["font-size"]??null,{fontSize:i.rootFontSize,rootFontSize:i.rootFontSize,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height}),h=g&&g>0?g:i.rootFontSize,y=C(u,"viewBox"),b=y===null?null:nt(y),v=!1,I=!1;y!==null&&(!b||b.width<0||b.height<0?(v=!0,o.push(lo(t,u,i,"viewBox",y,"is not a valid four-number viewBox with non-negative dimensions"))):(b.width===0||b.height===0)&&(I=!0));let x=C(u,"preserveAspectRatio");x!==null&&!N$(x)&&(v=!0,o.push(lo(t,u,i,"preserveAspectRatio",x,"does not match the SVG preserveAspectRatio grammar")));let k={},T=H=>{let oe=C(u,H);return oe!==null&&(k[H]=oe),oe},w=T("markerWidth"),P=T("markerHeight"),N=H=>({percentBasis:H==="width"?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,fontSize:h,rootFontSize:i.rootFontSize}),R=(H,oe,re)=>{if(oe===null)return 3;let xe=Pe(oe,N(re));return xe===void 0||xe<0?(v=!0,o.push(lo(t,u,i,H,oe,xe===void 0?"is not a resolvable length":"must not be negative")),3):(xe===0&&(I=!0),xe)},$=R("markerWidth",w,"width"),A=R("markerHeight",P,"height"),O={width:b?.width??$,height:b?.height??A},G=H=>{let oe=T(H);if(oe===null)return 0;let re=oe.trim(),xe=H==="refX"?O.width:O.height;if(H==="refX"){if(re==="left")return 0;if(re==="center")return xe/2;if(re==="right")return xe}else{if(re==="top")return 0;if(re==="center")return xe/2;if(re==="bottom")return xe}let Ze=Pe(oe,{...N(H==="refX"?"width":"height"),percentBasis:xe});return Ze!==void 0?Ze:(v=!0,o.push(lo(t,u,i,H,oe,"is not a valid marker reference length or keyword")),0)},M=G("refX"),V=G("refY"),X=T("markerUnits"),Y="strokeWidth";X==="userSpaceOnUse"?Y="userSpaceOnUse":X!==null&&X!=="strokeWidth"&&(v=!0,o.push(lo(t,u,i,"markerUnits",X,"must be strokeWidth or userSpaceOnUse")));let U=T("orient"),te=0;if(U==="auto"||U==="auto-start-reverse")te=U;else if(U!==null){let H=$$(U);H===null?(v=!0,o.push(lo(t,u,i,"orient",U,"is not an orientation keyword, number, or angle"))):te=H}let Z=C(u,"overflow"),ne=Z==="visible"||Z==="hidden"?Z:void 0,F=O$(t,e,p),j=Object.freeze({sourceNodeId:u.sourceNodeId,sourceId:f,name:A$(f,u),status:v?"invalid":I?"empty":"materialized",...y!==null?{viewBox:y}:{},...x!==null?{preserveAspectRatio:x}:{},refX:M,refY:V,markerWidth:$,markerHeight:A,markerUnits:Y,orient:te,...ne?{overflow:ne}:{},authoredGeometry:Object.freeze(k),rootAttributes:E$(u),content:F.content,animations:F.animations});s.set(j.sourceNodeId,j),a.push(j)}let l=Object.freeze({candidates:Object.freeze(a),candidate:d=>s.get(d)??null});return Object.freeze({value:l,diagnostics:Object.freeze(o)})}var Av=["x1","y1","x2","y2"],D$=["cx","cy","r","fx","fy","fr"],Tv=Object.freeze({x1:0,y1:0,x2:1,y2:0});function Js(t){return t.namespaceUri!==K?null:t.localName.toLowerCase()==="lineargradient"?"linear-gradient":t.localName.toLowerCase()==="radialgradient"?"radial-gradient":null}function Or(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"gradients",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Gradient ${r} value ${i} ${o}.`})}function z$(t,e,n){let r=[n],i=new Set([n.sourceNodeId]);for(let o of e.templateChain(n.sourceNodeId)){if(o.validity!=="valid"||!o.targetSourceNodeId||i.has(o.targetSourceNodeId))break;let s=t.index.element(o.targetSourceNodeId);if(!s||!Js(s))break;i.add(s.sourceNodeId),r.push(s)}return r}function Rv(t,e,n){for(let r of t){if(n&&Js(r)!==n)continue;let i=C(r,e);if(i!==null)return i}return null}function Cv(t,e,n){for(let r of t){if(n&&Js(r)!==n)continue;let i=C(r,e);if(i!==null)return Object.freeze({raw:i,ownerSourceNodeId:r.sourceNodeId})}return null}function _$(t,e,n,r){let i=t.direct(n.sourceNodeId);return i?e.value(i.occurrenceId,r):null}function Ev(t,e,n,r){let i=t.direct(n.sourceNodeId),o=i?e.style(i.occurrenceId):null;return o?.cascadedValues[r]?o.resolvedValues[r]??o.specifiedValues[r]??null:C(n,r)}function km(t){let e=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(%)?$/u.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?e[2]?n/100:n:null}function $v(t,e,n,r){let i=_$(t,e,n,"font-size"),o=Pe(i,{percentBasis:r.rootFontSize,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.rootFontSize,rootFontSize:r.rootFontSize});return o!==void 0&&o>0?o:r.rootFontSize}function qs(t,e,n,r){if(e==="objectBoundingBox")return km(t);let i=n==="x"?r.viewport.width:n==="y"?r.viewport.height:Math.hypot(r.viewport.width,r.viewport.height)/Math.SQRT2;return Pe(t,{percentBasis:i,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.fontSize,rootFontSize:r.rootFontSize})??null}function Zs(t){return t==="r"||t==="fr"?"radius":t.endsWith("x")||t==="x1"||t==="x2"||t==="cx"||t==="fx"?"x":"y"}function Pm(t,e){let n={};if(t.type==="linear-gradient"){for(let i of Av){let o=t.authoredGeometry[i];n[i]=o===void 0?Tv[i]:qs(o,t.gradientUnits,Zs(i),e)??Tv[i]}return Object.freeze(n)}let r=Object.freeze({cx:.5,cy:.5,r:.5,fr:0});for(let i of["cx","cy","r","fr"]){let o=t.authoredGeometry[i];n[i]=o===void 0?r[i]:qs(o,t.gradientUnits,Zs(i),e)??r[i]}for(let i of["fx","fy"]){let o=t.authoredGeometry[i],s=i==="fx"?n.cx:n.cy;n[i]=o===void 0?s:qs(o,t.gradientUnits,Zs(i),e)??s}return Object.freeze(n)}function Nv(t){return t.children.filter(e=>e.kind==="element"&&e.namespaceUri===K&&e.localName.toLowerCase()==="stop")}function F$(t,e,n,r,i,o){let s=e.find(f=>Nv(f).length>0)??null,a=s?Nv(s):[],c=[],l=0,d=e[0],u=n.direct(d.sourceNodeId),p=u?r.value(u.occurrenceId,"color"):null;for(let f of a){let m=C(f,"offset")??"0",g=km(m);g===null&&o.push(Or(t,f,i,"offset",m,"is not a number or percentage"));let h=Math.min(1,Math.max(0,g??0)),y=Math.max(l,h);l=y;let b=n.direct(f.sourceNodeId),v=b?r.style(b.occurrenceId):null,I=(v?.cascadedValues["stop-color"]?v.specifiedValues["stop-color"]??v.resolvedValues["stop-color"]:C(f,"stop-color"))??"black",x=I.trim().toLowerCase(),k=/(?:^|[^-_a-z0-9])var\(/iu.test(I),T=x==="currentcolor"?p??"black":k?I:v?.resolvedValues["stop-color"]??I,w=Ev(n,r,f,"stop-opacity")??"1",P=km(w);P===null&&o.push(Or(t,f,i,"stop-opacity",w,"is not a number or percentage"));let N=Math.min(1,Math.max(0,P??1));T.trim().toLowerCase()==="transparent"&&(T="black",N=0),c.push(Object.freeze({occurrenceId:s?.sourceNodeId===d.sourceNodeId&&b?b.occurrenceId:`gradient-stop:${u?.occurrenceId??d.sourceNodeId}:${f.sourceNodeId}`,sourceNodeId:f.sourceNodeId,correspondingSourceNodeId:f.sourceNodeId,hostGradientSourceNodeId:d.sourceNodeId,offsetAuthored:C(f,"offset"),offset:y,color:T,opacity:N}))}return Object.freeze(c)}function L$(t,e,n,r,i,o,s){let a=Js(e),c=z$(t,i,e),l=C(e,"id"),d=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,u=Rv(c,"gradientUnits"),p=!1,f="objectBoundingBox";u==="userSpaceOnUse"?f="userSpaceOnUse":u!==null&&u!=="objectBoundingBox"&&s.push(Or(t,e,o,"gradientUnits",u,"must be objectBoundingBox or userSpaceOnUse"));let m=Rv(c,"spreadMethod"),g="pad";m==="reflect"||m==="repeat"?g=m:m!==null&&m!=="pad"&&s.push(Or(t,e,o,"spreadMethod",m,"must be pad, reflect, or repeat"));let h=Ev(n,r,e,"color-interpolation"),y="sRGB";h==="auto"||h==="linearRGB"?y=h:h!==null&&h!=="sRGB"&&s.push(Or(t,e,o,"color-interpolation",h,"must be auto, sRGB, or linearRGB"));let b={},v={},I=a==="linear-gradient"?Av:D$;for(let R of I){let $=Cv(c,R,a);if(!$)continue;b[R]=$.raw;let A=qs($.raw,f,Zs(R),{viewport:o.viewport,fontSize:$v(n,r,e,o),rootFontSize:o.rootFontSize});v[R]=Object.freeze({...$,validity:A===null?"invalid":"valid"})}let x=Cv(c,"gradientTransform"),k=x?.raw??null,T=Zt(k??"");x&&(b.gradientTransform=x.raw,v.gradientTransform=Object.freeze({...x,validity:T===null?"invalid":"valid"}),T===null&&s.push(Or(t,e,o,"gradientTransform",x.raw,"does not match the SVG transform-list grammar")));for(let[R,$]of Object.entries(v))R==="gradientTransform"||$.validity==="valid"||s.push(Or(t,e,o,R,$.raw,"is not a valid gradient coordinate"));if(a==="radial-gradient")for(let R of["r","fr"]){let $=v[R];if(!$||$.validity!=="valid")continue;let A=qs($.raw,f,Zs(R),{viewport:o.viewport,fontSize:$v(n,r,e,o),rootFontSize:o.rootFontSize});A!==null&&A<0&&(p=!0,s.push(Or(t,e,o,R,$.raw,"must not be negative")))}let w=F$(t,c,n,r,o,s),P=Object.freeze(tt(T??[1,0,0,1,0,0])),N=v.gradientTransform??null;return Object.freeze({occurrenceId:d,sourceNodeId:e.sourceNodeId,sourceId:l,type:a,status:p?"invalid":w.length===0?"empty":"materialized",gradientUnits:f,spreadMethod:g,colorInterpolation:y,authoredGeometry:Object.freeze(b),geometryValues:Object.freeze(v),transform:Object.freeze({authored:N,matrix:P}),stops:w,templateSourceNodeIds:Object.freeze(c.map(R=>R.sourceNodeId))})}function B$(t,e){let n=t.edges.flatMap(r=>{if(r.binding!=="applied-css"||!r.occurrenceId||r.propertyName!=="fill"&&r.propertyName!=="stroke")return[];let i=r.targetSourceNodeId?e.get(r.targetSourceNodeId):void 0,o=_n(r.propertyValue)[r.tokenIndex],s=o?r.propertyValue.slice(o.tokenEnd).trim():"",a=o?!s||s.toLowerCase()==="none"?Object.freeze({kind:"none"}):Object.freeze({kind:"color",value:s}):Object.freeze({kind:"unresolved",authoredValue:r.propertyValue}),c=r.validity==="missing"||r.validity==="invalid-target"?"invalid-reference":i?i.status:"other-paint-server";return[Object.freeze({resourceReferenceId:r.resourceReferenceId,occurrenceId:r.occurrenceId,sourceNodeId:r.fromSourceNodeId,correspondingSourceNodeId:r.fromSourceNodeId,propertyName:r.propertyName,authoredValue:r.propertyValue,gradientSourceNodeId:i?.sourceNodeId??null,status:c,fallback:a})]});return Object.freeze(n)}function nd(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="gradient").map(u=>t.index.element(u.sourceNodeId)).filter(u=>!!(u&&Js(u))).sort((u,p)=>u.elementOrder-p.elementOrder).map(u=>L$(t,u,e,n,r,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=B$(r,a),l=new Map;for(let u of c){let p=l.get(u.occurrenceId)??[];p.push(u),l.set(u.occurrenceId,p)}for(let u of l.values())Object.freeze(u);let d=Object.freeze({candidates:Object.freeze(s),bindings:c,candidate:u=>a.get(u)??null,bindingsFor:u=>l.get(u)??Object.freeze([]),binding:(u,p,f)=>(l.get(u)??[]).find(m=>m.propertyName===p&&(f===void 0||m.resourceReferenceId===f))??null,resolveGeometry:(u,p)=>{let f=u.gradientSourceNodeId?a.get(u.gradientSourceNodeId):null;return f?Pm(f,p):null}});return Object.freeze({value:d,diagnostics:Object.freeze(o)})}var G$=["x","y","width","height"],V$=new Set(["desc","metadata","title"]),j$=new Set(["defs","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]),U$=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(%)?$/u,H$=/^(?:none|x(?:Min|Mid|Max)Y(?:Min|Mid|Max))(?:\s+(?:meet|slice))?$/u;function Mv(t){return!!(t&&t.namespaceUri===K&&t.localName.toLowerCase()==="pattern")}function Ov(t){let e=U$.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?e[2]?n/100:n:null}function W$(t){if(t===null)return Object.freeze({value:"xMidYMid meet",valid:!0});let e=t.trim().replace(/\s+/gu," "),n=H$.test(e),r=Ji(n?e:null);return Object.freeze({value:`${r.align}${r.align==="none"&&!e.includes(" ")?"":` ${r.meetOrSlice}`}`,valid:n})}function bi(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"patterns",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Pattern ${r} value ${i} ${o}.`})}function K$(t,e,n){let r=[n],i=new Set([n.sourceNodeId]);for(let o of e.templateChain(n.sourceNodeId)){if(o.validity!=="valid"||!o.targetSourceNodeId||i.has(o.targetSourceNodeId))break;let s=t.index.element(o.targetSourceNodeId);if(!Mv(s))break;i.add(s.sourceNodeId),r.push(s)}return Object.freeze(r)}function uo(t,e){for(let n of t){let r=C(n,e);if(r!==null)return Object.freeze({raw:r,ownerSourceNodeId:n.sourceNodeId})}return null}function X$(t){return t.children.filter(e=>e.kind==="element"&&!V$.has(e.localName.toLowerCase()))}function Y$(t){return t.find(e=>X$(e).length>0)??null}function q$(t,e,n){let r=t;for(;r;){if(r.occurrenceId===e)return!0;r=r.parentOccurrenceId?n.get(r.parentOccurrenceId):void 0}return!1}function Z$(t,e,n,r){let i=e;for(;i&&i.correspondingSourceNodeId!==n;){let o=t.index.element(i.correspondingSourceNodeId);if(o&&j$.has(o.localName.toLowerCase())&&!(o.localName.toLowerCase()==="symbol"&&i.usePath.length>0))return!1;i=i.parentOccurrenceId?r.get(i.parentOccurrenceId):void 0}return!!i}function J$(t,e,n,r){if(!r)return Object.freeze([]);let i=e.direct(r.sourceNodeId);if(!i)return Object.freeze([]);let o=new Map(e.occurrences.map(l=>[l.occurrenceId,l])),s=e.occurrences.filter(l=>l.occurrenceId!==i.occurrenceId&&q$(l,i.occurrenceId,o)&&Z$(t,l,r.sourceNodeId,o)),a=new Set(s.map(l=>l.occurrenceId)),c=new Map(s.map(l=>[l.occurrenceId,`pattern-content:${n.sourceNodeId}:${l.occurrenceId}`]));return Object.freeze(s.map(l=>Object.freeze({occurrenceId:c.get(l.occurrenceId),sourceOccurrenceId:l.occurrenceId,sourceNodeId:l.correspondingSourceNodeId,correspondingSourceNodeId:l.correspondingSourceNodeId,hostPatternSourceNodeId:n.sourceNodeId,parentOccurrenceId:l.parentOccurrenceId&&a.has(l.parentOccurrenceId)?c.get(l.parentOccurrenceId)??null:null,role:l.role,shadow:l.usePath.length>0,orderKey:Object.freeze([...l.orderKey])})))}function Q$(t,e,n){if(!e)return Object.freeze([]);let r=new Set(n.map(o=>o.sourceOccurrenceId)),i=new Set(n.map(o=>o.correspondingSourceNodeId));return Object.freeze(t.edges.filter(o=>o.participation==="resource-product"&&o.containingResourceSourceNodeId===e.sourceNodeId&&(o.occurrenceId!==null&&r.has(o.occurrenceId)||i.has(o.fromSourceNodeId))&&o.kind!=="pattern-template"))}function eN(t,e){if(e.length===0)return Object.freeze([]);let n=new Map(t.resources.map(r=>[r.sourceNodeId,r]));return Object.freeze(t.closureFromEdges(e).materializations.map(r=>{let i=n.get(r.sourceNodeId);return Object.freeze({sourceNodeId:r.sourceNodeId,sourceId:i?.authoredId??null,kind:i?.kind??"referenced-fragment",viaResourceReferenceId:r.viaResourceReferenceId})}))}function tN(t,e,n,r){return e==="objectBoundingBox"?Ov(t)===null?"invalid":"valid":Pe(t,{percentBasis:n==="x"?r.viewport.width:r.viewport.height,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.rootFontSize,rootFontSize:r.rootFontSize})===void 0?"invalid":"valid"}function po(t,e,n,r,i){return t===void 0?i:e==="objectBoundingBox"?Ov(t)??i:Pe(t,{percentBasis:n==="x"?r.viewport.width:r.viewport.height,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.fontSize,rootFontSize:r.rootFontSize})??i}function Tm(t,e){if(t.status!=="materialized")return null;let n=po(t.values.x?.raw,t.patternUnits,"x",e,0),r=po(t.values.y?.raw,t.patternUnits,"y",e,0),i=po(t.values.width?.raw,t.patternUnits,"x",e,0),o=po(t.values.height?.raw,t.patternUnits,"y",e,0);return t.patternUnits==="userSpaceOnUse"?Object.freeze({x:n,y:r,width:i,height:o}):Object.freeze({x:e.objectBounds.x+n*e.objectBounds.width,y:e.objectBounds.y+r*e.objectBounds.height,width:i*e.objectBounds.width,height:o*e.objectBounds.height})}function nN(t,e,n,r,i,o){let s=K$(t,r,e),a=C(e,"id"),c=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,l=uo(s,"patternUnits"),d="objectBoundingBox";l?.raw==="userSpaceOnUse"?d="userSpaceOnUse":l&&l.raw!=="objectBoundingBox"&&o.push(bi(t,e,i,"patternUnits",l.raw,"must be objectBoundingBox or userSpaceOnUse"));let u=uo(s,"patternContentUnits"),p="userSpaceOnUse";u?.raw==="objectBoundingBox"?p="objectBoundingBox":u&&u.raw!=="userSpaceOnUse"&&o.push(bi(t,e,i,"patternContentUnits",u.raw,"must be objectBoundingBox or userSpaceOnUse"));let f=!1,m={};for(let U of G$){let te=uo(s,U);if(!te)continue;let Z=tN(te.raw,d,U==="x"||U==="width"?"x":"y",i);m[U]=Object.freeze({...te,validity:Z}),Z==="invalid"&&o.push(bi(t,e,i,U,te.raw,"is not a valid pattern coordinate"))}let g={viewport:i.viewport,objectBounds:{x:0,y:0,width:1,height:1},fontSize:i.rootFontSize,rootFontSize:i.rootFontSize},h=po(m.width?.raw,d,"x",g,0),y=po(m.height?.raw,d,"y",g,0);for(let[U,te]of[["width",h],["height",y]])m[U]?.validity==="valid"&&te<0&&(f=!0,o.push(bi(t,e,i,U,m[U].raw,"must not be negative")));let b=uo(s,"patternTransform"),v=b?Zt(b.raw):[1,0,0,1,0,0],I=v===null?"invalid":"valid";b&&I==="invalid"&&o.push(bi(t,e,i,"patternTransform",b.raw,"does not match the SVG transform-list grammar"));let x=Object.freeze({raw:b?.raw??null,ownerSourceNodeId:b?.ownerSourceNodeId??null,matrix:Object.freeze(tt(v??[1,0,0,1,0,0])),validity:I}),k=uo(s,"viewBox"),T=k?nt(k.raw):null,w="valid";k&&(!T||T.width<0||T.height<0)&&(w="invalid",o.push(bi(t,e,i,"viewBox",k.raw,"must be four numbers with non-negative width and height")));let P=k?Object.freeze({...k,validity:w}):null,N=T&&w==="valid"?Object.freeze([T.x,T.y,T.width,T.height]):null,R=uo(s,"preserveAspectRatio"),$=W$(R?.raw??null);R&&!$.valid&&o.push(bi(t,e,i,"preserveAspectRatio",R.raw,"does not match the preserveAspectRatio grammar"));let A=R?Object.freeze({...R,validity:$.valid?"valid":"invalid"}):null,O=Y$(s),G=J$(t,n,e,O),M=Q$(r,O,G),V=eN(r,M),X=!!(N&&(N[2]===0||N[3]===0)),Y=f?"invalid":!O||h===0||y===0||X?"empty":"materialized";return Object.freeze({occurrenceId:c,sourceNodeId:e.sourceNodeId,sourceId:a,status:Y,patternUnits:d,patternContentUnits:p,values:Object.freeze(m),transform:x,viewBox:N,viewBoxAuthored:P,preserveAspectRatio:$.value,preserveAspectRatioAuthored:A,templateSourceNodeIds:Object.freeze(s.map(U=>U.sourceNodeId)),contentProviderSourceNodeId:O?.sourceNodeId??null,contentOccurrences:G,contentOccurrenceIds:Object.freeze(G.map(U=>U.occurrenceId)),resources:V})}function rN(t,e){return Object.freeze(t.edges.flatMap(n=>{if(n.binding!=="applied-css"||!n.occurrenceId||n.propertyName!=="fill"&&n.propertyName!=="stroke")return[];let r=n.targetSourceNodeId?e.get(n.targetSourceNodeId):void 0,i=_n(n.propertyValue)[n.tokenIndex],o=i?n.propertyValue.slice(i.tokenEnd).trim():"",s=i?!o||o.toLowerCase()==="none"?Object.freeze({kind:"none"}):Object.freeze({kind:"color",value:o}):Object.freeze({kind:"unresolved",authoredValue:n.propertyValue}),a=n.validity==="missing"||n.validity==="invalid-target"?"invalid-reference":r?r.status:"other-paint-server";return[Object.freeze({resourceReferenceId:n.resourceReferenceId,consumerOccurrenceId:n.occurrenceId,occurrenceId:n.occurrenceId,sourceNodeId:n.fromSourceNodeId,correspondingSourceNodeId:n.fromSourceNodeId,propertyName:n.propertyName,authoredValue:n.propertyValue,patternSourceNodeId:r?.sourceNodeId??null,status:a,fallback:s})]}))}function rd(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="pattern").map(u=>t.index.element(u.sourceNodeId)).filter(Mv).sort((u,p)=>u.elementOrder-p.elementOrder).map(u=>nN(t,u,e,r,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=rN(r,a),l=new Map;for(let u of c){let p=l.get(u.occurrenceId)??[];p.push(u),l.set(u.occurrenceId,p)}for(let u of l.values())Object.freeze(u);let d=Object.freeze({candidates:Object.freeze(s),bindings:c,candidate:u=>a.get(u)??null,bindingsFor:u=>l.get(u)??Object.freeze([]),binding:(u,p,f)=>(l.get(u)??[]).find(m=>m.propertyName===p&&(f===void 0||m.resourceReferenceId===f))??null,resolveTile:(u,p)=>{let f=u.patternSourceNodeId?a.get(u.patternSourceNodeId):null;return f?Tm(f,p):null}});return Object.freeze({value:d,diagnostics:Object.freeze(o)})}var zv=new Map([["clippath","clipPath"],["filter","filter"],["lineargradient","linearGradient"],["mask","mask"],["pattern","pattern"],["radialgradient","radialGradient"],["symbol","symbol"]]),iN=new Set(["clipPathUnits","filterUnits","gradientUnits","maskContentUnits","maskUnits","patternContentUnits","patternUnits","primitiveUnits","spreadMethod"]);function Dv(t,e){let n=new Set(e.attributes.filter(o=>o.prefix==="xmlns").map(o=>o.name)),r=new Map,i=t.index.parent(e.sourceNodeId);for(;i;){for(let o of i.attributes)o.prefix==="xmlns"&&(n.has(o.name)||r.has(o.name)||r.set(o.name,o));i=t.index.parent(i.sourceNodeId)}return Object.freeze([...r.values()])}function Cm(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function id(t){return Cm(t).replaceAll('"',"&quot;")}function oN(t){switch(t.kind){case"text":return Cm(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function Rm(t,e,n=[],r=!1){if(t.namespaceUri===K&&t.localName.toLowerCase()==="script"||r&&t.namespaceUri===K&&["animate","animatemotion","animatetransform","discard","set"].includes(t.localName.toLowerCase())&&!Le(t))return"";let i=e.identifierBySourceNodeId.get(t.sourceNodeId),o=e.generatedIdBySourceNodeId.get(t.sourceNodeId),s=e.attributeRewrites.get(t.sourceNodeId),a=[],c=!1,l=!1;for(let m of n)a.push(`${m.name}="${id(m.value)}"`);for(let m of t.attributes){if(/^on/iu.test(m.name))continue;m.name==="data-source-id"&&(c=!0),m.localName==="id"&&m.namespaceUri===null&&(l=!0);let g=m.localName==="id"&&m.namespaceUri===null&&i?i.liveId:m.localName==="id"&&m.namespaceUri===null&&o?o:s?.get(m.name)??m.value;g===""&&iN.has(m.name)||a.push(`${m.name}="${id(g)}"`)}i?.restoreSourceId&&!c&&a.push(`data-source-id="${id(i.sourceId)}"`),o&&!l&&a.push(`id="${id(o)}"`);let d=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,u=e.textRewrites.get(t.sourceNodeId),p=u!==void 0?Cm(u):t.children.map(m=>m.kind==="element"?Rm(m,e,[],r):oN(m)).join(""),f=/\/\s*>\s*$/u.test(t.rawXml??"");return p.length===0&&f?`${d}/>`:`${d}>${p}</${t.name}>`}function sN(t){let e=new Map(t.resourceIds.map(i=>[i.sourceNodeId,i])),n=new Map,r=new Map;for(let i of t.rewrites){if(i.target==="text-content"){r.set(i.sourceNodeId,i.value);continue}if(!i.name)continue;let o=n.get(i.sourceNodeId)??new Map;o.set(i.name,i.value),n.set(i.sourceNodeId,o)}return{identifierBySourceNodeId:e,attributeRewrites:new Map([...n].map(([i,o])=>[i,o])),textRewrites:r,generatedIdBySourceNodeId:new Map(t.generatedIds.map(({sourceNodeId:i,liveId:o})=>[i,o]))}}function _v(t,e){let n=t.index.parent(e);for(;n;){if(n.namespaceUri===K&&n.localName.toLowerCase()==="defs")return!0;n=t.index.parent(n.sourceNodeId)}return!1}function aN(t){return t.definition.definitionChildIds&&Object.freeze(t.definition.definitionChildIds),t.definition.sourceDefinitionChildIds&&Object.freeze(t.definition.sourceDefinitionChildIds),Object.freeze(t.definition),Object.freeze(t)}function Fv(t,e,n){if(e.namespaceUri!==K||e.localName.toLowerCase()!=="g"||!_v(t,e.sourceNodeId))return null;let r=e.children.filter(o=>o.kind==="element");if(r.length===0)return null;let i=[];for(let o of r){if(o.namespaceUri!==K)return null;let s=zv.get(o.localName.toLowerCase()),a=Fv(t,o,n);if(!s&&!a)return null;let c=n.identifierBySourceNodeId.get(o.sourceNodeId);if(!c)return null;i.push({sourceId:c.liveId,destinationId:c.liveId})}return i}function od(t,e,n){let r=[],i=sN(e),o=[];for(let l of t.index.elements){if(l.namespaceUri!==K)continue;let d=zv.get(l.localName.toLowerCase()),u=Fv(t,l,i);if(!d&&!u)continue;let p=C(l,"id");if(!p)continue;let f=i.identifierBySourceNodeId.get(l.sourceNodeId);if(!f){r.push({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`Definition ${p} has no destination identifier assignment.`,documentPath:t.index.sourcePath(l.sourceNodeId),elementName:l.name,sourceId:p,sourceNodeId:l.sourceNodeId,capability:"paint-server-definitions"});continue}let m={id:f.liveId,type:d??l.localName,...u?{role:"referenced-fragment",definitionChildIds:u.map(g=>g.destinationId),sourceDefinitionChildIds:u.map(g=>g.sourceId)}:{},markup:Rm(l,i,Dv(t,l),d==="clipPath"||d==="mask"),passthrough:!0};o.push(aN({sourceNodeId:l.sourceNodeId,sourceId:p,destinationId:f.liveId,type:d??l.localName,insideDefs:_v(t,l.sourceNodeId),definition:m}))}let s=Object.freeze(o),a=new Map(s.map(l=>[l.sourceNodeId,l])),c=Object.freeze({candidates:s,candidate:l=>a.get(l)??null,definitionForSourceNode(l,d="referenced-fragment"){let u=a.get(l);if(u)return u.definition;let p=t.index.element(l);if(!p||p.namespaceUri!==K)return null;let f=i.identifierBySourceNodeId.get(l),m=C(p,"id"),g=f?.liveId??m;return g?Object.freeze({id:g,type:p.localName,role:d,markup:Rm(p,i,Dv(t,p)),passthrough:!0}):null},definitions:(l=new Set)=>Object.freeze(s.filter(d=>!l.has(d.sourceNodeId)).map(d=>d.definition))});return Object.freeze({value:c,diagnostics:Object.freeze(r)})}var sd=Object.freeze({x:"-10%",y:"-10%",width:"120%",height:"120%"}),cN=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u,lN=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(%)?$/u,dN=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(deg|grad|rad|turn)?$/iu,Gv=new Set(["animate","animatemotion","animatetransform","set"]),uN=new Set(["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]);function xi(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))xi(e);return Object.freeze(t)}function Dr(t){return t.children.filter(e=>e.kind==="element")}function Lv(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function $m(t){return(t.rawXml??"").replace(/\s+xmlns="http:\/\/www\.w3\.org\/2000\/svg"/gu,"").replace(/\s+xmlns=""/gu,"")}function lr(t){if(t===null||!cN.test(t.trim()))return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function vi(t,e){let n=C(t,e);return n===null?void 0:n}function cd(t,e,n=""){return`${t}:${e}${n}`}function ad(t,e,n,r){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,capability:"filters",sourceNodeId:n.sourceNodeId,sourceId:C(n,"id")??void 0,occurrenceId:r,elementName:n.name,message:e})}function pN(t){let e=[...Dr(t)];for(;e.length>0;){let n=e.pop();if(n.namespaceUri===K&&n.localName.toLowerCase()==="script")return!0;e.push(...Dr(n))}return!1}function Bv(t,e,n){let r=e.direct(t.sourceNodeId);return r?n.value(r.occurrenceId,"display"):C(t,"display")}function fN(t,e,n,r){if(Bv(e,n,r)?.trim().toLowerCase()==="none")return!0;let i=t.index.parent(e.sourceNodeId);for(;i;){if(i.namespaceUri===K&&i.localName.toLowerCase()==="defs"&&Bv(i,n,r)?.trim().toLowerCase()==="none")return!0;i=t.index.parent(i.sourceNodeId)}return!1}function mN(t){let e=C(t,"color-interpolation-filters"),n=C(t,"filterUnits"),r=C(t,"primitiveUnits");return{colorInterpolation:e==="auto"||e==="sRGB"||e==="linearRGB"?e:"linearRGB",filterUnits:n==="userSpaceOnUse"||n==="objectBoundingBox"?n:"objectBoundingBox",primitiveUnits:r==="userSpaceOnUse"||r==="objectBoundingBox"?r:"userSpaceOnUse",region:Object.freeze({x:C(t,"x")??sd.x,y:C(t,"y")??sd.y,width:C(t,"width")??sd.width,height:C(t,"height")??sd.height})}}function Vv(t,e){let n=vi(e,"x"),r=vi(e,"y"),i=vi(e,"width"),o=vi(e,"height");n!==void 0&&(t.x=n),r!==void 0&&(t.y=r),i!==void 0&&(t.width=i),o!==void 0&&(t.height=o);let s=C(e,"filterUnits");(s==="userSpaceOnUse"||s==="objectBoundingBox")&&(t.filterUnits=s);let a=C(e,"primitiveUnits");(a==="userSpaceOnUse"||a==="objectBoundingBox")&&(t.primitiveUnits=a);let c=C(e,"color-interpolation-filters");(c==="auto"||c==="sRGB"||c==="linearRGB")&&(t.type==="raw-svg"?t.colorInterpolationFilters=c:t.filterColorInterpolation=c);let l=vi(e,"flood-color"),d=vi(e,"flood-opacity"),u=vi(e,"lighting-color");l!==void 0&&(t.floodColor=l),d!==void 0&&(t.floodOpacity=d),u!==void 0&&(t.lightingColor=u)}function gN(t){return Dr(t).filter(e=>Gv.has(e.localName.toLowerCase())).map($m).filter(Boolean)}function Ot(t,e,n){let r={id:cd(e,t.sourceNodeId),type:e};for(let c of["in","result","x","y","width","height"]){let l=C(t,c);l!==null&&(r[c]=l)}let i=C(t,"color-interpolation-filters");(i==="auto"||i==="sRGB"||i==="linearRGB")&&(r.colorInterpolationFilters=i);let o=new Set(["in","result","x","y","width","height","color-interpolation-filters"]),s={};for(let c of t.attributes)o.has(c.name)||n.has(c.name)||(s[c.name]=c.value);Object.keys(s).length>0&&(r.unknownAttrs=s);let a=gN(t);return a.length>0&&(r.animations=a),r}function hN(t){let e=C(t,"type");if(e==="identity")return{type:e};if(e==="table"||e==="discrete"){let r=(C(t,"tableValues")??"").trim().split(/[\s,]+/u).filter(Boolean).map(i=>lr(i));return r.some(i=>i===void 0)?void 0:{type:e,tableValues:r}}if(e==="linear"){let n={type:e},r=lr(C(t,"slope")),i=lr(C(t,"intercept"));return r!==void 0&&(n.slope=r),i!==void 0&&(n.intercept=i),n}if(e==="gamma"){let n={type:e},r=lr(C(t,"amplitude")),i=lr(C(t,"exponent")),o=lr(C(t,"offset"));return r!==void 0&&(n.amplitude=r),i!==void 0&&(n.exponent=i),o!==void 0&&(n.offset=o),n}}function yN(t){let e={},n=t.localName.toLowerCase(),r=n==="fedistantlight"?["azimuth","elevation"]:n==="fepointlight"?["x","y","z"]:n==="fespotlight"?["x","y","z","pointsAtX","pointsAtY","pointsAtZ","specularExponent","limitingConeAngle"]:null;if(r){for(let i of r){let o=lr(C(t,i));o!==void 0&&(e[i]=o)}return n==="fedistantlight"?{kind:"feDistantLight",...e}:n==="fepointlight"?{kind:"fePointLight",...e}:{kind:"feSpotLight",...e}}}function nn(t,e,n,r=n){let i=lr(C(e,n));i!==void 0&&(t[r]=i)}function gt(t,e,n,r=n){let i=C(e,n);i!==null&&(t[r]=i)}function SN(t){let e=t.localName.toLowerCase();switch(e){case"feblend":{let n=Ot(t,"feBlend",new Set(["in2","mode","no-composite"]));gt(n,t,"in2");let r=C(t,"mode");return r&&uN.has(r)&&(n.mode=r),mt(t,"no-composite")&&(n.noComposite=!0),n}case"fecolormatrix":{let n=Ot(t,"feColorMatrix",new Set(["type","values"])),r=C(t,"type");return(r==="matrix"||r==="saturate"||r==="hueRotate"||r==="luminanceToAlpha")&&(n.matrixType=r),gt(n,t,"values"),n}case"fecomponenttransfer":{let n=Ot(t,"feComponentTransfer",new Set);for(let r of Dr(t)){let i=hN(r),o=r.localName.toLowerCase();o==="fefuncr"&&i?n.funcR=i:o==="fefuncg"&&i?n.funcG=i:o==="fefuncb"&&i?n.funcB=i:o==="fefunca"&&i&&(n.funcA=i)}return n}case"fecomposite":{let n=Ot(t,"feComposite",new Set(["in2","operator","k1","k2","k3","k4"]));gt(n,t,"in2");let r=C(t,"operator");(r==="over"||r==="in"||r==="out"||r==="atop"||r==="xor"||r==="lighter"||r==="arithmetic")&&(n.operator=r);for(let i of["k1","k2","k3","k4"])nn(n,t,i);return n}case"feconvolvematrix":{let r=Ot(t,"feConvolveMatrix",new Set(["order","kernelMatrix","divisor","bias","targetX","targetY","edgeMode","kernelUnitLength","preserveAlpha"]));gt(r,t,"order"),gt(r,t,"kernelMatrix");for(let s of["divisor","bias","targetX","targetY"])nn(r,t,s);let i=C(t,"edgeMode");(i==="duplicate"||i==="wrap"||i==="none")&&(r.edgeMode=i),gt(r,t,"kernelUnitLength");let o=C(t,"preserveAlpha");return o!==null&&(r.preserveAlpha=o==="true"),r}case"fediffuselighting":case"fespecularlighting":{let n=e==="fediffuselighting",i=Ot(t,n?"feDiffuseLighting":"feSpecularLighting",new Set(["surfaceScale","diffuseConstant","specularConstant","specularExponent","kernelUnitLength","lighting-color"]));nn(i,t,"surfaceScale"),n?nn(i,t,"diffuseConstant"):(nn(i,t,"specularConstant"),nn(i,t,"specularExponent")),gt(i,t,"kernelUnitLength"),gt(i,t,"lighting-color","lightingColor");for(let o of Dr(t)){let s=yN(o);if(s){i.lightSource=s;break}}return i}case"fedisplacementmap":{let n=Ot(t,"feDisplacementMap",new Set(["in2","scale","xChannelSelector","yChannelSelector"]));gt(n,t,"in2"),nn(n,t,"scale");for(let r of["xChannelSelector","yChannelSelector"]){let i=C(t,r);(i==="R"||i==="G"||i==="B"||i==="A")&&(n[r]=i)}return n}case"fedropshadow":{let n=Ot(t,"feDropShadow",new Set(["dx","dy","stdDeviation","flood-color","flood-opacity"]));return nn(n,t,"dx"),nn(n,t,"dy"),gt(n,t,"stdDeviation"),gt(n,t,"flood-color","floodColor"),gt(n,t,"flood-opacity","floodOpacity"),n}case"feflood":{let n=Ot(t,"feFlood",new Set(["flood-color","flood-opacity"]));return gt(n,t,"flood-color","floodColor"),gt(n,t,"flood-opacity","floodOpacity"),n}case"fegaussianblur":{let n=Ot(t,"feGaussianBlur",new Set(["stdDeviation","edgeMode"]));gt(n,t,"stdDeviation");let r=C(t,"edgeMode");return(r==="duplicate"||r==="wrap"||r==="none")&&(n.edgeMode=r),n}case"feimage":{let n=Ot(t,"feImage",new Set(["href","xlink:href","preserveAspectRatio","crossorigin"])),r=Le(t);r?.namespace==="svg2"?n.href=r.value:r?.namespace==="xlink"&&(n.xlinkHref=r.value),gt(n,t,"preserveAspectRatio");let i=C(t,"crossorigin");return(i==="anonymous"||i==="use-credentials")&&(n.crossorigin=i),n}case"femerge":{let n=Ot(t,"feMerge",new Set);return n.nodes=Dr(t).filter(r=>r.localName.toLowerCase()==="femergenode").map(r=>{let i=C(r,"in");return i===null?{}:{in:i}}),n}case"femorphology":{let n=Ot(t,"feMorphology",new Set(["operator","radius"])),r=C(t,"operator");return(r==="erode"||r==="dilate")&&(n.operator=r),gt(n,t,"radius"),n}case"feoffset":{let n=Ot(t,"feOffset",new Set(["dx","dy"]));return nn(n,t,"dx"),nn(n,t,"dy"),n}case"fetile":return Ot(t,"feTile",new Set);case"feturbulence":{let n=Ot(t,"feTurbulence",new Set(["baseFrequency","numOctaves","seed","stitchTiles","type"]));gt(n,t,"baseFrequency"),nn(n,t,"numOctaves"),nn(n,t,"seed");let r=C(t,"stitchTiles");(r==="stitch"||r==="noStitch")&&(n.stitchTiles=r);let i=C(t,"type");return(i==="fractalNoise"||i==="turbulence")&&(n.turbulenceType=i),n}default:return null}}function bN(t){let e=[],n="",r=0;for(let i of t)i==="("?r++:i===")"&&r--,/\s/u.test(i)&&r===0?(n&&e.push(n),n=""):n+=i;return n&&e.push(n),e}function gn(t,e){return(t===void 0?void 0:lr(t))??e}function vN(t,e){let n=bN(t);if(n.length<2)return null;let r=n[0],i=n[1]==="1",o={id:cd(r,e,":preset"),enabled:i};switch(r){case"hue-rotate":return{...o,type:r,angle:gn(n[2],0)};case"sepia":case"grayscale":case"saturate":case"invert":case"brightness":case"contrast":return{...o,type:r,amount:gn(n[2],1)};case"duotone":return{...o,type:r,shadowColor:n[2]??"#000000",highlightColor:n[3]??"#ffffff"};case"inner-shadow":return{...o,type:r,offsetX:gn(n[2],0),offsetY:gn(n[3],0),blurRadius:gn(n[4],0),choke:gn(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"drop-shadow":return{...o,type:r,offsetX:gn(n[2],0),offsetY:gn(n[3],0),blurRadius:gn(n[4],0),spread:gn(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"gaussian-blur":{let s=gn(n[2],0);return{...o,type:r,blurX:s,blurY:gn(n[3],s),linked:n[3]===void 0,quality:"normal"}}default:return null}}function xN(t,e){let n={id:cd("raw-svg",t.sourceNodeId),type:"raw-svg",enabled:!0,svgContent:Dr(t).map($m).filter(Boolean).join(`
17
+ `)};return Vv(n,t),e&&(n.display="none"),n}function IN(t){let e={id:cd("svg-primitive-chain",t.sourceNodeId),type:"svg-primitive-chain",enabled:!0,primitives:[]};Vv(e,t);let n=[];for(let r of Dr(t)){let i=r.localName.toLowerCase();if(i==="title")e.filterTitle=Lv(r);else if(i==="desc")e.filterDescription=Lv(r);else if(Gv.has(i))n.push($m(r));else{let o=SN(r);o&&e.primitives.push(o)}}return n.length>0&&(e.filterAnimations=n),e}function wN(t,e,n,r,i,o){let s=mN(e),a=e.attributes.find(g=>g.localName==="preset"&&g.prefix==="bx")?.value,c=fN(t,e,n,r),l=C(e,"filterUnits"),d=C(e,"primitiveUnits"),u=C(e,"color-interpolation-filters");l!==null&&l!=="userSpaceOnUse"&&l!=="objectBoundingBox"&&o.push(ad(i,`Invalid filterUnits value "${l}" uses its initial value.`,e)),d!==null&&d!=="userSpaceOnUse"&&d!=="objectBoundingBox"&&o.push(ad(i,`Invalid primitiveUnits value "${d}" uses its initial value.`,e)),u!==null&&u!=="auto"&&u!=="sRGB"&&u!=="linearRGB"&&o.push(ad(i,`Invalid color-interpolation-filters value "${u}" uses its initial value.`,e));let p=a?vN(a,e.sourceNodeId):c||pN(e)?xN(e,c):IN(e),f=Object.freeze(p?[p]:[]),m=p?.type==="svg-primitive-chain"&&p.primitives.length===0;return xi({sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),status:p?m?"empty":"materialized":"invalid",filters:f,...s})}function kN(t,e){let n=lN.exec(t.trim());if(!n)return null;let r=Number(n[1]);return!Number.isFinite(r)||r<0?null:n[2]?r/100:r}function PN(t){let e=dN.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n))return null;switch((e[2]??"deg").toLowerCase()){case"turn":return n*360;case"rad":return n*180/Math.PI;case"grad":return n*.9;default:return n}}function TN(t){let e=[],n="",r=null,i=!1,o=0;for(let s of t){if(r){n+=s,i?i=!1:s==="\\"?i=!0:s===r&&(r=null);continue}s==='"'||s==="'"?(r=s,n+=s):s==="("?(o++,n+=s):s===")"?(o--,n+=s):/\s/u.test(s)&&o===0?(n&&e.push(n),n=""):n+=s}return n&&e.push(n),e}function RN(t,e){if(t.toLowerCase()==="currentcolor")return e??"#000000";if(/^#[\da-f]{3,8}$/iu.test(t)||/^rgba?\(/iu.test(t))return t;let n=ao(t);return n?`rgb(${n.r}, ${n.g}, ${n.b})`:null}function CN(t,e,n,r,i,o){if(t==="brightness"||t==="contrast"||t==="grayscale"||t==="invert"||t==="opacity"||t==="saturate"||t==="sepia"){let c=kN(e,1);return c===null?null:{id:n,type:t,enabled:!0,amount:c}}if(t==="hue-rotate"){let c=PN(e);return c===null?null:{id:n,type:t,enabled:!0,angle:c}}if(t==="blur"){let c=Pe(e.trim(),{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});return c===void 0||c<0||e.trim().endsWith("%")?null:{id:n,type:"gaussian-blur",enabled:!0,blurX:c,blurY:c,linked:!0,quality:"normal"}}if(t!=="drop-shadow")return null;let s=[],a=null;for(let c of TN(e.trim())){let l=Pe(c,{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});if(l!==void 0&&!c.endsWith("%"))s.push(l);else{let d=RN(c,r);if(!d||a!==null)return null;a=d}}return s.length<2||s.length>3||(s[2]??0)<0?null:{id:n,type:"drop-shadow",enabled:!0,offsetX:s[0],offsetY:s[1],blurRadius:s[2]??0,spread:0,color:a??r??"#000000",opacity:1}}function $N(t,e,n){let r=t.resolvePropertyValue(e.correspondingSourceNodeId,"filter",n),i=r.filter(o=>o.occurrenceId===e.occurrenceId);return i.length>0?i:r.filter(o=>o.occurrenceId===null)}function NN(t){let e=t.trim();return e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e.startsWith("#")&&e.length>1?e.slice(1):null}function AN(t,e){let n=0;for(let r of e){if(t.slice(n,r.tokenStart).replace(/\/\*[\s\S]*?\*\//gu,"").trim())return!1;n=r.tokenEnd}return t.slice(n).replace(/\/\*[\s\S]*?\*\//gu,"").trim().length===0}function EN(t,e,n,r,i,o,s,a){let c=[],l=$N(r,t,e),d=0,u=!1,p=Pe(n.value(t.occurrenceId,"font-size"),{fontSize:o.rootFontSize??16,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height})??o.rootFontSize??16,f=n.value(t.occurrenceId,"color"),m=xn(e);AN(e,m)||(u=!0);for(let[y,b]of m.entries()){let v=`filter-operation:${t.occurrenceId}:${y}`,I=e.slice(b.tokenStart,b.tokenEnd);if(b.name!=="url"){let N=CN(b.name,e.slice(b.argumentsStart,b.argumentsEnd),v,f,p,o),R=N?"materialized":"invalid-reference";N||(u=!0,s.push(ad(o,`Invalid or unsupported CSS filter function "${I}".`,a,t.occurrenceId))),c.push(Object.freeze({operationId:v,kind:"function",authoredValue:I,filter:N,filterSourceNodeId:null,status:R}));continue}let k=NN(e.slice(b.argumentsStart,b.argumentsEnd))===null?void 0:l[d++],T=k?.targetSourceNodeId?i.get(k.targetSourceNodeId):null,P=k?.validity==="valid"&&T?T.status==="empty"?"empty":T.status==="materialized"?"materialized":"invalid-reference":"invalid-reference";P==="invalid-reference"&&(u=!0),c.push(xi({operationId:v,kind:"reference",authoredValue:I,filter:P==="materialized"?T?.filters[0]??null:null,filterSourceNodeId:k?.targetSourceNodeId??null,status:P}))}let h=e.trim().toLowerCase()==="none"?"none":u||c.length===0?"invalid-reference":"materialized";return xi({consumerOccurrenceId:t.occurrenceId,consumerSourceNodeId:t.correspondingSourceNodeId,authoredValue:e,status:h,operations:Object.freeze(c)})}function ld(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="filter").map(u=>t.index.element(u.sourceNodeId)).filter(u=>!!u).map(u=>wN(t,u,e,n,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=[];for(let u of e.occurrences){let p=t.index.element(u.correspondingSourceNodeId);if(!p)continue;let f=n.value(u.occurrenceId,"filter");f&&c.push(EN(u,f,n,r,a,i,o,p))}let l=new Map(c.map(u=>[u.consumerOccurrenceId,u]));xi(s),xi(c),xi(o);let d=Object.freeze({candidates:s,bindings:c,diagnostics:o,candidate(u){return a.get(u)??null},binding(u){return l.get(u)??null}});return Object.freeze({value:d,diagnostics:o})}var MN="application/ecmascript",ON="http://www.w3.org/1999/xlink",DN=Object.freeze([]);function zN(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function _N(t,e){let n=t.attributes[e];return n.namespaceUri===ON&&n.localName==="href"?!0:n.namespaceUri!==null?!1:["id","type","href","crossorigin","async","defer"].includes(n.localName)}function FN(t){let e=t.attributes.filter((n,r)=>!_N(t,r)).map(n=>[n.name,n.value]);return e.length>0?Object.freeze(Object.fromEntries(e)):void 0}function LN(t,e){return!e||e.sourceNodeId===t.root.sourceNodeId||e.namespaceUri===K&&["defs","metadata"].includes(e.localName.toLowerCase())?"document":"element"}function BN(t){let e=Le(t)?.value,n=e!==void 0&&e.length>0,r=C(t,"type")||MN,i=C(t,"crossorigin"),o=C(t,"id")||void 0,s=FN(t);return Object.freeze({id:`script:${t.sourceNodeId}`,...o?{svgId:o}:{},source:n?"external":"inline",content:n?"":zN(t),...n?{href:e}:{},type:r,...i==="anonymous"||i==="use-credentials"?{crossorigin:i}:{},...mt(t,"async")?{async:!0}:{},...mt(t,"defer")?{defer:!0}:{},...s?{customAttrs:s}:{}})}function dd(t,e){let n=[],r=t.index.elements.filter(l=>l.namespaceUri===K&&l.localName.toLowerCase()==="script").map(l=>{let d=t.index.parent(l.sourceNodeId);return Object.freeze({sourceNodeId:l.sourceNodeId,parentSourceNodeId:d?.sourceNodeId??null,scope:LN(t,d),script:BN(l)})}),i=Object.freeze(r.filter(l=>l.scope==="document")),o=Object.freeze(r.filter(l=>l.scope==="element")),s=new Map(r.map(l=>[l.sourceNodeId,l])),a=new Map;for(let l of o){if(!l.parentSourceNodeId)continue;let d=a.get(l.parentSourceNodeId)??[];a.set(l.parentSourceNodeId,Object.freeze([...d,l]))}Object.freeze(r),Object.freeze(n);let c=Object.freeze({candidates:r,documentScripts:i,elementScripts:o,candidate(l){return s.get(l)??null},forParent(l){return a.get(l)??DN}});return Object.freeze({value:c,diagnostics:n})}function Gn(t){if(!t)return"";let e=t.replace(/[^A-Za-z0-9_.-]/g,"_");return e&&!/^[A-Za-z_]/.test(e)&&(e=`_${e}`),e}function GN(t){let e=t.state?.children;return Array.isArray(e)?e:[]}function jv(t,e,n="shapes"){let r=new Set,i=(o,s)=>{r.has(o)||(r.add(o),e(o,s),GN(o).forEach((a,c)=>i(a,`${s}.children[${c}]`)),r.delete(o))};t.forEach((o,s)=>i(o,`${n}[${s}]`))}function VN(t){let e=[],n=new Set,r=i=>{if(!(i===null||typeof i!="object"||n.has(i))){if(n.add(i),Array.isArray(i)){let o=i.filter(s=>!!(s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.type=="string"&&"state"in s));o.length===i.length&&o.length>0?e.push(o):i.forEach(r);return}Object.values(i).forEach(r)}};return r(t),e}function jN(t){return t.definitionId??`${t.type}-${t.id}`}function UN(t,e){return{severity:"warning",code:"duplicate-svg-id",source:"native-document",entrypoint:"full-snapshot-restore",capability:"destination-identity",sourceId:t,documentPath:e[0]?.documentPath,message:`SVG destination id "${t}" has ${e.length} canonical owners.`}}function HN(t,e={}){let n=[],r=new Map,i=new Set,o=[],s=f=>{if(!f.id)return;let m=`${f.channel}\0${f.ownerKey}\0${f.id}`;if(i.has(m))return;i.add(m);let g=Object.freeze({...f});n.push(g);let h=r.get(f.id)??[];h.push(g),r.set(f.id,h)},a=(f,m)=>{let g=f.state??{},h=g.metadata;if(typeof h?.name=="string"){let y=Gn(h.name);y&&s({id:y,ownerKey:`shape:${f.id}:metadata`,channel:"shape-authored",documentPath:m})}f.type==="view"&&typeof g.viewName=="string"&&g.viewName&&s({id:Gn(g.viewName),ownerKey:`view:${f.id}`,channel:"view",documentPath:m}),f.type==="text"&&g.isTextPath===!0&&g.textPathPoints&&s({id:`text-path-${f.id}`,ownerKey:`shape:${f.id}:text-path`,channel:"shape-generated",documentPath:m}),g.displayMode==="motionOnly"&&s({id:f.id,ownerKey:`shape:${f.id}:motion-path`,channel:"shape-generated",documentPath:m}),Array.isArray(g.filters)&&g.filters.length>0&&s({id:`filter-${f.id}`,ownerKey:`shape:${f.id}:filter`,channel:"shape-generated",documentPath:m}),typeof h?.rawMetadata=="string"&&c(h.rawMetadata,`shape:${f.id}:metadata`,void 0,m)},c=(f,m,g,h)=>{let y=`<svg xmlns="${K}">${f}</svg>`,b=tn(y,{source:"native-document",entrypoint:"full-snapshot-restore"},e.parserHost);if(o.push(...b.diagnostics),!b.value)return;let v=new Map;for(let I of b.value.index.elements.slice(1)){let x=C(I,"id");if(!x||b.value.index.parent(I.sourceNodeId)===b.value.root&&g===x)continue;let T=v.get(x)??0;v.set(x,T+1),s({id:x,ownerKey:`${m}#${x}${T>0?`@${T}`:""}`,channel:"verbatim-fragment"})}},l=new Map;jv(t.shapes??[],(f,m)=>{l.has(f.id)||l.set(f.id,f),a(f,m)});for(let f of l.values()){let m=f.state??{},g=[f.type==="text"?m.shapeInsideRef:void 0,f.type==="shape-reference"?m.targetShapeId:void 0];for(let h of g){if(typeof h!="string")continue;let y=l.get(h),b=y?.state?.metadata?.name;y&&(typeof b!="string"||Gn(b).length===0)&&s({id:y.id,ownerKey:`shape:${y.id}:reference-target`,channel:"shape-generated",documentPath:`shape:${y.id}`})}}typeof t.documentMetadata?.rawMetadata=="string"&&c(t.documentMetadata.rawMetadata,"document:metadata",void 0,"documentMetadata");for(let f of t.documentStyles??[])f.svgId&&s({id:f.svgId,ownerKey:`style:${f.id}`,channel:"document-style",documentPath:"documentStyles"});for(let f of t.documentScripts??[])f.svgId&&s({id:f.svgId,ownerKey:`script:${f.id}`,channel:"document-script",documentPath:"documentScripts"});for(let f of t.animationTimeline?.tracks??[])f.sourceSmilId&&s({id:f.sourceSmilId,ownerKey:`animation:${f.id}`,channel:"animation",documentPath:"animationTimeline"});let d=(f,m,g)=>{let h=m?`libraryFurniture[${g}]`:`library[${g}]`;s({id:f.id,ownerKey:`library:${f.id}`,channel:"library-runtime",documentPath:h}),f.sourceId&&s({id:f.sourceId,ownerKey:`library:${f.id}:source`,channel:"library-source-alias",documentPath:h}),VN(f).forEach((y,b)=>jv(y,a,`${h}.shapeForest[${b}]`))};(t.library??[]).forEach((f,m)=>d(f,!1,m)),(e.libraryFurniture??[]).forEach((f,m)=>d(f,!0,m));for(let[f,m]of(t.paintServerDefs??[]).entries())s({id:m.id,ownerKey:`paint-server:${m.id}`,channel:"paint-server",documentPath:`paintServerDefs[${f}]`}),c(m.markup,`paint-server:${m.id}`,m.id,`paintServerDefs[${f}].markup`);for(let[f,m]of(t.clipMaskGroups??[]).entries()){let g=jN(m);s({id:g,ownerKey:`clip-mask:${m.id}`,channel:"clip-mask-definition",documentPath:`clipMaskGroups[${f}]`}),m.rawDefinition&&c(m.rawDefinition,`clip-mask:${m.id}`,g,`clipMaskGroups[${f}].rawDefinition`)}for(let f of e.platformReservations??[])s(f);for(let f of r.values())Object.freeze(f);Object.freeze(n);let u=Object.freeze({owners:n,has(f){return r.has(f)},firstOwner(f){return r.get(f)?.[0]??null},ownersOf(f){return r.get(f)??Object.freeze([])}}),p=[...r.entries()].filter(([,f])=>f.length>1).map(([f,m])=>UN(f,m));return{value:u,diagnostics:Object.freeze([...o,...p])}}function WN(t){let e=new Set(t.owners.map(s=>s.id)),n=new Map,r=[],i=new Map;return Object.freeze({allocate:s=>{let a=n.get(s.requestKey);if(a)return a;let c=s.preferredId,l=Gn(c??""),d=Gn(s.fallbackBase)||"svg-resource",u=l||d,p=e.has(u)?t.firstOwner(u):null,f=u;if(e.has(f)){let g=i.get(u)??1;for(;e.has(`${u}-${g}`);)g++;f=`${u}-${g}`,i.set(u,g+1)}e.add(f);let m=Object.freeze({requestKey:s.requestKey,...c!==void 0?{authoredId:c}:{},destinationId:f,...p?{collisionOwner:p}:{}});return n.set(s.requestKey,m),r.push(m),m},assignment(s){return n.get(s)??null},has(s){return e.has(s)},snapshot(){return Object.freeze([...r])}})}function Qs(t,e,n,r){let i=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/10);switch(t){case"stripes":return[{tag:"rect",attrs:{width:r?.strokeWidth!=null?Math.max(.01,Math.min(1,r.strokeWidth))*e:e/2,height:e,fill:n}}];case"dots":{let o=r?.dotRadius!=null?Math.max(.05,Math.min(.45,r.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*o,fill:n}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:n,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:n}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:n}}];case"diagonal":{let o=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:n,"stroke-width":o}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:n,"stroke-width":i}}];case"zigzag":{let o=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,s=e*o;return[{tag:"path",attrs:{d:`M 0 ${s} L ${e/4} 0 L ${e/2} ${s} L ${e*3/4} 0 L ${e} ${s}`,fill:"none",stroke:n,"stroke-width":i}}]}case"waves":{let o=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,s=e*o,a=e/2;return[{tag:"path",attrs:{d:`M 0 ${a} Q ${e/4} ${a-s} ${e/2} ${a} T ${e} ${a}`,fill:"none",stroke:n,"stroke-width":i}}]}case"triangles":{let o=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${o} L 0 ${o} Z`,fill:"none",stroke:n,"stroke-width":i}}]}case"hexagons":{let o=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${o*.5} L ${e*.75} ${o} L ${e*.25} ${o} L 0 ${o*.5} Z`,fill:"none",stroke:n,"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:n,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:n,"stroke-width":i}}];case"bricks":{let o=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}}]}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:n,"stroke-width":i}}];default:return[]}}function KN(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${r}"`).join("");return`<${t.tag}${e}/>`}function ud(t,e,n,r,i){let o=10*e,s="";s+=`<rect width="${o}" height="${o}" fill="${r}"/>`;let a=Qs(t,o,n,i);for(let c of a)s+=KN(c);return{svgContent:s,width:o,height:o}}function de(t,e,n){n==null||n===""||t.push([e,n])}function Nm(t){return(t.stops??[]).map(e=>{let n=[["offset",`${e.offset*100}%`],["stop-color",e.color]];return e.opacity!==void 0&&e.opacity<1&&n.push(["stop-opacity",e.opacity]),{attributes:n}})}function XN(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${fe(String(r))}"`).join("");return`<${t.tag}${e}/>`}function pd(t,e){let n=[["id",t]];if(e.svgContent!=null){let c=e.authoredGeometry??{};return de(n,"patternUnits",e.patternUnits??"userSpaceOnUse"),de(n,"patternContentUnits",e.patternContentUnits),de(n,"x",c.x??e.x),de(n,"y",c.y??e.y),de(n,"width",c.width??e.width??10),de(n,"height",c.height??e.height??10),de(n,"viewBox",e.viewBox),de(n,"preserveAspectRatio",e.preserveAspectRatio),de(n,"patternTransform",e.patternTransform),{attributes:n,content:e.svgContent}}let r=10*(e.scale??1),i=e.color||"#000000",o=e.backgroundColor||"#ffffff";de(n,"patternUnits","userSpaceOnUse"),de(n,"width",r),de(n,"height",r),e.rotation&&de(n,"patternTransform",`rotate(${e.rotation})`);let s=`<rect width="${fe(String(r))}" height="${fe(String(r))}" fill="${fe(o)}"/>`,a=Qs(e.patternType,r,i).map(XN).join("");return{attributes:n,content:`${s}${a}`}}function fd(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=s=>n?String(s):`${s*100}%`,i=e.authoredGeometry??{},o=[["id",t]];return n&&de(o,"gradientUnits","userSpaceOnUse"),de(o,"x1",i.x1??r(e.x1)),de(o,"y1",i.y1??r(e.y1)),de(o,"x2",i.x2??r(e.x2)),de(o,"y2",i.y2??r(e.y2)),de(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&de(o,"color-interpolation",e.colorInterpolation),de(o,"gradientTransform",i.gradientTransform??ws(e.gradientTransform)),{element:"linearGradient",attributes:o,stops:Nm(e)}}function md(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=a=>n?String(a):`${a*100}%`,i=e.authoredGeometry??{},o=[["id",t]];if(n&&de(o,"gradientUnits","userSpaceOnUse"),de(o,"cx",i.cx??r(e.cx)),de(o,"cy",i.cy??r(e.cy)),de(o,"fx",i.fx??r(e.fx)),de(o,"fy",i.fy??r(e.fy)),de(o,"r",i.r??r(e.r)),(i.fr!==void 0||e.fr!==void 0&&e.fr>0)&&de(o,"fr",i.fr??r(e.fr??0)),de(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&de(o,"color-interpolation",e.colorInterpolation),i.gradientTransform!==void 0||e.gradientTransform!==void 0)de(o,"gradientTransform",i.gradientTransform??ws(e.gradientTransform));else{let a=e.ry!==void 0&&e.ry!==e.r,c=!!e.rotation;if(!a&&!c)return{element:"radialGradient",attributes:o,stops:Nm(e)};let l=e.cx??(n?0:.5),d=e.cy??(n?0:.5),u=[`translate(${l}, ${d})`];c&&u.push(`rotate(${e.rotation})`),a&&e.ry!==0&&u.push(`scale(1, ${e.ry/e.r})`),u.push(`translate(${-l}, ${-d})`),de(o,"gradientTransform",u.join(" "))}return{element:"radialGradient",attributes:o,stops:Nm(e)}}function Am(t){return t.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(n=>n.type==="feGaussianBlur"||n.type==="feDropShadow"||n.type==="feOffset"||n.type==="feMorphology"||n.type==="feDisplacementMap"||n.type==="feTurbulence"))}function gd(t,e,n={}){let r=e.filter(p=>p.enabled);if(r.length===0)return null;let i=r.find(p=>p.type==="raw-svg");if(i){let p=[["id",t]];return de(p,"x",n.x??i.x),de(p,"y",n.y??i.y),de(p,"width",n.width??i.width),de(p,"height",n.height??i.height),de(p,"filterUnits",n.filterUnits??i.filterUnits),de(p,"primitiveUnits",n.primitiveUnits??i.primitiveUnits),de(p,"color-interpolation-filters",n.colorInterpolation&&n.colorInterpolation!=="auto"?n.colorInterpolation:i.colorInterpolationFilters),de(p,"flood-color",i.floodColor),de(p,"flood-opacity",i.floodOpacity),de(p,"lighting-color",i.lightingColor),de(p,"display",i.display),{kind:"raw",attributes:p,content:i.svgContent}}let o=r.find(p=>p.type==="svg-primitive-chain");if(o)return{kind:"primitive-chain",attributes:[],chain:{...o,x:n.x??o.x,y:n.y??o.y,width:n.width??o.width,height:n.height??o.height,filterUnits:n.filterUnits??o.filterUnits,primitiveUnits:n.primitiveUnits??o.primitiveUnits,filterColorInterpolation:n.colorInterpolation&&n.colorInterpolation!=="auto"?n.colorInterpolation:o.filterColorInterpolation}};let s=r.some(p=>p.type==="gaussian-blur"&&p.quality==="high"||p.type==="motion-blur"&&p.quality==="high"),a=Am(r),c=a?s?"-200%":"-100%":"-10%",l=a?s?"500%":"300%":"120%",d=n.primitiveUnits??"userSpaceOnUse",u=[["id",t]];return de(u,"x",n.x??c),de(u,"y",n.y??c),de(u,"width",n.width??l),de(u,"height",n.height??l),de(u,"filterUnits",n.filterUnits??"objectBoundingBox"),de(u,"primitiveUnits",d),n.colorInterpolation&&n.colorInterpolation!=="auto"&&de(u,"color-interpolation-filters",n.colorInterpolation),{kind:"generated",attributes:u,filters:r,primitiveUnits:d}}function S(t,e){return e==null||e===""?"":` ${t}="${fe(String(e))}"`}function yd(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);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 YN(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,spread:s,color:a,opacity:c}=t,l="";if(s===0)l+=`<feDropShadow${S("in",e)}${S("dx",r)}${S("dy",i)}${S("stdDeviation",o/2)}${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_shadow`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_shadow`)}/><feMergeNode${S("in",e)}/></feMerge>`;else{l+=`<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",`${n}_alpha`)}/>`;let d=s>0?"dilate":"erode",u=Math.abs(s);l+=`<feMorphology${S("in",`${n}_alpha`)}${S("operator",d)}${S("radius",u)}${S("result",`${n}_spread`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_spread`)}${S("stdDeviation",o/2)}${S("result",`${n}_blur`)}/>`,l+=`<feOffset${S("in",`${n}_blur`)}${S("dx",r)}${S("dy",i)}${S("result",`${n}_offset`)}/>`,l+=`<feFlood${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_color`)}/>`,l+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_offset`)}${S("operator","in")}${S("result",`${n}_shadow`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_shadow`)}/><feMergeNode${S("in",e)}/></feMerge>`}return l}function qN(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,choke:s,color:a,opacity:c}=t,l=o*(1-s/100),d="";return d+=`<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",`${n}_alpha`)}/>`,d+=`<feComponentTransfer${S("in",`${n}_alpha`)}${S("result",`${n}_inverted`)}><feFuncA${S("type","table")}${S("tableValues","1 0")}/></feComponentTransfer>`,d+=`<feGaussianBlur${S("in",`${n}_inverted`)}${S("stdDeviation",l/2)}${S("result",`${n}_blur`)}/>`,d+=`<feOffset${S("in",`${n}_blur`)}${S("dx",r)}${S("dy",i)}${S("result",`${n}_offset`)}/>`,d+=`<feFlood${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_color`)}/>`,d+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_offset`)}${S("operator","in")}${S("result",`${n}_coloredShadow`)}/>`,d+=`<feComposite${S("in",`${n}_coloredShadow`)}${S("in2",`${n}_alpha`)}${S("operator","in")}${S("result",`${n}_innerShadow`)}/>`,d+=`<feComposite${S("in",`${n}_innerShadow`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`,d}function ZN(t,e,n){let{blurX:r,blurY:i}=t;return r===0&&i===0?De(e,n):`<feGaussianBlur${S("in",e)}${S("stdDeviation",`${r/2} ${i/2}`)}${S("result",n)}/>`}function JN(t,e,n){let{distance:r,angle:i}=t;if(r===0)return De(e,n);let o=i*Math.PI/180,s=Math.abs(Math.cos(o)*r),a=Math.abs(Math.sin(o)*r);return`<feGaussianBlur${S("in",e)}${S("stdDeviation",`${s/2} ${a/2}`)}${S("result",n)}/>`}function Uv(t,e,n){let{x:r,y:i,z:o,color:s,surfaceScale:a,diffuseConstant:c,specularConstant:l,specularExponent:d}=t,u="";return u+=`<feDiffuseLighting${S("in","SourceAlpha")}${S("surfaceScale",a)}${S("diffuseConstant",c)}${S("lighting-color",s)}${S("result",`${n}_diffuse`)}>`,u+=`<fePointLight${S("x",r)}${S("y",i)}${S("z",o)}/>`,u+="</feDiffuseLighting>",u+=`<feSpecularLighting${S("in","SourceAlpha")}${S("surfaceScale",a)}${S("specularConstant",l)}${S("specularExponent",d)}${S("lighting-color",s)}${S("result",`${n}_specular`)}>`,u+=`<fePointLight${S("x",r)}${S("y",i)}${S("z",o)}/>`,u+="</feSpecularLighting>",u+=`<feComposite${S("in",e)}${S("in2",`${n}_diffuse`)}${S("operator","arithmetic")}${S("k1",1)}${S("k2",0)}${S("k3",0)}${S("k4",0)}${S("result",`${n}_lit`)}/>`,u+=`<feComposite${S("in",`${n}_specular`)}${S("in2",`${n}_lit`)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",1)}${S("k3",1)}${S("k4",0)}${S("result",n)}/>`,u}function Hv(t,e,n){let{x:r,y:i,z:o,pointsAtX:s,pointsAtY:a,pointsAtZ:c,coneAngle:l,color:d,surfaceScale:u,specularConstant:p,specularExponent:f}=t,m="";return m+=`<feSpecularLighting${S("in","SourceAlpha")}${S("surfaceScale",u)}${S("specularConstant",p)}${S("specularExponent",f)}${S("lighting-color",d)}${S("result",`${n}_specular`)}>`,m+=`<feSpotLight${S("x",r)}${S("y",i)}${S("z",o)}${S("pointsAtX",s)}${S("pointsAtY",a)}${S("pointsAtZ",c)}${S("limitingConeAngle",l)}/>`,m+="</feSpecularLighting>",m+=`<feComposite${S("in",`${n}_specular`)}${S("in2","SourceAlpha")}${S("operator","in")}${S("result",`${n}_clipped`)}/>`,m+=`<feComposite${S("in",`${n}_clipped`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",1)}${S("k3",1)}${S("k4",0)}${S("result",n)}/>`,m}function Wv(t){switch(t.kind){case"point":return`<fePointLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}/>`;case"spot":{let e=`<feSpotLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}${S("pointsAtX",t.pointsAtX)}${S("pointsAtY",t.pointsAtY)}${S("pointsAtZ",t.pointsAtZ)}`;return t.limitingConeAngle!==void 0&&(e+=S("limitingConeAngle",t.limitingConeAngle)),t.specularExponent!==void 0&&(e+=S("specularExponent",t.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${S("azimuth",t.azimuth)}${S("elevation",t.elevation)}/>`}}function QN(t,e,n){return`<feDiffuseLighting${S("in",e)}${S("surfaceScale",t.surfaceScale)}${S("diffuseConstant",t.diffuseConstant)}${S("lighting-color",t.color)}${S("result",n)}>`+Wv(t.lightSource)+"</feDiffuseLighting>"}function eA(t,e,n){return`<feSpecularLighting${S("in",e)}${S("surfaceScale",t.surfaceScale)}${S("specularConstant",t.specularConstant)}${S("specularExponent",t.specularExponent)}${S("lighting-color",t.color)}${S("result",n)}>`+Wv(t.lightSource)+"</feSpecularLighting>"}function tA(t,e,n){let{width:r,color:i,opacity:o,position:s}=t,a="";if(s==="inside")a+=`<feMorphology${S("in","SourceAlpha")}${S("operator","erode")}${S("radius",r)}${S("result",`${n}_eroded`)}/>`,a+=`<feComposite${S("in","SourceAlpha")}${S("in2",`${n}_eroded`)}${S("operator","out")}${S("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${S("flood-color",i)}${S("flood-opacity",o)}${S("result",`${n}_color`)}/>`,a+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_outlineAlpha`)}${S("operator","in")}${S("result",`${n}_outline`)}/>`,a+=`<feComposite${S("in",`${n}_outline`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`;else{let c=s==="outside"?r:r/2;a+=`<feMorphology${S("in","SourceAlpha")}${S("operator","dilate")}${S("radius",c)}${S("result",`${n}_dilated`)}/>`,a+=`<feComposite${S("in",`${n}_dilated`)}${S("in2","SourceAlpha")}${S("operator","out")}${S("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${S("flood-color",i)}${S("flood-opacity",o)}${S("result",`${n}_color`)}/>`,a+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_outlineAlpha`)}${S("operator","in")}${S("result",`${n}_outline`)}/>`,a+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_outline`)}/><feMergeNode${S("in",e)}/></feMerge>`}return a}function nA(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=1+4*r,o=-r,s=[0,o,0,o,i,o,0,o,0].join(" ");return`<feConvolveMatrix${S("in",e)}${S("order","3")}${S("kernelMatrix",s)}${S("divisor","1")}${S("bias","0")}${S("preserveAlpha","true")}${S("edgeMode","duplicate")}${S("result",n)}/>`}function rA(t,e,n){let{blockSize:r}=t;if(r<=1)return De(e,n);let i=r/2,o="";return o+=`<feMorphology${S("in",e)}${S("operator","erode")}${S("radius",i)}${S("result",`${n}_eroded`)}/>`,o+=`<feMorphology${S("in",`${n}_eroded`)}${S("operator","dilate")}${S("radius",i)}${S("result",n)}/>`,o}function iA(t,e,n){let{scale:r,frequency:i,octaves:o,warpType:s}=t;if(r===0)return De(e,n);let a="";return a+=`<feTurbulence${S("type",s)}${S("baseFrequency",i)}${S("numOctaves",o)}${S("seed",0)}${S("result",`${n}_turbulence`)}/>`,a+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_turbulence`)}${S("scale",r)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",n)}/>`,a}function oA(t,e,n){let{operator:r,radiusX:i,radiusY:o}=t;return i===0&&o===0?De(e,n):`<feMorphology${S("in",e)}${S("operator",r)}${S("radius",`${i} ${o}`)}${S("result",n)}/>`}function sA(t,e,n){let{levels:r}=t;if(r<2)return De(e,n);let i=[];for(let a=0;a<r;a++)i.push(a/(r-1));let o=i.join(" "),s=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return s+=`<feFuncR${S("type","discrete")}${S("tableValues",o)}/>`,s+=`<feFuncG${S("type","discrete")}${S("tableValues",o)}/>`,s+=`<feFuncB${S("type","discrete")}${S("tableValues",o)}/>`,s+="</feComponentTransfer>",s}function aA(t,e,n){let{levels:r,contrast:i}=t;if(r<2)return De(e,n);let o=[];for(let c=0;c<r;c++){let l=c/(r-1),d=l;i!==1&&(d=.5+(l-.5)*i,d=Math.max(0,Math.min(1,d))),o.push(d)}let s=o.join(" "),a=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return a+=`<feFuncR${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function cA(t,e,n){let{radius:r}=t;if(r===0)return De(e,n);let i="";return i+=`<feGaussianBlur${S("in","SourceAlpha")}${S("stdDeviation",r)}${S("result",`${n}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${S("in",`${n}_blurredAlpha`)}${S("result",`${n}_thresholdAlpha`)}><feFuncA${S("type","linear")}${S("slope",20)}${S("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${S("in",e)}${S("in2",`${n}_thresholdAlpha`)}${S("operator","in")}${S("result",n)}/>`,i}function lA(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=1-r;return`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","saturate")}${S("values",i)}${S("result",n)}/>`}function dA(t,e,n){let{red:r,green:i,blue:o}=t;if(r===1&&i===1&&o===1)return De(e,n);let s=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return s+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,s+=`<feFuncG${S("type","linear")}${S("slope",i)}${S("intercept",0)}/>`,s+=`<feFuncB${S("type","linear")}${S("slope",o)}${S("intercept",0)}/>`,s+="</feComponentTransfer>",s}function uA(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return i+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+=`<feFuncG${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+=`<feFuncB${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+="</feComponentTransfer>",i}function pA(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=.5*(1-r),o=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return o+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+=`<feFuncG${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+=`<feFuncB${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+="</feComponentTransfer>",o}function fA(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return i+=`<feFuncA${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+="</feComponentTransfer>",i}function mA(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=r,o=1-r,s=`${i} ${o}`,a=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return a+=`<feFuncR${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function gA(t,e,n){let{angle:r}=t;return r===0||r===360?De(e,n):`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","hueRotate")}${S("values",r)}${S("result",n)}/>`}function hA(t,e,n){let{amount:r}=t;return r===1?De(e,n):`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","saturate")}${S("values",r)}${S("result",n)}/>`}function yA(t,e,n){let{threshold:r}=t,i="";if(i+=`<feColorMatrix${S("in",e)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`,r===.5)i+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,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 s=[];for(let c=0;c<256;c++)s.push(c/255<r?0:1);let a=s.join(" ");i+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,i+=`<feFuncR${S("type","table")}${S("tableValues",a)}/>`,i+=`<feFuncG${S("type","table")}${S("tableValues",a)}/>`,i+=`<feFuncB${S("type","table")}${S("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function SA(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=[.393,.769,.189,0,0],o=[.349,.686,.168,0,0],s=[.272,.534,.131,0,0],a=[1,0,0,0,0],c=[0,1,0,0,0],l=[0,0,1,0,0],d=(g,h)=>g.map((y,b)=>y*(1-r)+h[b]*r),u=d(a,i),p=d(c,o),f=d(l,s),m=[...u,...p,...f,0,0,0,1,0].join(" ");return`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","matrix")}${S("values",m)}${S("result",n)}/>`}function bA(t,e,n){let{shadowColor:r,highlightColor:i}=t,o=yd(r),s=yd(i),a="";return a+=`<feColorMatrix${S("in",e)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`,a+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,a+=`<feFuncR${S("type","table")}${S("tableValues",`${o.r} ${s.r}`)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",`${o.g} ${s.g}`)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",`${o.b} ${s.b}`)}/>`,a+="</feComponentTransfer>",a}function vA(t,e,n){let{intensity:r}=t;if(r===0)return De(e,n);let i="";i+=`<feComponentTransfer${S("in",e)}${S("result",`${n}_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",`${n}_invert`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`;let o=[.1,.1,.1,0,0],s=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],c=[1,0,0,0,0],l=[0,1,0,0,0],d=[0,0,1,0,0],u=(h,y)=>h.map((b,v)=>b*(1-r)+y[v]*r),p=u(c,o),f=u(l,s),m=u(d,a),g=[...p,...f,...m,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${S("in",`${n}_gray`)}${S("type","matrix")}${S("values",g)}${S("result",n)}/>`,i}function xA(t,e,n){let{amount:r,scale:i}=t;if(r===0)return De(e,n);let o=1/i,s="";return s+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",o)}${S("numOctaves",3)}${S("seed",0)}${S("result",`${n}_noise`)}/>`,s+=`<feColorMatrix${S("in",`${n}_noise`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_noiseGray`)}/>`,s+=`<feBlend${S("in",e)}${S("in2",`${n}_noiseGray`)}${S("mode","overlay")}${S("result",`${n}_blended`)}/>`,s+=`<feComposite${S("in",`${n}_blended`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",r)}${S("k3",1-r)}${S("k4",0)}${S("result",`${n}_amt`)}/>`,s+=`<feComposite${S("in",`${n}_amt`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,s}function IA(t,e,n){let{strength:r,angle:i}=t;if(r===0)return De(e,n);let o=i*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=r,l=[-(c*(s+a)),-(c*a),c*(-s+a),-(c*s),1,c*s,c*(s-a),c*a,c*(s+a)].join(" ");return`<feConvolveMatrix${S("in",e)}${S("order","3 3")}${S("kernelMatrix",l)}${S("divisor",1)}${S("bias",.5)}${S("preserveAlpha","true")}${S("result",n)}/>`}function wA(t,e,n){let{amount:r,size:i}=t;if(r===0)return De(e,n);let o=.5/i,s="";return s+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",`${o} ${o}`)}${S("numOctaves",5)}${S("seed",0)}${S("stitchTiles","stitch")}${S("result",`${n}_grain`)}/>`,s+=`<feColorMatrix${S("in",`${n}_grain`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_grainGray`)}/>`,s+=`<feBlend${S("in",e)}${S("in2",`${n}_grainGray`)}${S("mode","soft-light")}${S("result",`${n}_blended`)}/>`,s+=`<feComposite${S("in",`${n}_blended`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",r)}${S("k3",1-r)}${S("k4",0)}${S("result",`${n}_amt`)}/>`,s+=`<feComposite${S("in",`${n}_amt`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,s}function kA(t,e,n){let{wetness:r,turbulence:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",.02+i*.03)}${S("numOctaves",4)}${S("seed",42)}${S("result",`${n}_turb`)}/>`,o+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_turb`)}${S("scale",r*15)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${S("in",`${n}_disp`)}${S("stdDeviation",r*2)}${S("result",`${n}_blur`)}/>`,o+=`<feBlend${S("in",`${n}_blur`)}${S("in2",e)}${S("mode","multiply")}${S("result",n)}/>`,o}function PA(t,e,n){let{thickness:r,texture:i}=t;if(r===0&&i===0)return De(e,n);let o="";o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.03+i*.02)}${S("numOctaves",3)}${S("seed",1e3)}${S("result",`${n}_brush`)}/>`;let s=Math.max(3,8-Math.floor(r*5)),a=Array.from({length:s+1},(c,l)=>l/s).join(" ");o+=`<feComponentTransfer${S("in",e)}${S("result",`${n}_poster`)}>`;for(let c of["R","G","B"])o+=`<feFunc${c}${S("type","discrete")}${S("tableValues",a)}/>`;return o+="</feComponentTransfer>",o+=`<feDisplacementMap${S("in",`${n}_poster`)}${S("in2",`${n}_brush`)}${S("scale",i*4)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feMorphology${S("in",`${n}_disp`)}${S("operator","dilate")}${S("radius",r*.5)}${S("result",`${n}_thick`)}/>`,o+=`<feComposite${S("in",`${n}_thick`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,o}function TA(t,e,n){let{spread:r,edges:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",.01+i*.02)}${S("numOctaves",5)}${S("seed",1100)}${S("result",`${n}_ink`)}/>`,o+=`<feMorphology${S("in",e)}${S("operator","dilate")}${S("radius",r*3)}${S("result",`${n}_dilate`)}/>`,o+=`<feDisplacementMap${S("in",`${n}_dilate`)}${S("in2",`${n}_ink`)}${S("scale",i*10)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${S("in",`${n}_disp`)}${S("stdDeviation",r*.5)}${S("result",n)}/>`,o}function RA(t,e,n){let{wrinkles:r,shine:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.02)}${S("numOctaves",4)}${S("seed",1200)}${S("result",`${n}_wrinkle`)}/>`,o+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_wrinkle`)}${S("scale",r*15)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feSpecularLighting${S("in",`${n}_wrinkle`)}${S("surfaceScale",r*2)}${S("specularConstant",i*1.5)}${S("specularExponent",20)}${S("result",`${n}_sheen`)}>`,o+=`<feDistantLight${S("azimuth",45)}${S("elevation",60)}/>`,o+="</feSpecularLighting>",o+=`<feBlend${S("in",`${n}_disp`)}${S("in2",`${n}_sheen`)}${S("mode","screen")}${S("result",`${n}_blend`)}/>`,o+=`<feComposite${S("in",`${n}_blend`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,o}function CA(t,e,n){let{density:r,size:i}=t;if(r===0)return De(e,n);let o="",s=1-r;o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.1/i)}${S("numOctaves",1)}${S("seed",1400)}${S("result",`${n}_hole`)}/>`,o+=`<feComponentTransfer${S("in",`${n}_hole`)}${S("result",`${n}_thresh`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${S("type","linear")}${S("slope",10)}${S("intercept",-s*10+5)}/>`;o+="</feComponentTransfer>",o+=`<feComponentTransfer${S("in",`${n}_thresh`)}${S("result",`${n}_clamp`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${S("type","table")}${S("tableValues","0 0 1 1")}/>`;return o+="</feComponentTransfer>",o+=`<feComposite${S("in",e)}${S("in2",`${n}_clamp`)}${S("operator","in")}${S("result",n)}/>`,o}function $A(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return De(e,n);let{r:s,g:a,b:c}=yd(r),l="";return l+=`<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",`${n}_alpha`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_alpha`)}${S("stdDeviation",i/2)}${S("result",`${n}_blur`)}/>`,l+=`<feColorMatrix${S("in",`${n}_blur`)}${S("type","matrix")}${S("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${c} 0 0 0 ${o} 0`)}${S("result",`${n}_color`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_color`)}/><feMergeNode${S("in",e)}/></feMerge>`,l}function NA(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return De(e,n);let{r:s,g:a,b:c}=yd(r),l="";return l+=`<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",`${n}_alpha`)}/>`,l+=`<feMorphology${S("in",`${n}_alpha`)}${S("operator","erode")}${S("radius",i/4)}${S("result",`${n}_erode`)}/>`,l+=`<feComposite${S("in",`${n}_alpha`)}${S("in2",`${n}_erode`)}${S("operator","out")}${S("result",`${n}_edge`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_edge`)}${S("stdDeviation",i/3)}${S("result",`${n}_blur`)}/>`,l+=`<feColorMatrix${S("in",`${n}_blur`)}${S("type","matrix")}${S("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${c} 0 0 0 ${o*2} 0`)}${S("result",`${n}_color`)}/>`,l+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_alpha`)}${S("operator","in")}${S("result",`${n}_clipped`)}/>`,l+=`<feComposite${S("in",`${n}_clipped`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`,l}function De(t,e){return`<feMerge${S("result",e)}><feMergeNode${S("in",t)}/></feMerge>`}function Sd(t){switch(t.type){case"feBlend":return AA(t);case"feColorMatrix":return EA(t);case"feComponentTransfer":return MA(t);case"feComposite":return OA(t);case"feConvolveMatrix":return DA(t);case"feDiffuseLighting":return zA(t);case"feSpecularLighting":return _A(t);case"feDisplacementMap":return FA(t);case"feDropShadow":return LA(t);case"feFlood":return BA(t);case"feGaussianBlur":return GA(t);case"feImage":return VA(t);case"feMerge":return jA(t);case"feMorphology":return UA(t);case"feOffset":return HA(t);case"feTile":return WA(t);case"feTurbulence":return KA(t)}}function xt(t){let e="";if(e+=S("in",t.in),e+=S("x",t.x),e+=S("y",t.y),e+=S("width",t.width),e+=S("height",t.height),e+=S("color-interpolation-filters",t.colorInterpolationFilters),e+=S("result",t.result),t.unknownAttrs){let n=Object.keys(t.unknownAttrs).sort();for(let r of n)e+=S(r,t.unknownAttrs[r])}return e}function It(t){return t.animations&&t.animations.length>0?t.animations.join(""):""}function AA(t){let e=`<feBlend${xt(t)}${S("in2",t.in2)}${S("mode",t.mode)}`;t.noComposite&&(e+=' no-composite="no-composite"');let n=It(t);return n?`${e}>${n}</feBlend>`:`${e}/>`}function EA(t){let e=`<feColorMatrix${xt(t)}${S("type",t.matrixType)}${S("values",t.values)}`,n=It(t);return n?`${e}>${n}</feColorMatrix>`:`${e}/>`}function hd(t,e){if(!e)return"";let n=`feFunc${t}`;switch(e.type){case"identity":return`<${n} type="identity"/>`;case"table":case"discrete":return`<${n} type="${e.type}"${S("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${n} type="linear"${S("slope",e.slope)}${S("intercept",e.intercept)}/>`;case"gamma":return`<${n} type="gamma"${S("amplitude",e.amplitude)}${S("exponent",e.exponent)}${S("offset",e.offset)}/>`}}function MA(t){let e="";return e+=hd("R",t.funcR),e+=hd("G",t.funcG),e+=hd("B",t.funcB),e+=hd("A",t.funcA),e+=It(t),`<feComponentTransfer${xt(t)}>${e}</feComponentTransfer>`}function OA(t){let e=`<feComposite${xt(t)}${S("in2",t.in2)}${S("operator",t.operator)}`;t.operator==="arithmetic"&&(e+=S("k1",t.k1),e+=S("k2",t.k2),e+=S("k3",t.k3),e+=S("k4",t.k4));let n=It(t);return n?`${e}>${n}</feComposite>`:`${e}/>`}function DA(t){let e=`<feConvolveMatrix${xt(t)}`;e+=S("order",t.order),e+=S("kernelMatrix",t.kernelMatrix),e+=S("divisor",t.divisor),e+=S("bias",t.bias),e+=S("targetX",t.targetX),e+=S("targetY",t.targetY),e+=S("edgeMode",t.edgeMode),e+=S("kernelUnitLength",t.kernelUnitLength),t.preserveAlpha!==void 0&&(e+=S("preserveAlpha",t.preserveAlpha?"true":"false"));let n=It(t);return n?`${e}>${n}</feConvolveMatrix>`:`${e}/>`}function Kv(t){switch(t.kind){case"feDistantLight":return`<feDistantLight${S("azimuth",t.azimuth)}${S("elevation",t.elevation)}/>`;case"fePointLight":return`<fePointLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}${S("pointsAtX",t.pointsAtX)}${S("pointsAtY",t.pointsAtY)}${S("pointsAtZ",t.pointsAtZ)}`;return e+=S("specularExponent",t.specularExponent),e+=S("limitingConeAngle",t.limitingConeAngle),e+"/>"}}}function zA(t){let e=`<feDiffuseLighting${xt(t)}`;e+=S("surfaceScale",t.surfaceScale),e+=S("diffuseConstant",t.diffuseConstant),e+=S("kernelUnitLength",t.kernelUnitLength),e+=S("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=Kv(t.lightSource)),n+=It(t),`${e}>${n}</feDiffuseLighting>`}function _A(t){let e=`<feSpecularLighting${xt(t)}`;e+=S("surfaceScale",t.surfaceScale),e+=S("specularConstant",t.specularConstant),e+=S("specularExponent",t.specularExponent),e+=S("kernelUnitLength",t.kernelUnitLength),e+=S("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=Kv(t.lightSource)),n+=It(t),`${e}>${n}</feSpecularLighting>`}function FA(t){let e=`<feDisplacementMap${xt(t)}`;e+=S("in2",t.in2),e+=S("scale",t.scale),e+=S("xChannelSelector",t.xChannelSelector),e+=S("yChannelSelector",t.yChannelSelector);let n=It(t);return n?`${e}>${n}</feDisplacementMap>`:`${e}/>`}function LA(t){let e=`<feDropShadow${xt(t)}`;e+=S("dx",t.dx),e+=S("dy",t.dy),e+=S("stdDeviation",t.stdDeviation),e+=S("flood-color",t.floodColor),e+=S("flood-opacity",t.floodOpacity);let n=It(t);return n?`${e}>${n}</feDropShadow>`:`${e}/>`}function BA(t){let e=`<feFlood${xt(t)}${S("flood-color",t.floodColor)}${S("flood-opacity",t.floodOpacity)}`,n=It(t);return n?`${e}>${n}</feFlood>`:`${e}/>`}function GA(t){let e=`<feGaussianBlur${xt(t)}${S("stdDeviation",t.stdDeviation)}${S("edgeMode",t.edgeMode)}`,n=It(t);return n?`${e}>${n}</feGaussianBlur>`:`${e}/>`}function VA(t){let e=`<feImage${xt(t)}`;t.href!==void 0?e+=S("href",t.href):t.xlinkHref!==void 0&&(e+=S("xlink:href",t.xlinkHref)),e+=S("preserveAspectRatio",t.preserveAspectRatio),e+=S("crossorigin",t.crossorigin);let n=It(t);return n?`${e}>${n}</feImage>`:`${e}/>`}function jA(t){let e="";for(let n of t.nodes)e+=`<feMergeNode${S("in",n.in)}/>`;return e+=It(t),`<feMerge${xt(t)}>${e}</feMerge>`}function UA(t){let e=`<feMorphology${xt(t)}${S("operator",t.operator)}${S("radius",t.radius)}`,n=It(t);return n?`${e}>${n}</feMorphology>`:`${e}/>`}function HA(t){let e=`<feOffset${xt(t)}${S("dx",t.dx)}${S("dy",t.dy)}`,n=It(t);return n?`${e}>${n}</feOffset>`:`${e}/>`}function WA(t){let e=`<feTile${xt(t)}`,n=It(t);return n?`${e}>${n}</feTile>`:`${e}/>`}function KA(t){let e=`<feTurbulence${xt(t)}`;e+=S("baseFrequency",t.baseFrequency),e+=S("numOctaves",t.numOctaves),e+=S("seed",t.seed),e+=S("stitchTiles",t.stitchTiles),e+=S("type",t.turbulenceType);let n=It(t);return n?`${e}>${n}</feTurbulence>`:`${e}/>`}function Em(t,e){let n=`<filter${S("id",t)}`;n+=S("x",e.x),n+=S("y",e.y),n+=S("width",e.width),n+=S("height",e.height),n+=S("filterUnits",e.filterUnits),n+=S("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(n+=S("color-interpolation-filters",e.filterColorInterpolation)),n+=S("flood-color",e.floodColor),n+=S("flood-opacity",e.floodOpacity),n+=S("lighting-color",e.lightingColor),n+=">",e.filterTitle&&(n+=`<title>${fe(e.filterTitle)}</title>`),e.filterDescription&&(n+=`<desc>${fe(e.filterDescription)}</desc>`);for(let r of e.primitives)n+=Sd(r);if(e.filterAnimations)for(let r of e.filterAnimations)n+=r;return n+="</filter>",n}function Mm(t,e,n,r){switch(t.type){case"drop-shadow":return YN(t,e,n);case"inner-shadow":return qN(t,e,n);case"gaussian-blur":return ZN(t,e,n);case"motion-blur":return JN(t,e,n);case"point-light":{let i=t;return Uv(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,n)}case"spot-light":{let i=t;return Hv(r?{...i,x:i.x+r.x,y:i.y+r.y,pointsAtX:i.pointsAtX+r.x,pointsAtY:i.pointsAtY+r.y}:i,e,n)}case"diffuse-lighting":return QN(t,e,n);case"specular-lighting":return eA(t,e,n);case"outline":return tA(t,e,n);case"sharpen":return nA(t,e,n);case"pixelate":return rA(t,e,n);case"warp":return iA(t,e,n);case"morphology":return oA(t,e,n);case"contouring-discrete":return sA(t,e,n);case"contouring-table":return aA(t,e,n);case"round-edges":return cA(t,e,n);case"grayscale":return lA(t,e,n);case"channel-painter":return dA(t,e,n);case"brightness":return uA(t,e,n);case"contrast":return pA(t,e,n);case"opacity":return fA(t,e,n);case"invert":return mA(t,e,n);case"hue-rotate":return gA(t,e,n);case"saturate":return hA(t,e,n);case"black-and-white":return yA(t,e,n);case"sepia":return SA(t,e,n);case"duotone":return bA(t,e,n);case"xray":return vA(t,e,n);case"noise":return xA(t,e,n);case"emboss":return IA(t,e,n);case"film-grain":return wA(t,e,n);case"watercolor":return kA(t,e,n);case"gouache":return PA(t,e,n);case"ink-blot":return TA(t,e,n);case"crumpled-plastic":return RA(t,e,n);case"riddled":return CA(t,e,n);case"glow":return $A(t,e,n);case"inner-glow":return NA(t,e,n);case"raw-svg":return t.svgContent;case"svg-primitive-chain":return t.primitives.map(Sd).join("");default:return De(e,n)}}function ea(t,e,n={}){let r=gd(t,e,n);if(!r)return"";if(r.kind==="primitive-chain")return Em(t,r.chain);let i=r.attributes.map(([c,l])=>S(c,l)).join("");if(r.kind==="raw")return`<filter${i}>${r.content}</filter>`;let o="",s="SourceGraphic",a=0;for(let c of r.filters){let l=`result${a++}`;o+=Mm(c,s,l),s=l}return`<filter${i}>${o}</filter>`}function Xv(t){let e="",n=new Set;for(let r of t){let i=r.state.filters;if(!i||i.length===0)continue;let o=i.filter(l=>l.enabled);if(o.length===0)continue;let s=r.state.filterLibraryIds,a=Array.isArray(s)&&s.length>0?s[0]:`filter-${r.id}`;if(n.has(a))continue;n.add(a);let c=r.state;e+=ea(a,o,{colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight})}return e}function ta(t,e,n){return!e||e.length===0||e.filter(i=>i.enabled).length===0?null:Array.isArray(n)&&n.length>0?n.map(i=>`url(#${fe(i)})`).join(" "):`url(#filter-${fe(t)})`}function Yv(t,e,n){let r=ta(t,e,n);return r===null?"":` filter="${r}"`}var ve=(t,e,n={})=>({channel:"attribute",name:t,value:e,...n}),Om=/^[A-Za-z_][\w:.-]*$/,bd=(t,e)=>({channel:"style",name:t,value:e});function Ke(t){return typeof t=="string"?t:null}function zr(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Dm(t){return Ke(t("fillType"))??"solid"}function xd(t){return t("fillGradient")}function Jv(t){if(!t||typeof t!="object")return;let e=t.id;return typeof e=="string"&&e.length>0?e:void 0}function XA(t){let e=Ke(t("fillLibraryId"))??Jv(xd(t));return e?`url(#${e})`:"none"}function YA(t){let e=Ke(t("strokeLibraryId"))??Jv(t("strokeGradient"));return e?`url(#${e})`:"none"}function qv(t,e){let n=Ke(t(`${e}Type`))??(e==="fill"?Dm(t):"solid"),r=e==="fill"?xd(t):t("strokeGradient");if(t(e==="fill"?"inheritFill":"inheritStroke")===!0&&n==="solid"&&!r||n==="none")return null;let i=zr(t(`${e}Opacity`))??1,o=r&&typeof r=="object"?zr(r.opacity)??1:1,s=i*o;return s<1?s:t(e==="fill"?"preserveFillOpacity":"preserveStrokeOpacity")===!0?1:null}function qA(t){let e=Ke(t("strokeDasharray"));return e||rl(Ke(t("lineStyle"))??"solid",zr(t("dashLength"))??8,zr(t("gapLength"))??4)}function Zv(t){if(!Ke(t("strokeDasharray"))&&Ke(t("lineStyle"))==="dotted")return"round";let n=Ke(t("strokeLinecap"));return n&&n!=="butt"?n:null}function vd(t,e,n={}){if(!t||typeof t!="object"||Array.isArray(t))return[];let r=[];for(let[i,o]of Object.entries(t))typeof o=="string"&&(e==="attribute"&&!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(i)||r.push({channel:e,name:i,value:o,...n}));return r}var na=[{id:"fill",keys:["fillColor","fillType","fillGradient","fillLibraryId","inheritFill"],project:(t,e)=>{let n=Dm(t);return t("inheritFill")===!0&&n==="solid"&&!xd(t)?[ve("fill",null)]:n==="none"?[ve("fill","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[ve("fill",XA(t))]:[ve("fill",Ke(t("fillColor"))??"#000000")]}},{id:"element-opacity",keys:["opacity","preserveOpacity"],project:t=>{let e=zr(t("opacity")),n=t("preserveOpacity")===!0;return[ve("opacity",e!==null&&(e<1||n)?e:null)]}},{id:"fill-opacity",keys:["fillOpacity","preserveFillOpacity","fillType","fillGradient","inheritFill"],project:t=>[ve("fill-opacity",qv(t,"fill"))]},{id:"fill-rule",keys:["fillRule"],project:t=>{let e=Ke(t("fillRule"));return[ve("fill-rule",e&&e!=="nonzero"?e:null)]}},{id:"stroke",keys:["borderColor","strokeType","strokeGradient","strokeLibraryId","inheritStroke"],project:(t,e)=>{let n=Ke(t("strokeType"))??"solid";return t("inheritStroke")===!0&&n==="solid"&&!t("strokeGradient")?[ve("stroke",null)]:n==="none"?[ve("stroke","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[ve("stroke",YA(t))]:[ve("stroke",Ke(t("borderColor"))??"none")]}},{id:"stroke-width",keys:["borderWidth"],project:t=>{let e=t("borderWidth");return[ve("stroke-width",typeof e=="number"||typeof e=="string"?e:null)]}},{id:"stroke-opacity",keys:["strokeOpacity","preserveStrokeOpacity","strokeType","strokeGradient","inheritStroke"],project:t=>[ve("stroke-opacity",qv(t,"stroke"))]},{id:"blend-mode",keys:["blendMode"],project:t=>{let e=Ke(t("blendMode"));return[bd("mix-blend-mode",e&&e!=="normal"?e:null)]}},{id:"paint-order",keys:["paintOrder"],project:t=>{let e=Ke(t("paintOrder"));return[ve("paint-order",e&&e!=="normal"?e:null)]}},{id:"inline-style",keys:["inlineStyle"],project:t=>vd(t("inlineStyle"),"style")},{id:"markers",keys:["markerStart","markerMid","markerEnd"],project:t=>[["marker-start",t("markerStart")],["marker-mid",t("markerMid")],["marker-end",t("markerEnd")]].map(([e,n])=>ve(String(e),typeof n=="string"&&n?`url(#${n})`:null))},{id:"stroke-linejoin",keys:["strokeLinejoin"],project:t=>{let e=Ke(t("strokeLinejoin"));return[ve("stroke-linejoin",e&&e!=="miter"?e:null)]}},{id:"stroke-linecap",keys:["strokeLinecap"],project:t=>[ve("stroke-linecap",Zv(t))]},{id:"stroke-miterlimit",keys:["strokeMiterlimit"],project:t=>{let e=zr(t("strokeMiterlimit"));return[ve("stroke-miterlimit",e!==null&&e!==4?e:null)]}},{id:"stroke-dasharray",keys:["lineStyle","dashLength","gapLength","strokeDasharray","strokeLinecap"],project:t=>[ve("stroke-dasharray",qA(t)),ve("stroke-linecap",Zv(t))]},{id:"stroke-dashoffset",keys:["dashOffset"],project:t=>{let e=zr(t("dashOffset"));return[ve("stroke-dashoffset",e!==null&&e!==0?e:null)]}},{id:"shape-rendering",keys:["shapeRendering"],project:t=>{let e=Ke(t("shapeRendering"));return[ve("shape-rendering",e&&e!=="auto"?e:null)]}},{id:"text-rendering",keys:["textRendering"],project:t=>{let e=Ke(t("textRendering"));return[ve("text-rendering",e&&e!=="auto"?e:null)]}},{id:"image-rendering",keys:["imageRendering"],project:t=>{let e=Ke(t("imageRendering"));return[ve("image-rendering",e&&e!=="auto"?e:null)]}},{id:"color-rendering",keys:["colorRendering"],project:t=>{let e=Ke(t("colorRendering"));return[ve("color-rendering",e&&e!=="auto"?e:null)]}},{id:"color-interpolation",keys:["colorInterpolation"],project:t=>{let e=Ke(t("colorInterpolation"));return[ve("color-interpolation",e&&e!=="sRGB"?e:null)]}},{id:"filter",keys:["filters","filterLibraryIds"],project:(t,e)=>[ve("filter",ta(e.shapeId,t("filters"),t("filterLibraryIds")))]},{id:"system-language",keys:["systemLanguage"],project:t=>{let e=t("systemLanguage");return[ve("systemLanguage",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"required-extensions",keys:["requiredExtensions"],project:t=>{let e=t("requiredExtensions");return[ve("requiredExtensions",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"vector-effect",keys:["vectorEffect"],project:t=>{let e=Ke(t("vectorEffect"));return[ve("vector-effect",e&&e!=="none"?e:null)]}},{id:"visibility",keys:["visibility"],project:t=>{let e=Ke(t("visibility"));return[ve("visibility",e&&e!=="visible"?e:null)]}},{id:"display",keys:["displayAttr"],project:t=>{let e=Ke(t("displayAttr"));return[ve("display",e&&e!=="inline"?e:null)]}},{id:"visible",keys:["visible"],project:t=>[bd("display",t("visible")===!1?"none":null)]},{id:"path-length",keys:["pathLength"],project:t=>{let e=zr(t("pathLength"));return[ve("pathLength",e!==null&&e>=0?e:null)]}},{id:"transform-box",keys:["transformBox"],project:t=>{let e=Ke(t("transformBox"));return[bd("transform-box",e&&e!=="view-box"?e:null)]}},{id:"transform",keys:["rotation","transformMatrix","translateX","translateY","skewX","skewY","scaleX","scaleY","customPivot","rawTransform"],project:()=>[]},{id:"locked",keys:["locked"],project:()=>[]},{id:"metadata",keys:["metadata"],project:t=>{let e=t("metadata"),n=[],r=e?.name?Gn(e.name):"";if(n.push(ve("id",r||null)),n.push(ve("class",e?.classes&&e.classes.length>0?e.classes.join(" "):null)),n.push(ve("role",e?.role??null)),n.push(ve("aria-label",e?.ariaLabel??null)),e?.aria)for(let[i,o]of Object.entries(e.aria))i!=="aria-label"&&Om.test(i)&&n.push(ve(i,o));if(n.push(ve("xml:lang",e?.lang??null)),typeof e?.tabindex=="number"&&Number.isFinite(e.tabindex)&&n.push(ve("tabindex",String(Math.trunc(e.tabindex)))),e?.autofocus&&n.push(ve("autofocus","",{allowEmpty:!0})),n.push(ve("xml:space",e?.xmlSpace??null)),e?.customData)for(let[i,o]of Object.entries(e.customData)){let s=`data-${i}`;Om.test(s)&&n.push(ve(s,o))}if(e?.foreignAttrs)for(let i of e.foreignAttrs)Om.test(i.name)&&n.push(ve(i.name,i.value));return n}},{id:"css-clip-path",keys:["cssClipPath"],project:t=>[bd("clip-path",Ke(t("cssClipPath")))]},{id:"css-mask-properties",keys:["cssMaskProperties"],project:t=>vd(t("cssMaskProperties"),"style")},{id:"container-presentation",keys:["containerPresentation"],project:(t,e)=>e.includeContainerPresentation?vd(t("containerPresentation"),"attribute",{ifAbsent:!0}):[]},{id:"authored-attributes",keys:["authoredAttributes"],project:(t,e)=>e.includeAuthoredAttributes?vd(t("authoredAttributes"),"attribute",{ifAbsent:!0}):[]}];function Id(t,e,n){return t.project(e,n)}function fo(t,e){return na.flatMap(n=>n.project(t,e))}function Ii(t){let e=t;return n=>n==="displayAttr"?t.display:e[n]}function zm(t){return Dm(e=>t[e])}function Qv(t){return xd(e=>t[e])}var ZA=[["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 fe(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function wd(t){let e=new Map,n=new Map,r=t.state,i=r;switch(t.type){case"circle":e.set("cx",String(r.x??0)),e.set("cy",String(r.y??0)),e.set("r",String(r.radius??50));break;case"ellipse":e.set("cx",String(r.cx??0)),e.set("cy",String(r.cy??0)),e.set("rx",String(r.rx??50)),e.set("ry",String(r.ry??30));break;case"rectangle":case"square":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),e.set("width",String(r.width??100)),e.set("height",String(r.height??100));{let c=r.rx??r.cornerRadius??0,l=r.ry??r.cornerRadius??0;(c>0||l>0)&&(e.set("rx",String(c)),e.set("ry",String(l)))}break;case"line":e.set("x1",String(r.x1??0)),e.set("y1",String(r.y1??0)),e.set("x2",String(r.x2??0)),e.set("y2",String(r.y2??0));break;case"text":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),r.fontSize&&e.set("font-size",String(r.fontSize)),r.fontFamily&&e.set("font-family",r.fontFamily),r.fontWeight&&e.set("font-weight",String(r.fontWeight)),r.fontStyle&&e.set("font-style",r.fontStyle),r.textAnchor&&e.set("text-anchor",r.textAnchor),r.letterSpacing&&e.set("letter-spacing",String(r.letterSpacing));for(let[c,l]of ZA){let d=typeof r[c]=="string"?String(r[c]).trim():"";d&&n.set(l,d)}break;case"image":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),e.set("width",String(r.width??100)),e.set("height",String(r.height??100)),i.href&&e.set("href",String(i.href));break}for(let c of fo(Ii(r),{shapeId:t.id,includeAuthoredAttributes:!0})){if(c.channel==="style"){n.delete(c.name),c.value!==null&&c.value!==""&&n.set(c.name,String(c.value));continue}c.ifAbsent&&e.has(c.name)||(e.delete(c.name),!(c.value===null||c.value===""&&!c.allowEmpty)&&e.set(c.name,String(c.value)))}n.size>0&&e.set("style",[...n].map(([c,l])=>`${c}: ${l}`).join("; "));let o=JA(i);o&&e.set("transform",o);let s=i.startEndpoint,a=i.endEndpoint;return s&&s!=="none"&&e.set("marker-start",`url(#line-marker-${s})`),a&&a!=="none"&&e.set("marker-end",`url(#line-marker-${a})`),e}function ex(t){switch(t.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 JA(t){return bt(t)}function tx(t,e){let n=t.viewboxes?.[0];return{width:e.width??n?.width??800,height:e.height??n?.height??600}}var _r="https://svgsketch.com/ns/metadata",wi="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Wt="http://purl.org/dc/elements/1.1/",Fr="http://creativecommons.org/ns#",nx="http://www.w3.org/2000/svg",ra={rdf:wi,rdfs:"http://www.w3.org/2000/01/rdf-schema#",owl:"http://www.w3.org/2002/07/owl#",xsd:"http://www.w3.org/2001/XMLSchema#",dc:Wt,dcterms:"http://purl.org/dc/terms/",cc:Fr,xmp:"http://ns.adobe.com/xap/1.0/",xmpRights:"http://ns.adobe.com/xap/1.0/rights/",xmpMM:"http://ns.adobe.com/xap/1.0/mm/",photoshop:"http://ns.adobe.com/photoshop/1.0/",illustrator:"http://ns.adobe.com/AdobeIllustrator/10.0/",exif:"http://ns.adobe.com/exif/1.0/",tiff:"http://ns.adobe.com/tiff/1.0/",foaf:"http://xmlns.com/foaf/0.1/",schema:"http://schema.org/",og:"https://ogp.me/ns#",inkscape:"http://www.inkscape.org/namespaces/inkscape",sodipodi:"http://sodipodi.sourceforge.net/DTD/sodipodi-0.0.dtd",prism:"http://prismstandard.org/namespaces/basic/3.0/",svgsketch:_r},ia=new Set([`${Wt}|creator`,`${Wt}|subject`,`${Wt}|rights`,`${Wt}|description`,`${Fr}|license`]);function Td(t){let e=t.indexOf(":");if(e<=0||e===t.length-1)return null;let n=t.slice(0,e),r=t.slice(e+1);if(!/^[A-Za-z_][\w.-]*$/.test(r))return null;let i=ra[n];return i?{ns:i,local:r,prefix:n}:null}var QA={cc0:"https://creativecommons.org/publicdomain/zero/1.0/","cc-by":"https://creativecommons.org/licenses/by/4.0/","cc-by-sa":"https://creativecommons.org/licenses/by-sa/4.0/","cc-by-nc":"https://creativecommons.org/licenses/by-nc/4.0/","cc-by-nc-sa":"https://creativecommons.org/licenses/by-nc-sa/4.0/","cc-by-nd":"https://creativecommons.org/licenses/by-nd/4.0/","cc-by-nc-nd":"https://creativecommons.org/licenses/by-nc-nd/4.0/",mit:"https://opensource.org/licenses/MIT","apache-2.0":"https://www.apache.org/licenses/LICENSE-2.0"},eE={cc0:"CC0 1.0 Universal (Public Domain)","cc-by":"Creative Commons Attribution 4.0","cc-by-sa":"Creative Commons Attribution-ShareAlike 4.0","cc-by-nc":"Creative Commons Attribution-NonCommercial 4.0","cc-by-nc-sa":"Creative Commons Attribution-NonCommercial-ShareAlike 4.0","cc-by-nd":"Creative Commons Attribution-NoDerivatives 4.0","cc-by-nc-nd":"Creative Commons Attribution-NonCommercial-NoDerivatives 4.0",mit:"MIT License","apache-2.0":"Apache License 2.0",custom:"Custom License"};function Fm(t,e){return t==="custom"?e||"":QA[t]||""}function Lm(t){return eE[t]||t}function kd(t){return!!(t.author||t.keywords&&t.keywords.length>0||t.license||t.customMetadata&&Object.keys(t.customMetadata).length>0)}function Rd(t){let e=[];if(t.author&&e.push(`<dc:creator>${fe(t.author)}</dc:creator>`),t.keywords&&t.keywords.length>0&&e.push(`<dc:subject>${fe(t.keywords.join(", "))}</dc:subject>`),t.license){let n=Fm(t.license,t.licenseUrl);n&&e.push(`<cc:license rdf:resource="${fe(n)}"/>`),e.push(`<dc:rights>${fe(Lm(t.license))}</dc:rights>`)}if(t.customMetadata)for(let[n,r]of Object.entries(t.customMetadata)){let i=Td(n);if(i){if(ia.has(`${i.ns}|${i.local}`))continue;e.push(`<${i.prefix}:${i.local}>${fe(r??"")}</${i.prefix}:${i.local}>`)}else e.push(`<svgsketch:custom key="${fe(n)}" value="${fe(r??"")}"/>`)}return e.join(`
18
+ `)}function Bm(t){let e=Rd(t);return e.length>0?`<rdf:Description svgsketch:managed="true">
19
+ ${e}
20
+ </rdf:Description>`:`<rdf:Description svgsketch:managed="true">
21
+ </rdf:Description>`}function Pd(t){let e={rdf:wi,dc:Wt,cc:Fr,svgsketch:_r};if(t.customMetadata)for(let r of Object.keys(t.customMetadata)){let i=Td(r);i&&!(i.prefix in e)&&(e[i.prefix]=i.ns)}return`<metadata>
22
+ <rdf:RDF ${Object.entries(e).map(([r,i])=>`xmlns:${r}="${i}"`).join(" ")}>
23
+ `+Bm(t)+`
24
+ </rdf:RDF>
25
+ </metadata>`}var tE=["dc:creator","dc:subject","dc:rights","dc:description","cc:license","svgsketch:custom"];function nE(t){let e=t;for(let n of tE)e=e.replace(new RegExp(`<${n}\\b[^>]*/>\\s*`,"g"),""),e=e.replace(new RegExp(`<${n}\\b[^>]*>[\\s\\S]*?</${n}>\\s*`,"g"),"");return e}function Gm(t,e){let n=t.match(/<rdf:Description\b/g);if(!n||n.length!==1||!/<rdf:RDF\b/.test(t))return null;let r=/<rdf:Description\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(t);if(!r)return null;let[i,o,s]=[r[0],r[1],r[2]],a=r.index,c=Rd(e),l=`<rdf:Description svgsketch:managed="true"${o}>`,d;if(s==="/")d=t.slice(0,a)+`${l}
26
+ ${c}
27
+ </rdf:Description>`+t.slice(a+i.length);else{let p=t.lastIndexOf("</rdf:Description>");if(p<=a)return null;let f=nE(t.slice(a+i.length,p));d=t.slice(0,a)+l+f+`${c}
28
+ `+t.slice(p)}let u=[["svgsketch",_r],["dc",Wt],["cc",Fr]];return d=d.replace(/<rdf:RDF\b((?:[^>"']|"[^"]*"|'[^']*')*?)>/,(p,f)=>{let m="";for(let[g,h]of u)d.includes(`xmlns:${g}=`)||(m+=` xmlns:${g}="${h}"`);return m?`<rdf:RDF${f}${m}>`:p}),d}function rx(t){return t.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g,"$1").replace(/<[^>]*>/g,"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").trim()}function Cd(t){return t?.language?` xml:lang="${fe(t.language)}"`:""}function _m(t,e,n){let r=n?` xml:lang="${fe(n)}"`:"";return`<${t}${r}>${fe(e)}</${t}>`}function ix(t){let e=t.descriptiveElements;if(!e)return null;let n={title:!1,desc:!1},r=[];for(let i of e){let o=!n[i.kind];if(n[i.kind]=!0,!o){r.push(i.rawXml);continue}let s=i.kind==="title"?t.title:t.description;s&&r.push(s.trim()===i.text.trim()?i.rawXml:_m(i.kind,s,i.language))}return!n.title&&t.title&&r.unshift(_m("title",t.title,null)),!n.desc&&t.description&&r.push(_m("desc",t.description,null)),r.join("")}function mo(t){if(!t)return"";let e="",n=ix(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${fe(t.title)}</title>`),t.description||t.rawDescription){let r=rx(t.rawDescription??""),i=(t.description??"").trim();e+=t.rawDescription&&r===i?`<desc>${t.rawDescription}</desc>`:`<desc>${fe(t.description??"")}</desc>`}return t.rawMetadata&&(e+=t.rawMetadata),e}function $d(t){if(!t)return"";let e="",n=ix(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${fe(t.title)}</title>`),t.description||t.rawDescription){let r=rx(t.rawDescription??""),i=(t.description??"").trim();t.rawDescription&&r===i?e+=`<desc>${t.rawDescription}</desc>`:e+=`<desc>${fe(t.description)}</desc>`}if(t.rawMetadata)if(!t.rawMetadataAuthoritative&&kd(t)&&!t.rawMetadata.includes("svgsketch:managed")){let r=Gm(t.rawMetadata,t);e+=r??Pd(t)+t.rawMetadata}else e+=t.rawMetadata;else kd(t)&&(e+=Pd(t));return t.rawHtmlMetadata&&(e+=t.rawHtmlMetadata),e}var Vm="http://www.w3.org/1999/xhtml",Um="http://www.w3.org/XML/1998/namespace",rE="http://www.w3.org/1999/xlink",jm="http://www.w3.org/2000/xmlns/",iE=new Set([K,Um,rE,Vm,jm]),oE=new Set(["data-shape-id","data-locked","data-hidden","data-cx","data-cy","data-radius","data-corner-radius","data-shift-angle","data-sides","data-arms","data-inner-radius-percent","data-arm-width-percent","data-turns","data-thickness-percent","data-direction","data-teeth","data-tooth-depth-percent","data-hole-radius-percent","data-head-width-percent","data-head-length-percent","data-shaft-width-percent","data-line-style","data-dash-length","data-gap-length","data-start-endpoint","data-end-endpoint","data-original-width","data-original-height","data-preserve-aspect-ratio"]),sE=Object.freeze(Object.fromEntries(Object.entries(ra).map(([t,e])=>[e,t])));function Hm(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Wm(t){let e=Hm(t,"lang",Um);return e?e.value:C(t,"lang")}function ki(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function ax(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function aE(t){return ax(t).replaceAll('"',"&quot;")}function cE(t){switch(t.kind){case"text":return ax(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function lE(t){let e=new Set,n=!1,r=[t];for(;r.length>0;){let i=r.pop();i.prefix&&i.prefix!=="xml"?e.add(i.prefix):!i.prefix&&i.namespaceUri&&(n=!0);for(let o of i.attributes)o.prefix&&o.prefix!=="xmlns"&&o.prefix!=="xml"&&e.add(o.prefix);for(let o of i.children)o.kind==="element"&&r.push(o)}return{prefixes:e,defaultNamespace:n}}function dE(t,e){let n=lE(e),r=new Map;for(let o of e.attributes)(o.namespaceUri===jm||o.name==="xmlns")&&r.set(o.name,o);let i=t.index.parent(e.sourceNodeId);for(;i;){for(let o of i.attributes){if(!(o.namespaceUri===jm||o.name==="xmlns")||r.has(o.name))continue;(o.name==="xmlns"&&n.defaultNamespace||o.prefix==="xmlns"&&n.prefixes.has(o.localName))&&r.set(o.name,o)}i=t.index.parent(i.sourceNodeId)}return Object.freeze([...r.values()].filter(o=>!e.attributes.some(s=>s.name===o.name)))}function cx(t,e=[]){let n=[...e,...t.attributes].map(s=>`${s.name}="${aE(s.value)}"`),r=`<${t.name}${n.length>0?` ${n.join(" ")}`:""}`,i=t.children.map(lx).join(""),o=/\/\s*>\s*$/u.test(t.rawXml??"");return i.length===0&&o?`${r}/>`:`${r}>${i}</${t.name}>`}function lx(t){return t.kind==="element"?cx(t):cE(t)}function oa(t,e){return cx(e,dE(t,e))}function Km(t,e){return t.children.map(n=>n.kind!=="element"||!e?lx(n):oa(e,n)).join("")}function dx(t,e,n){return e.children.filter(r=>r.kind==="element"&&(r.namespaceUri===K||t.root.namespaceUri===null&&r.namespaceUri===null)&&r.localName.toLowerCase()===n)}function ux(t,e){return Object.freeze(e.children.filter(n=>n.kind==="element"&&(n.namespaceUri===K||t.root.namespaceUri===null&&n.namespaceUri===null)&&(n.localName.toLowerCase()==="title"||n.localName.toLowerCase()==="desc")).map(n=>Object.freeze({kind:n.localName.toLowerCase(),sourceNodeId:n.sourceNodeId,language:Wm(n),text:ki(n).trim(),rawInnerXml:Km(n),rawXml:oa(t,n)})))}function px(t){return t.map(({kind:e,language:n,text:r,rawXml:i})=>({kind:e,language:n,text:r,rawXml:i}))}function fx(t){return t.children.some(e=>e.kind==="element")}function uE(t){if(t.classes&&Object.freeze(t.classes),t.aria&&Object.freeze(t.aria),t.customData&&Object.freeze(t.customData),t.foreignAttrs){for(let e of t.foreignAttrs)Object.freeze(e);Object.freeze(t.foreignAttrs)}if(t.descriptiveElements){for(let e of t.descriptiveElements)Object.freeze(e);Object.freeze(t.descriptiveElements)}return Object.freeze(t)}function pE(t,e,n,r,i){let o={};n.length>0&&(o.descriptiveElements=px(n));let s=C(e,"id");s&&(o.name=s);let a=(C(e,"class")??"").split(/\s+/u).filter(Boolean);a.length>0&&(o.classes=a);let c=n.find(b=>b.kind==="title"),l=n.find(b=>b.kind==="desc");if(c?.text&&(o.title=c.text),l?.text&&(o.description=l.text),l){let b=t.index.element(l.sourceNodeId);b&&fx(b)&&(o.rawDescription=Km(b,t))}let d=C(e,"role");d&&(o.role=d);let u=C(e,"aria-label");u&&(o.ariaLabel=u);let p={},f={};for(let b of e.attributes)b.namespaceUri===null&&(b.name.startsWith("aria-")&&b.name!=="aria-label"&&b.value&&(p[b.name]=b.value),b.name.startsWith("data-")&&!oE.has(b.name)&&(f[b.name.slice(5)]=b.value));Object.keys(p).length>0&&(o.aria=p),Object.keys(f).length>0&&(o.customData=f);let m=Wm(e);m!==null&&(o.lang=m);let g=C(e,"tabindex");if(g!==null){if(/^[+-]?\d+$/u.test(g.trim())){let b=Number(g);Number.isSafeInteger(b)&&(o.tabindex=b)}o.tabindex===void 0&&i.push({severity:"warning",code:"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"metadata",documentPath:t.index.sourcePath(e.sourceNodeId),elementName:e.name,...s?{sourceId:s}:{},sourceNodeId:e.sourceNodeId,message:`Invalid tabindex value "${g}" was ignored.`})}if(mt(e,"autofocus")&&(o.autofocus=!0),!["text","tspan","flowroot"].includes(e.localName.toLowerCase())){let b=Hm(e,"space",Um)?.value;(b==="default"||b==="preserve")&&(o.xmlSpace=b)}let h=e.attributes.filter(b=>b.namespaceUri!==null&&!iE.has(b.namespaceUri)).map(b=>({name:b.name,namespaceURI:b.namespaceUri,value:b.value}));h.length>0&&(o.foreignAttrs=h);let y=dx(t,e,"metadata").map(b=>oa(t,b)).join(`
29
+ `);return y&&(o.rawMetadata=y),uE(o)}function ox(t){let e=[],n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="element"&&(e.push(r),n.push(...[...r.children].reverse()))}return e}function sx(t,e,n){return Hm(t,e,n)?.value??null}function fE(t){let e=t.toLowerCase();return e.includes("publicdomain")||e.includes("cc0")?"cc0":e.includes("by-nc-nd")?"cc-by-nc-nd":e.includes("by-nc-sa")?"cc-by-nc-sa":e.includes("by-nc")?"cc-by-nc":e.includes("by-nd")?"cc-by-nd":e.includes("by-sa")?"cc-by-sa":e.includes("/by/")||e.includes("attribution")?"cc-by":e.includes("mit")?"mit":e.includes("apache")?"apache-2.0":"custom"}function mE(t){let e=t.flatMap(p=>ox(p).filter(f=>f.namespaceUri===wi&&f.localName==="Description")),n=e.find(p=>sx(p,"managed",_r)==="true")??e[0];if(!n)return{};let r={},i=ox(n),o=i.find(p=>p.namespaceUri===Wt&&p.localName==="creator");o?.children.length&&(r.author=ki(o).trim());let s=i.find(p=>p.namespaceUri===Wt&&p.localName==="subject");if(s){let p=ki(s).split(",").map(f=>f.trim()).filter(Boolean);p.length>0&&(r.keywords=p)}let a=i.find(p=>p.namespaceUri===Fr&&p.localName==="license"),c=i.find(p=>p.namespaceUri===Wt&&p.localName==="rights"),l=a?sx(a,"resource",wi)??ki(a).trim():c?ki(c).trim():"";l&&(r.license=fE(l),r.license==="custom"&&(r.licenseUrl=l));let d={},u=n.children.filter(p=>p.kind==="element");for(let p of u){if(p.namespaceUri===_r&&p.localName==="custom"){let h=C(p,"key");h!==null&&(d[h]=C(p,"value")??"");continue}let f=p.namespaceUri??"";if(ia.has(`${f}|${p.localName}`))continue;let m=sE[f];if(!m)continue;let g=`${m}:${p.localName}`;g in d||(d[g]=ki(p).trim())}if(Object.keys(d).length===0)for(let p of u){if(p.namespaceUri!==Wt||p.localName!=="description")continue;let f=ki(p),m=f.indexOf(":");if(m<=0)continue;let g=f.slice(0,m).trim();g&&(d[g]=f.slice(m+1).trim())}return Object.keys(d).length>0&&(r.customMetadata=d),r}function gE(t){let e=t.root,n=ux(t,e),r=dx(t,e,"metadata"),i=mE(r);n.length>0&&(i.descriptiveElements=px(n));let o=Wm(e);o!==null&&(i.language=o);let s=n.find(u=>u.kind==="title"),a=n.find(u=>u.kind==="desc");if(s?.text&&(i.title=s.text),a?.text&&(i.description=a.text),a){let u=t.index.element(a.sourceNodeId);u&&fx(u)&&(i.rawDescription=Km(u,t))}let c=r.map(u=>oa(t,u)).join(`
30
+ `);c&&(i.rawMetadata=c,i.rawMetadataAuthoritative=!0);let l=Object.freeze(e.children.filter(u=>u.kind==="element"&&u.namespaceUri===Vm&&["base","link","meta"].includes(u.localName.toLowerCase())).map(u=>Object.freeze({sourceNodeId:u.sourceNodeId,localName:u.localName.toLowerCase(),namespaceUri:Vm,rawXml:oa(t,u)})));l.length>0&&(i.rawHtmlMetadata=l.map(u=>u.rawXml).join(`
31
+ `));let d=[];for(let u=e.children.length-1;u>=0;u--){let p=e.children[u];if(p.kind==="comment"){d.unshift(p.value);continue}if(!(p.kind==="text"&&!p.value.trim()))break}if(d.length>0&&(i.trailingComments=d),i.keywords&&Object.freeze(i.keywords),i.customMetadata&&Object.freeze(i.customMetadata),i.trailingComments&&Object.freeze(i.trailingComments),i.descriptiveElements){for(let u of i.descriptiveElements)Object.freeze(u);Object.freeze(i.descriptiveElements)}return Object.freeze({sourceNodeId:e.sourceNodeId,metadata:Object.freeze(i),descriptiveElements:n,htmlMetadata:l})}function hE(t,e){let n=t.index.parent(e.sourceNodeId);if(!n)return Object.freeze([]);let r=n.children.findIndex(o=>o.kind==="element"&&o.sourceNodeId===e.sourceNodeId);if(r<0)return Object.freeze([]);let i=[];for(let o=r-1;o>=0;o--){let s=n.children[o];if(s.kind==="comment"){i.unshift(s.value);continue}if(!(s.kind==="text"&&s.value.trim().length===0))break}return Object.freeze(i)}function Nd(t,e){let n=[],r=[];for(let a of t.index.elements){if(a===t.root||a.namespaceUri!==K&&!(t.root.namespaceUri===null&&a.namespaceUri===null))continue;let c=ux(t,a),l=pE(t,a,c,e,n),d=hE(t,a);Object.keys(l).length===0&&c.length===0&&d.length===0||r.push(Object.freeze({sourceNodeId:a.sourceNodeId,metadata:l,descriptiveElements:c,leadingComments:d}))}let i=Object.freeze(r),o=new Map(i.map(a=>[a.sourceNodeId,a]));return{value:Object.freeze({document:gE(t),candidates:i,candidate(a){return o.get(a)??null}}),diagnostics:Object.freeze(n)}}var yE="https://boxy-svg.com",qm=new Set(["cursive","emoji","fangsong","fantasy","math","monospace","sans-serif","serif","system-ui","ui-monospace","ui-rounded","ui-sans-serif","ui-serif"]);function mx(t){return/[\t\n\f\r ]/u.test(t??"")}function Ad(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function SE(t,e){let n=1,r=null,i=!1;for(let o=e+1;o<t.length;o++){let s=t[o];if(r){i?i=!1:s==="\\"?i=!0:s===r&&(r=null);continue}if(s==="/"&&t[o+1]==="*"){o=Math.max(o,Ad(t,o)-1);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="{")n++;else if(s==="}"&&--n===0)return o}return t.length-1}function Od(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,Ad(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(o!=="@")continue;let s=i,a=i+1;for(;/[-_a-z0-9]/iu.test(t[a]??"");)a++;let c=t.slice(i+1,a).toLowerCase(),l=a,d=null,u=!1,p=0;for(;l<t.length;l++){let m=t[l];if(d){u?u=!1:m==="\\"?u=!0:m===d&&(d=null);continue}if(m==="/"&&t[l+1]==="*"){l=Math.max(l,Ad(t,l)-1);continue}if(m==='"'||m==="'"){d=m;continue}if(m==="(")p++;else if(m===")")p=Math.max(0,p-1);else if(p===0&&(m===";"||m==="{"))break}if(l>=t.length)continue;if(t[l]===";"){e.push(Object.freeze({name:c,start:s,end:l+1,preludeStart:a,preludeEnd:l,blockStart:null,blockEnd:null})),i=l;continue}let f=SE(t,l);e.push(Object.freeze({name:c,start:s,end:Math.min(t.length,f+1),preludeStart:a,preludeEnd:l,blockStart:l+1,blockEnd:f}))}return Object.freeze(e)}function Dd(t){let e=t.trim();if(e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))){let n=e.slice(1,-1);return Gi(n)??n}return Gi(e)??e}function zd(t){let e=xn(t).find(r=>r.name==="url");if(e)return Dd(t.slice(e.argumentsStart,e.argumentsEnd));let n=t.trim();if(n.startsWith('"')||n.startsWith("'")){let r=n[0],i=n.indexOf(r,1);return i>0?n.slice(1,i):null}return null}function Zm(t,e=0){let n=[];for(let r of xn(t)){if(r.name==="url"){n.push(Object.freeze({rawUrl:Dd(t.slice(r.argumentsStart,r.argumentsEnd)),tokenStart:e+r.tokenStart,tokenEnd:e+r.tokenEnd}));continue}n.push(...Zm(t.slice(r.argumentsStart,r.argumentsEnd),e+r.argumentsStart))}return Object.freeze(n)}function bE(t){let e=Od(t),n=e.filter(o=>o.name==="font-face"||o.name==="import"),r=[],i=0;for(let o of e){if(o.name!=="import")continue;let s=zd(t.slice(o.preludeStart,o.preludeEnd));s!==null&&r.push(Object.freeze({url:s,channel:"css-import",tokenIndex:i})),i++}for(let o of Zm(t))n.some(s=>o.tokenStart>=s.start&&o.tokenEnd<=s.end)||(r.push(Object.freeze({url:o.rawUrl,channel:"css-url",tokenIndex:i})),i++);return Object.freeze(r)}function Lr(t){let e=t.trim();if(!e)return Object.freeze({status:"empty",requestUrl:null});if(/^data:/iu.test(e))return Object.freeze({status:"data",requestUrl:null});let n=_d(e);return Object.freeze(n?{status:"external",requestUrl:n.href}:{status:"blocked",requestUrl:null})}function Jm(t){return Lr(t).status==="data"?t:""}var vE=new Set(["feimage","iframe","image","link","mpath","script","textpath","use"]),xE=new Set(["audio","embed","iframe","img","input","script","source","track","video"]);function Qm(t){return t.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;")}function hx(t){return Qm(t).replace(/"/gu,"&quot;")}function Xm(t){return t.trim().startsWith("#")?t:Jm(t)}function yx(t,e){if(t.kind!=="element"){if(t.kind==="comment")return`<!--${t.value}-->`;if(t.kind==="processing-instruction"||t.kind==="doctype")return"";let a=e==="style"?aa(t.value):t.value;return Qm(a)}let n=t.localName.toLowerCase();if(n==="script"||n==="meta"&&t.attributes.some(a=>a.localName.toLowerCase()==="http-equiv"&&a.value.trim().toLowerCase()==="refresh"))return"";let i=[];for(let a of t.attributes){let c=a.name.toLowerCase(),l=a.localName.toLowerCase();if(/^on/iu.test(c))continue;let d=a.value;l==="style"?d=aa(d):(c==="href"||c==="xlink:href")&&vE.has(n)||l==="src"&&xE.has(n)||l==="poster"&&n==="video"||l==="data"&&n==="object"?d=Xm(d):l==="srcset"?d="":a.namespaceUri===null&&!c.startsWith("xmlns")&&(d=aa(d)),i.push(`${a.name}="${hx(d)}"`)}let o=i.length>0?`<${t.name} ${i.join(" ")}>`:`<${t.name}>`,s=t.children.map(a=>yx(a,n)).join("");return`${o}${s}</${t.name}>`}function Sx(t){let e=tn(t,{source:"svg",entrypoint:"svg-document-import"});if(!e.value)return"";let n=yx(e.value.root,null);return t.trimStart().startsWith("<?xml")?`<?xml version="1.0" encoding="UTF-8"?>
32
+ ${n}`:n}var IE=new Set(["animate","animatemotion","animatetransform","desc","metadata","mpath","set","title"]);function wE(t){switch(t.kind){case"text":return Qm(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function bx(t,e,n){let r=t.sourceNodeId===e,i=new Map(t.attributes.map(u=>[u.name,u.value])),o=t.attributes.map(u=>u.name),s=(u,p)=>{if(p===null){i.delete(u);return}i.has(u)||o.push(u),i.set(u,p)};r&&Object.prototype.hasOwnProperty.call(n,"clipPathUnits")&&s("clipPathUnits",n.clipPathUnits??null),n.clipRule!==void 0&&(r||!IE.has(t.localName.toLowerCase()))&&s("clip-rule",n.clipRule);let a=o.filter((u,p)=>o.indexOf(u)===p&&i.has(u)).map(u=>`${u}="${hx(i.get(u))}"`),c=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,l=t.children.map(u=>u.kind==="element"?bx(u,e,n):wE(u)).join(""),d=/\/\s*>\s*$/u.test(t.rawXml??"");return l.length===0&&d?`${c}/>`:`${c}>${l}</${t.name}>`}function vx(t,e){let n=tn(`<svg xmlns="${K}">${t}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"});if(!n.value)return null;let r=n.value.index.children(n.value.root.sourceNodeId)[0];if(!r)return null;let i=r.localName.toLowerCase();return i!=="clippath"&&i!=="mask"?null:bx(r,r.sourceNodeId,e)}function _d(t){let e=/^(https?):\/\/([^/?#\s\\]+)([^\s\\]*)$/iu.exec(t);if(!e)return null;let n=e[1].toLowerCase(),r=e[2],i=r.lastIndexOf("@"),o=i>=0?r.slice(0,i+1):"",s=r.slice(i+1);if(!s)return null;let a=s.startsWith("[")?s.slice(0,Math.max(0,s.indexOf("]")+1)).toLowerCase():s.split(":")[0].toLowerCase();if(!a)return null;let c=e[3]||"/",l=c.indexOf("?"),d=c.indexOf("#",Math.max(0,l)),u=l<0?"":c.slice(l+1,d<0?void 0:d);return Object.freeze({href:`${n}://${o}${s.toLowerCase()}${c}`,hostname:a,query:u})}function gx(t){try{return decodeURIComponent(t.replace(/\+/gu," "))}catch{return t.replace(/\+/gu," ")}}function eg(t){let e=[],n=0,r=null,i=!1,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(r){i?i=!1:a==="\\"?i=!0:a===r&&(r=null);continue}if(a==="/"&&t[s+1]==="*"){s=Math.max(s,Ad(t,s)-1);continue}a==='"'||a==="'"?r=a:a==="("||a==="["?o++:a===")"||a==="]"?o=Math.max(0,o-1):a===","&&o===0&&(e.push(t.slice(n,s).trim()),n=s+1)}return e.push(t.slice(n).trim()),Object.freeze(e.filter(Boolean))}function kE(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&(mx(t[n])||t[n]===",");)n++;if(n>=t.length)break;let r=n;for(;n<t.length&&!mx(t[n]);)n++;let i=t.slice(r,n);if(i.endsWith(",")){i=i.replace(/,+$/u,""),i&&e.push(i);continue}i&&e.push(i);let o=0;for(;n<t.length;){let s=t[n++];if(s==="(")o++;else if(s===")")o=Math.max(0,o-1);else if(s===","&&o===0)break}}return Object.freeze(e)}function tg(t){if(typeof t!="string")return null;let e=Dd(eg(t)[0]??"").trim();return!e||qm.has(e.toLowerCase())?null:e}function PE(t){let e=[];for(let n of zn(t,";")){let r=t.slice(n.start,n.end),i=zn(r,":",!0)[0]?.end??r.length;if(i>=r.length)continue;let o=r.slice(0,i).trim().toLowerCase(),s=r.slice(i+1).trim();o&&e.push(Object.freeze({property:o,value:s}))}return Object.freeze(e)}function TE(t){let e=xn(t).find(n=>n.name==="format");return e&&Dd(t.slice(e.argumentsStart,e.argumentsEnd))||null}var RE=Object.freeze({"font-style":"style","font-weight":"weight","font-stretch":"stretch","font-display":"display","unicode-range":"unicodeRange","font-feature-settings":"featureSettings","font-variation-settings":"variationSettings","ascent-override":"ascentOverride","descent-override":"descentOverride","line-gap-override":"lineGapOverride","size-adjust":"sizeAdjust"});function CE(t){let e={};for(let n of t){let r=RE[n.property];r&&n.value&&(e[r]=n.value)}return Object.keys(e).length>0?Object.freeze(e):void 0}function ng(t){let e=[];for(let n of Od(t)){if(n.name!=="font-face"||n.blockStart===null||n.blockEnd===null)continue;let r=PE(t.slice(n.blockStart,n.blockEnd)),i=tg(r.find(a=>a.property==="font-family")?.value),o=r.find(a=>a.property==="src")?.value;if(!i||!o)continue;let s=CE(r);for(let a of eg(o)){let c=zd(a);if(c===null)continue;let l=Lr(c);l.status!=="external"||!l.requestUrl||e.push(Object.freeze({family:i,url:l.requestUrl,format:TE(a),...s?{descriptors:s}:{}}))}}return Object.freeze(e)}function xx(t){let e=[];for(let n of Od(t)){if(n.name!=="import")continue;let r=zd(t.slice(n.preludeStart,n.preludeEnd));if(r===null)continue;let i=Lr(r);if(i.status!=="external"||!i.requestUrl)continue;let o=_d(i.requestUrl);if(!o||o.hostname!=="fonts.googleapis.com")continue;let s=o.query.split("&").map(a=>a.split("=",2)).filter(([a])=>gx(a).toLowerCase()==="family").map(([,a])=>gx(a??""));for(let a of s)for(let c of a.split("|")){let l=c.split(":")[0].trim();l&&!qm.has(l.toLowerCase())&&e.push(l)}}return Object.freeze(e)}function $E(t){return zn(t,";").map(e=>{let n=t.slice(e.start,e.end),r=zn(n,":",!0)[0]?.end??n.length;if(r>=n.length||n.slice(0,r).trim().toLowerCase()!=="src")return n;let o=n.slice(0,r+1),s=eg(n.slice(r+1)).filter(a=>{let c=zd(a);return c===null||Lr(c).status==="data"});return`${o} ${s.length>0?s.join(", "):'local("__svgsketch_quarantined_font__")'}`}).join(";")}function aa(t){let e=[];for(let i of Od(t)){if(i.name==="import"){e.push({start:i.start,end:i.end,value:"/* external stylesheet import quarantined */"});continue}i.name!=="font-face"||i.blockStart===null||i.blockEnd===null||e.push({start:i.blockStart,end:i.blockEnd,value:$E(t.slice(i.blockStart,i.blockEnd))})}let n=t;for(let i of e.sort((o,s)=>s.start-o.start))n=`${n.slice(0,i.start)}${i.value}${n.slice(i.end)}`;let r=Zm(n).filter(i=>{let o=i.rawUrl.trim();return!o||o.startsWith("#")?!1:Lr(o).status!=="data"}).sort((i,o)=>o.tokenStart-i.tokenStart);for(let i of r)n=`${n.slice(0,i.tokenStart)}url("data:application/octet-stream;base64,")${n.slice(i.tokenEnd)}`;return n}function NE(t,e,n){let r=[];for(let i of e.stylesheets)if(i.applicable){for(let o of xx(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"google-font-import",family:o}));for(let o of ng(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"external-font-face",family:o.family,url:o.url,format:o.format,...o.descriptors?{descriptors:o.descriptors}:{}}))}for(let i of t.index.elements)for(let o of i.attributes)if(!(o.namespaceUri!==yE||o.localName!=="fonts"))for(let s of o.value.split(",")){let a=s.replace(/\+/gu," ").trim();!a||a.includes("/")||qm.has(a.toLowerCase())||r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"boxy-fonts",family:a}))}for(let i of n.candidates){if(i.canonicalType!=="text"||i.status!=="materialized")continue;let o=a=>{let c=tg(a);c&&r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:i.occurrenceId,origin:"text-font-family",family:c}))};o(i.state.fontFamily);let s=ti(i.state);if(s){o(s.baseStyle.fontFamily);for(let a of s.runs)o(a.style.fontFamily)}}return Object.freeze(r)}function rn(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName.toLowerCase()===e.toLowerCase())?.value??null}function Ed(t){return t.children.map(e=>e.kind==="text"||e.kind==="cdata"?e.value:"").join("")}function Fd(t,e){let n=[],r=[...t.index.children(e)].reverse();for(;r.length>0;){let i=r.pop();n.push(i),r.push(...[...t.index.children(i.sourceNodeId)].reverse())}return Object.freeze(n)}function Rn(t,e){let n=Lr(e.href);t.push(Object.freeze({...e,...n}))}function go(t,e,n,r=new Set(["css-import","css-url"]),i=()=>!0){for(let o of bE(e))!r.has(o.channel)||!i(o)||o.url.trim().startsWith("#")||Rn(t,{...n,occurrenceId:`${n.occurrenceId}:css:${o.tokenIndex}`,channel:o.channel,href:o.url,hrefNamespace:null})}function rg(t,e,n,r){for(let i of Fd(e,n.sourceNodeId)){let o=i.localName.toLowerCase(),s=rn(i,"id"),a={sourceNodeId:i.sourceNodeId,occurrenceId:`${r}:foreign:${i.sourceNodeId}`,sourceId:s,elementName:i.localName},c=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(o)||o==="input"&&rn(i,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:o==="video"},{attributeName:"data",channel:"html-data",applies:o==="object"},{attributeName:"href",channel:"html-src",applies:o==="link"&&(rn(i,"rel")??"").split(/\s+/u).some(u=>u.toLowerCase()==="stylesheet")}];for(let u of c){if(!u.applies)continue;let p=rn(i,u.attributeName);p!==null&&Rn(t,{...a,occurrenceId:`${a.occurrenceId}:${u.attributeName}`,attributeName:u.attributeName,channel:u.channel,href:p,hrefNamespace:null})}let l=rn(i,"srcset");if(l!==null&&(o==="img"||o==="source"))for(let[u,p]of kE(l).entries())Rn(t,{...a,occurrenceId:`${a.occurrenceId}:srcset:${u}`,attributeName:"srcset",channel:"html-srcset",href:p,hrefNamespace:null});let d=rn(i,"style");d!==null&&go(t,d,{...a,attributeName:"style"}),o==="style"&&go(t,Ed(i),{...a,attributeName:"textContent"})}}function AE(t,e,n,r){let i=rn(n,"data-shape-type")?.toLowerCase();if(i==="video"||i==="audio"){let o=Fd(e,n.sourceNodeId).find(s=>s.localName.toLowerCase()===i);if(o){let s=rn(o,"src")??"";if(Rn(t,{sourceNodeId:o.sourceNodeId,occurrenceId:`${r}:media:src`,sourceId:rn(o,"id"),elementName:i,attributeName:"src",channel:"html-src",href:s,hrefNamespace:null}),i==="video"){let a=rn(n,"data-poster")??rn(o,"poster");a!==null&&Rn(t,{sourceNodeId:n.sourceNodeId,occurrenceId:`${r}:media:poster`,sourceId:rn(n,"id"),elementName:"video",attributeName:"poster",channel:"html-poster",href:a,hrefNamespace:null})}}return}rg(t,e,n,r)}function EE(t,e,n){let r=[];for(let i of e.occurrences){let o=t.index.element(i.correspondingSourceNodeId);if(!o||o.namespaceUri!==K)continue;let s=o.localName.toLowerCase();if(s==="image"||s==="feimage"){let a=Le(o)??{value:"",namespace:"svg2"};Rn(r,{sourceNodeId:o.sourceNodeId,occurrenceId:i.occurrenceId,sourceId:C(o,"id"),elementName:s==="feimage"?"feImage":"image",attributeName:"href",channel:"svg-href",href:a.value,hrefNamespace:a.namespace})}else s==="foreignobject"&&AE(r,t,o,i.occurrenceId)}for(let i of n.stylesheets)i.applicable&&go(r,i.authoredText,{sourceNodeId:i.sourceNodeId,occurrenceId:`style:${i.sourceNodeId}`,sourceId:i.id,elementName:"style",attributeName:"textContent"},new Set(["css-import"]),o=>_d(o.url)?.hostname!=="fonts.googleapis.com");for(let i of n.elements){let o=t.index.element(i.correspondingSourceNodeId);if(!(!o||o.namespaceUri!==K))for(let s of Object.values(i.cascadedValues))go(r,s.value,{sourceNodeId:s.sourceNodeId,occurrenceId:`style:${i.occurrenceId}:${s.propertyName}`,sourceId:null,elementName:"style-declaration",attributeName:s.propertyName})}return Object.freeze(r)}function Ix(t,e,n){let r=[...new Set(t.filter(d=>d.origin==="google-font-import"||d.origin==="boxy-fonts").map(d=>d.family))].sort(),i=[],o=new Set;for(let d of t){if(d.origin!=="external-font-face"||!d.url)continue;let u=`${d.family}\0${d.url}\0${d.format??""}\0${JSON.stringify(d.descriptors??{})}`;o.has(u)||(o.add(u),i.push(Object.freeze({family:d.family,url:d.url,format:d.format??null,...d.descriptors?{descriptors:d.descriptors}:{}})))}i.sort((d,u)=>d.family.localeCompare(u.family)||d.url.localeCompare(u.url)||(d.format??"").localeCompare(u.format??""));let s=[...new Set([...r,...i.map(d=>d.family)])].sort(),a=[...new Set(e.filter(d=>d.status==="external"&&d.requestUrl).map(d=>d.requestUrl))].sort(),c=[];s.length>0&&c.push(Object.freeze({kind:"font-consent",families:s,googleFamilies:r,...i.length>0?{externalSources:i}:{}})),a.length>0&&c.push(Object.freeze({kind:"external-asset-resolution",urls:a})),Object.freeze(s),Object.freeze(r),Object.freeze(i),Object.freeze(a),Object.freeze(c);let l=Object.freeze({fontCandidates:t,assetCandidates:e,effects:c});return Object.freeze({value:l,diagnostics:n})}function Ld(t,e,n,r,i){return Ix(NE(t,n,r),EE(t,e,n),Object.freeze([]))}function ME(t){let e=t.state,n=e.extra;return typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,...e}:e}function ig(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function og(t,e,n){for(let r of xx(e))t.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"google-font-import",family:r}));for(let r of ng(e))t.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"external-font-face",family:r.family,url:r.url,format:r.format,...r.descriptors?{descriptors:r.descriptors}:{}}))}function wx(t,e,n,r){og(t,n,r),go(e,n,{sourceNodeId:r,occurrenceId:r,sourceId:null,elementName:"style",attributeName:"textContent"},void 0,o=>_d(o.url)?.hostname!=="fonts.googleapis.com");let i=new Set(ng(n).map(o=>o.url));for(let o=e.length-1;o>=0;o--){let s=e[o];s.sourceNodeId===r&&i.has(s.requestUrl??"")&&e.splice(o,1)}}function kx(t,e,n,r,i,o){let s=tn(`<svg xmlns="${K}"><foreignObject>${n}</foreignObject></svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical foreign content could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=s.value.index.children(s.value.root.sourceNodeId).find(c=>c.localName.toLowerCase()==="foreignobject");if(a){rg(e,s.value,a,r);for(let c of Fd(s.value,a.sourceNodeId))c.localName.toLowerCase()==="style"&&og(t,Ed(c),`${r}:${c.sourceNodeId}`)}}function sg(t,e,n,r){go(t,e,{sourceNodeId:n,occurrenceId:`${n}:${r}`,sourceId:null,elementName:"canonical-state",attributeName:r})}function sa(t,e,n){if(ig(e))for(let[r,i]of Object.entries(e))typeof i=="string"&&sg(t,i,n,r)}function ag(t,e,n,r,i,o){if(Array.isArray(n))for(let[s,a]of n.entries()){if(!ig(a))continue;let c=`${r}:filter:${s}`;a.type==="feImage"&&Rn(e,{sourceNodeId:r,occurrenceId:c,sourceId:null,elementName:"feImage",attributeName:"href",channel:"canonical-state",href:typeof a.href=="string"?a.href:typeof a.xlinkHref=="string"?a.xlinkHref:"",hrefNamespace:typeof a.href=="string"?"svg2":"xlink"}),a.type==="raw-svg"&&typeof a.svgContent=="string"&&Md(t,e,a.svgContent,`${c}:raw`,i,o),ag(t,e,a.primitives,`${c}:primitives`,i,o)}}function Ym(t,e,n,r,i,o){!ig(n)||typeof n.svgContent!="string"||Md(t,e,n.svgContent,r,i,o)}function OE(t,e,n,r,i,o){let s=ME(n),a=`snapshot:${r}:${n.id}`;if(n.type==="text"){let c=d=>{let u=tg(d);u&&t.push(Object.freeze({sourceNodeId:a,occurrenceId:a,origin:"text-font-family",family:u}))};c(s.fontFamily);let l=ti(s);if(l){c(l.baseStyle.fontFamily);for(let d of l.runs)c(d.style.fontFamily)}}n.type==="image"?Rn(e,{sourceNodeId:a,occurrenceId:a,sourceId:n.id,elementName:"image",attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}):n.type==="video"||n.type==="audio"?(Rn(e,{sourceNodeId:a,occurrenceId:`${a}:src`,sourceId:n.id,elementName:n.type,attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}),n.type==="video"&&typeof s.posterHref=="string"&&Rn(e,{sourceNodeId:a,occurrenceId:`${a}:poster`,sourceId:n.id,elementName:"video",attributeName:"posterHref",channel:"canonical-state",href:s.posterHref,hrefNamespace:null})):n.type==="foreign-object"&&typeof s.rawContent=="string"&&kx(t,e,s.rawContent,a,i,o),Ym(t,e,s.fillGradient,`${a}:fillGradient`,i,o),Ym(t,e,s.strokeGradient,`${a}:strokeGradient`,i,o),ag(t,e,s.filters,a,i,o),sa(e,s.authoredAttributes,`${a}:authored`),sa(e,s.containerPresentation,`${a}:container-presentation`),sa(e,s.instancePresentation,`${a}:instance-presentation`),sa(e,s.cssMaskProperties,`${a}:mask`),typeof s.cssClipPath=="string"&&sg(e,s.cssClipPath,a,"clip-path")}function Md(t,e,n,r,i,o){let s=tn(`<svg xmlns="${K}">${n}</svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical raw definition could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=new Set;for(let c of s.value.index.elements){if(c.localName.toLowerCase()!=="foreignobject")continue;let l=`${r}:${c.sourceNodeId}`;rg(e,s.value,c,l);for(let d of Fd(s.value,c.sourceNodeId))a.add(d.sourceNodeId),d.localName.toLowerCase()==="style"&&og(t,Ed(d),`${r}:${d.sourceNodeId}`)}for(let c of s.value.index.elements){if(a.has(c.sourceNodeId))continue;let l=c.localName.toLowerCase();if(c.namespaceUri===K&&(l==="image"||l==="feimage")){let d=Le(c)??{value:"",namespace:"svg2"};Rn(e,{sourceNodeId:`${r}:${c.sourceNodeId}`,occurrenceId:`${r}:${c.sourceNodeId}`,sourceId:rn(c,"id"),elementName:l==="feimage"?"feImage":"image",attributeName:"href",channel:"canonical-state",href:d.value,hrefNamespace:d.namespace})}l==="style"&&wx(t,e,Ed(c),`${r}:${c.sourceNodeId}:style`);for(let d of c.attributes)d.localName.toLowerCase()==="href"||d.localName.toLowerCase()==="src"||sg(e,d.value,`${r}:${c.sourceNodeId}`,d.name)}}function Px(t,e){let n=[],r=[],i=[];for(let[s,a]of(t.documentStyles??[]).entries())wx(n,r,a.css,`snapshot:documentStyles[${s}]`);et(t,{onShape:(s,a)=>OE(n,r,s,a,e,i)});for(let[s,a]of(t.library??[]).entries()){let c=`snapshot:library[${s}]`;a.kind==="pattern"?Ym(n,r,a.pattern,`${c}:pattern`,e,i):a.kind==="filter"?ag(n,r,a.filters,`${c}:filters`,e,i):(a.kind==="symbol"||a.kind==="marker")&&sa(r,a.rootAttributes,`${c}:root`)}let o=t.documentMetadata?.rawHtmlMetadata;typeof o=="string"&&kx(n,r,o,"snapshot:documentMetadata.rawHtmlMetadata",e,i);for(let[s,a]of(t.paintServerDefs??[]).entries())Md(n,r,a.markup,`snapshot:paintServerDefs[${s}]`,e,i);for(let[s,a]of(t.clipMaskGroups??[]).entries())a.rawDefinition&&Md(n,r,a.rawDefinition,`snapshot:clipMaskGroups[${s}].rawDefinition`,e,i);return Ix(Object.freeze(n),Object.freeze(r),Object.freeze(i))}function DE(t,e,n){let r=new Set,i=o=>{let s=o;for(;s;){let a=s.localName.toLowerCase();if(a==="clippath"||a==="mask")return!0;s=t.index.parent(s.sourceNodeId)}return!1};for(let o of n.css){let s=e.occurrence(o.occurrenceId);if(!s)continue;let a=t.index.element(s.correspondingSourceNodeId);a&&i(a)&&r.add(a.sourceNodeId)}return t.index.elements.filter(o=>r.has(o.sourceNodeId)).map(o=>o.sourceNodeId)}var cg=Object.freeze({matchesMedia(t){let e=t.trim().toLowerCase();return e===""||e==="all"||e==="screen"},supportsCondition(){return!1}}),zE=new Map([["clippath","clip-path"],["marker","marker"],["mask","mask"],["pattern","pattern"]]);function _E(t){return Object.freeze(t.index.elements.flatMap(e=>{let n=zE.get(e.localName.toLowerCase());return n?[Object.freeze({sourceNodeId:e.sourceNodeId,capability:n})]:[]}))}function FE(t,e,n){let r=new Map(t.occurrences.map(i=>[i.occurrenceId,i]));return Object.freeze([...e.candidates.filter(i=>i.status==="materialized").map(i=>i.occurrenceId),...n.uses.filter(i=>["symbol-instance","linked-reference"].includes(i.status)).map(i=>i.useOccurrenceId)].filter(i=>r.get(i)?.role!=="definition"))}function ca(t,e={}){let n={source:e.source??"svg",entrypoint:e.entrypoint??"svg-document-import"},r=tn(t,n,e.xmlHost);if(!r.value)return Object.freeze({value:null,diagnostics:r.diagnostics});let i=r.value,o=Il(i.root,n),s=Object.freeze({width:o.value.viewBoxWidth??300,height:o.value.viewBoxHeight??150}),a=e.rootFontSize??16,c=Object.freeze({viewport:Object.freeze({x:o.value.viewBoxX??0,y:o.value.viewBoxY??0,...s}),rootFontSize:a}),l=Cl(i,n),d=l.value.condition(i.root.sourceNodeId),u=Object.freeze({...o.value,...d?.systemLanguage!==null&&d?.systemLanguage!==void 0?{systemLanguage:d.systemLanguage}:{},...d?.requiredExtensions!==null&&d?.requiredExtensions!==void 0?{requiredExtensions:d.requiredExtensions}:{}}),p=dd(i,n),f=Nd(i,n),m=Al(i,{...n,resourceRoots:_E(i),...e.maxUseDepth!==void 0?{maxDepth:e.maxUseDepth}:{},...e.maxUseOccurrences!==void 0?{maxOccurrences:e.maxUseOccurrences}:{}}),g=jl(i,m,{...n,environment:e.styleEnvironment??cg}),h=Xl(i,m,g.value,{...n,viewport:s,rootFontSize:a,...e.textMetricsHost?{textMetricsHost:e.textMetricsHost}:{}}),y=Hl(i,m,g.value,{...n,leafGeometry:h.value}),b=$l(i,{...e.claimedIds?{claimedIds:e.claimedIds}:{},cssAnimationTargetSourceNodeIds:DE(i,m,y.value)}),v=Dl(i,m,g.value,n),I=_l(i,{...n,appliedDeclarations:g.value.appliedResourceDeclarations}),x=ed(i,m,g.value,I,h.value,{...n,viewport:s,rootFontSize:a}),k=ld(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),T=td(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),w=nd(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),P=rd(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),N=od(i,b,n),R=wl(i,n),$=Pl(i,n),A=Fl(i),O=Ld(i,m,g.value,h.value,n),G=Tl(i,m,{...n,materializedOccurrenceIds:FE(m,h.value,v)}),M=[...r.diagnostics,...o.diagnostics,...l.diagnostics,...p.diagnostics,...f.diagnostics,...m.diagnostics,...g.diagnostics,...y.diagnostics,...v.diagnostics,...h.diagnostics,...I.diagnostics,...x.diagnostics,...k.diagnostics,...T.diagnostics,...w.diagnostics,...P.diagnostics,...N.diagnostics,...R.diagnostics,...$.diagnostics,...O.diagnostics,...G.diagnostics],V=Object.freeze({projectionContext:c,sourceDocument:i,rootFrame:u,identifiers:b,conditionalProcessing:l.value,scripts:p.value,metadata:f.value,useOccurrences:m,styles:g.value,animations:y.value,symbolUses:v,leafGeometry:h.value,resourceDependencies:I,clipMasks:x.value,filters:k.value,markers:T.value,gradients:w.value,patterns:P.value,paintServerDefinitions:N.value,views:R.value,embeddedFrames:$.value,authoredAttributes:A,externalEffects:O.value,hierarchy:G.value});return Object.freeze({value:V,diagnostics:Object.freeze(M)})}function J(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function ho(t={}){let e={schemaVersion:_t,shapes:t.shapes?t.shapes.map(n=>({...n})):[],viewboxes:t.viewboxes?t.viewboxes.map(n=>({...n})):[]};return t.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...t.metadata}),e}function Tx(t){let{type:e,id:n,...r}=t,i={};for(let[o,s]of Object.entries(r))s!==void 0&&(i[o]=s);return{id:n??J(),type:e,state:i}}function Pi(t,e,n,r,i){return{id:i??J(),x:t,y:e,width:n,height:r}}var LE;function BE(){return LE??=new Set([...ue.typeIds().filter(t=>t!=="document"),"spline"])}function Br(t){let e=[],n=[];if(t==null||typeof t!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:n};let r=t;for(let o of Object.keys(r))o in wt||n.push({path:o,message:`Unknown top-level field "${o}" (likely written by a newer version); it is preserved in the unknownFields quarantine on save`,severity:"warning"});let i={doc:r,errors:e,warnings:n};for(let o of Object.keys(wt)){let s=r[o];s===void 0&&!wt[o].required||WE[o](s,i)}return{valid:e.length===0,errors:e,warnings:n}}function Me(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hn(t,e,n){return Array.isArray(t)?!0:(n.push({path:e,message:`${e} must be an array`,severity:"error"}),!1)}var GE=new Set(["x1","y1","x2","y2","gradientTransform"]),VE=new Set(["cx","cy","fx","fy","r","fr","gradientTransform"]),jE=new Set(["x","y","width","height"]);function Vn(t,e,n){t.push({path:e,message:n,severity:"error"})}function UE(t,e,n,r){if(!Me(t)){Vn(r,e,"Gradient must be a plain object");return}let i=n==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let o of i)t[o]!==void 0&&(typeof t[o]!="number"||!Number.isFinite(t[o]))&&Vn(r,`${e}.${o}`,`${o} must be a finite number`);if(t.fr!==void 0&&(typeof t.fr!="number"||!Number.isFinite(t.fr))&&Vn(r,`${e}.fr`,"fr must be a finite number"),t.authoredGeometry!==void 0)if(!Me(t.authoredGeometry))Vn(r,`${e}.authoredGeometry`,"Gradient authoredGeometry must be a plain object");else{let o=n==="linear-gradient"?GE:VE;for(let[s,a]of Object.entries(t.authoredGeometry))o.has(s)?typeof a!="string"&&Vn(r,`${e}.authoredGeometry.${s}`,"Authored gradient geometry declarations must be strings"):Vn(r,`${e}.authoredGeometry.${s}`,"is not a supported authored gradient geometry field")}t.gradientTransform!==void 0&&(!Array.isArray(t.gradientTransform)||t.gradientTransform.length!==6||!t.gradientTransform.every(o=>typeof o=="number"&&Number.isFinite(o)))&&Vn(r,`${e}.gradientTransform`,"gradientTransform must be a 6-element finite affine matrix"),Array.isArray(t.stops)?t.stops.forEach((o,s)=>{if(!Me(o)){Vn(r,`${e}.stops[${s}]`,"Gradient stop must be an object");return}for(let a of["offset","opacity"])o[a]!==void 0&&(typeof o[a]!="number"||!Number.isFinite(o[a]))&&Vn(r,`${e}.stops[${s}].${a}`,`${a} must be a finite number`)}):Vn(r,`${e}.stops`,"Gradient stops must be an array")}function HE(t,e,n){if(!Me(t)){n.push({path:e,message:"Pattern must be a plain object",severity:"error"});return}for(let r of["x","y","width","height","scale","rotation","opacity"])t[r]!==void 0&&(typeof t[r]!="number"||!Number.isFinite(t[r]))&&n.push({path:`${e}.${r}`,message:`${r} must be a finite number`,severity:"error"});t.patternUnits!==void 0&&t.patternUnits!=="userSpaceOnUse"&&t.patternUnits!=="objectBoundingBox"&&n.push({path:`${e}.patternUnits`,message:"patternUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"}),t.patternContentUnits!==void 0&&t.patternContentUnits!=="userSpaceOnUse"&&t.patternContentUnits!=="objectBoundingBox"&&n.push({path:`${e}.patternContentUnits`,message:"patternContentUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"});for(let r of["svgContent","patternTransform","viewBox","preserveAspectRatio"])t[r]!==void 0&&typeof t[r]!="string"&&n.push({path:`${e}.${r}`,message:`${r} must be a string`,severity:"error"});if(t.authoredGeometry!==void 0)if(!Me(t.authoredGeometry))n.push({path:`${e}.authoredGeometry`,message:"Pattern authoredGeometry must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(t.authoredGeometry))jE.has(r)?typeof i!="string"&&n.push({path:`${e}.authoredGeometry.${r}`,message:"Authored pattern geometry declarations must be strings",severity:"error"}):n.push({path:`${e}.authoredGeometry.${r}`,message:"is not a supported authored pattern geometry field",severity:"error"})}var WE={schemaVersion:(t,{errors:e,warnings:n})=>{typeof t!="number"||!Number.isInteger(t)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):t>_t&&n.push({path:"schemaVersion",message:`schemaVersion ${t} is newer than supported (${_t})`,severity:"warning"})},shapes:(t,{errors:e,warnings:n})=>{if(!hn(t,"shapes",e))return;let r=new Set;t.forEach((i,o)=>{lg(i,`shapes[${o}]`,e,n,r)})},viewboxes:(t,{errors:e})=>{if(!hn(t,"viewboxes",e))return;let n=new Set;t.forEach((r,i)=>{eM(r,`viewboxes[${i}]`,e,n)})},guides:(t,{errors:e})=>{hn(t,"guides",e)&&t.forEach((n,r)=>{tM(n,`guides[${r}]`,e)})},measurements:(t,{errors:e})=>{hn(t,"measurements",e)&&t.forEach((n,r)=>{let i=`measurements[${r}]`;if(!Me(n)){e.push({path:i,message:"Measurement must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Measurement id must be a non-empty string",severity:"error"})})},sceneTree:(t,{doc:e,errors:n,warnings:r})=>{if(!hn(t,"sceneTree",n))return;let i=KE(e.shapes),o=new Set;t.forEach((s,a)=>{XE(s,`sceneTree[${a}]`,n,r,i,o)})},clipMaskGroups:(t,{errors:e,warnings:n})=>{hn(t,"clipMaskGroups",e)&&t.forEach((r,i)=>{nM(r,`clipMaskGroups[${i}]`,e,n)})},documentMetadata:(t,{errors:e})=>{Me(t)||e.push({path:"documentMetadata",message:"documentMetadata must be a plain object",severity:"error"})},documentScripts:(t,{errors:e})=>{hn(t,"documentScripts",e)&&t.forEach((n,r)=>{let i=`documentScripts[${r}]`;if(!Me(n)){e.push({path:i,message:"Document script must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Document script id must be a non-empty string",severity:"error"})})},documentStyles:(t,{errors:e})=>{hn(t,"documentStyles",e)&&t.forEach((n,r)=>{let i=`documentStyles[${r}]`;if(!Me(n)){e.push({path:i,message:"Document style must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Document style id must be a non-empty string",severity:"error"}),typeof n.css!="string"&&e.push({path:`${i}.css`,message:"Document style css must be a string",severity:"error"})})},templateVariables:(t,{errors:e})=>{hn(t,"templateVariables",e)&&t.forEach((n,r)=>{let i=`templateVariables[${r}]`;if(!Me(n)){e.push({path:i,message:"Template variable must be a non-null object",severity:"error"});return}(typeof n.name!="string"||n.name.length===0)&&e.push({path:`${i}.name`,message:"Template variable name must be a non-empty string",severity:"error"})})},animationTimeline:(t,{doc:e,errors:n})=>{if(!Me(t)){n.push({path:"animationTimeline",message:"animationTimeline must be a plain object",severity:"error"});return}if(t.tracks!==void 0&&!Array.isArray(t.tracks)){n.push({path:"animationTimeline.tracks",message:"animationTimeline.tracks must be an array",severity:"error"});return}Array.isArray(t.tracks)&&Number(e.schemaVersion)>=11&&t.tracks.forEach((r,i)=>{if(!Me(r)||!Array.isArray(r.keyframes))return;let o=new Set;r.keyframes.forEach((s,a)=>{let c=`animationTimeline.tracks[${i}].keyframes[${a}].id`;if(!Me(s)||typeof s.id!="string"||!s.id){n.push({path:c,message:"Animation keyframe id must be a non-empty string",severity:"error"});return}if(o.has(s.id)){n.push({path:c,message:`Duplicate animation keyframe id: "${s.id}"`,severity:"error"});return}o.add(s.id)})})},library:(t,{doc:e,errors:n,warnings:r})=>{if(!hn(t,"library",n))return;let i=new Set;t.forEach((o,s)=>{let a=`library[${s}]`;if(!Me(o)){n.push({path:a,message:"Library def must be a non-null object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?n.push({path:`${a}.id`,message:"Library def id must be a non-empty string",severity:"error"}):i.has(o.id)?n.push({path:`${a}.id`,message:`Duplicate library def id: "${o.id}"`,severity:"error"}):i.add(o.id),(typeof o.kind!="string"||o.kind.length===0)&&n.push({path:`${a}.kind`,message:"Library def kind must be a non-empty string",severity:"error"}),o.kind==="symbol"||o.kind==="marker"){if(o.kind==="symbol"){let c=typeof e.schemaVersion=="number"&&e.schemaVersion>=8;if(o.defKind!==void 0&&!["symbol","group","shape"].includes(String(o.defKind))&&n.push({path:`${a}.defKind`,message:"Symbol defKind must be symbol, group, or shape",severity:"error"}),o.defKind==="shape"&&(!Array.isArray(o.shapes)||o.shapes.length!==1)&&n.push({path:`${a}.shapes`,message:"Native shape definitions must contain exactly one root shape",severity:"error"}),c)for(let l of["wrapperAttrs","groups","overflow"])o[l]!==void 0&&n.push({path:`${a}.${l}`,message:`Symbol ${l} is schema-v7 migration input only`,severity:"error"});for(let l of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])o[l]!==void 0&&typeof o[l]!="string"&&n.push({path:`${a}.${l}`,message:`Symbol ${l} must be a string when present`,severity:"error"});if(o.rootAttributes!==void 0)if(!Me(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Symbol rootAttributes must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(o.rootAttributes))c&&["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(l)&&n.push({path:`${a}.rootAttributes.${l}`,message:`Symbol ${l} must use its typed root field`,severity:"error"}),typeof d!="string"&&n.push({path:`${a}.rootAttributes.${l}`,message:"Symbol root attribute values must be strings",severity:"error"})}if(o.kind==="marker"){for(let c of["viewBox","preserveAspectRatio"])o[c]!==void 0&&typeof o[c]!="string"&&n.push({path:`${a}.${c}`,message:`Marker ${c} must be a string when present`,severity:"error"});if(o.authoredGeometry!==void 0)if(!Me(o.authoredGeometry))n.push({path:`${a}.authoredGeometry`,message:"Marker authoredGeometry must be a plain object",severity:"error"});else for(let[c,l]of Object.entries(o.authoredGeometry))typeof l!="string"&&n.push({path:`${a}.authoredGeometry.${c}`,message:"Marker authored geometry declarations must be strings",severity:"error"});if(o.rootAttributes!==void 0)if(!Me(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Marker rootAttributes must be a plain object",severity:"error"});else for(let[c,l]of Object.entries(o.rootAttributes))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(c)&&n.push({path:`${a}.rootAttributes.${c}`,message:`Marker ${c} must use its typed root field`,severity:"error"}),typeof l!="string"&&n.push({path:`${a}.rootAttributes.${c}`,message:"Marker root attribute values must be strings",severity:"error"})}if(Array.isArray(o.shapes)){let c=new Set;o.shapes.forEach((l,d)=>{lg(l,`${a}.shapes[${d}]`,n,r,c)})}if(o.kind==="symbol"&&Me(o.variants))for(let[c,l]of Object.entries(o.variants)){if(!Array.isArray(l))continue;let d=new Set;l.forEach((u,p)=>{lg(u,`${a}.variants[${c}][${p}]`,n,r,d)})}}(o.kind==="linear-gradient"||o.kind==="radial-gradient")&&UE(o.gradient,`${a}.gradient`,o.kind,n),o.kind==="pattern"&&HE(o.pattern,`${a}.pattern`,n)})},paintServerDefs:(t,{errors:e})=>{if(!hn(t,"paintServerDefs",e))return;let n=new Set;t.forEach((r,i)=>{qE(r,`paintServerDefs[${i}]`,e,n)})},colorGlyphLibrary:(t,{errors:e})=>{if(!Me(t)){e.push({path:"colorGlyphLibrary",message:"colorGlyphLibrary must be a plain object",severity:"error"});return}t.version!==void 0&&!Number.isInteger(t.version)&&e.push({path:"colorGlyphLibrary.version",message:"colorGlyphLibrary.version must be an integer",severity:"error"}),t.entries!==void 0&&!Array.isArray(t.entries)&&e.push({path:"colorGlyphLibrary.entries",message:"colorGlyphLibrary.entries must be an array",severity:"error"})},exportItems:(t,{errors:e})=>{hn(t,"exportItems",e)&&t.forEach((n,r)=>{let i=`exportItems[${r}]`;if(!Me(n)){e.push({path:i,message:"Export item must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Export item id must be a non-empty string",severity:"error"}),typeof n.filename!="string"&&e.push({path:`${i}.filename`,message:"Export item filename must be a string",severity:"error"}),typeof n.format!="string"&&e.push({path:`${i}.format`,message:"Export item format must be a string",severity:"error"})})},unknownFields:(t,{errors:e})=>{Me(t)||e.push({path:"unknownFields",message:"unknownFields must be a plain object (forward-compat quarantine bag)",severity:"error"})}};function KE(t){let e=new Set;if(!Array.isArray(t))return e;for(let n of t)dn(n,{onShape:r=>{typeof r.id=="string"&&r.id.length>0&&e.add(r.id)}});return e}function Rx(t){return t.startsWith("structural:")}function XE(t,e,n,r,i,o){if(t===null||typeof t!="object"){n.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let s=t;typeof s.id!="string"||s.id.length===0?n.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(o.has(s.id)&&n.push({path:`${e}.id`,message:`Duplicate scene tree id: "${s.id}"`,severity:"error"}),o.add(s.id),!i.has(s.id)&&!Rx(s.id)&&r.push({path:`${e}.id`,message:`Scene tree id "${s.id}" is not present in shapes`,severity:"warning"})),s.parentId!==null&&typeof s.parentId!="string"?n.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof s.parentId=="string"&&!i.has(s.parentId)&&!Rx(s.parentId)&&r.push({path:`${e}.parentId`,message:`Scene tree parentId "${s.parentId}" is not present in shapes`,severity:"warning"}),(typeof s.index!="number"||!Number.isInteger(s.index)||s.index<0)&&n.push({path:`${e}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),s.updatedAt!==void 0&&(typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt)||s.updatedAt<0)&&n.push({path:`${e}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),s.clientId!==void 0&&typeof s.clientId!="string"&&n.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var YE=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function qE(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=t;typeof i.id!="string"||i.id.length===0?n.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):r.add(i.id);let o=i.role===void 0?"resource":i.role;o!=="resource"&&o!=="referenced-fragment"&&n.push({path:`${e}.role`,message:"Paint server def role must be resource or referenced-fragment",severity:"error"}),typeof i.type=="string"&&(o==="resource"&&YE.has(i.type)||o==="referenced-fragment"&&/^[A-Za-z][\w.-]*$/u.test(i.type))||n.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)&&n.push({path:`${e}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"}),i.passthrough!==void 0&&typeof i.passthrough!="boolean"&&n.push({path:`${e}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"});for(let a of["definitionChildIds","sourceDefinitionChildIds"]){let c=i[a];c!==void 0&&(!Array.isArray(c)||c.some(l=>typeof l!="string"||l.length===0))&&n.push({path:`${e}.${a}`,message:"Definition child ids must be non-empty strings",severity:"error"})}Array.isArray(i.definitionChildIds)&&Array.isArray(i.sourceDefinitionChildIds)&&i.definitionChildIds.length!==i.sourceDefinitionChildIds.length&&n.push({path:e,message:"Definition child id arrays must have equal lengths",severity:"error"})}function lg(t,e,n,r,i){if(t===null||typeof t!="object"||Array.isArray(t)){n.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}dn(t,{onShape:(o,s)=>{ZE(o,`${e}${s}`,n,r,i)}})}function ZE(t,e,n,r,i){if(typeof t.id!="string"||t.id.length===0?n.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(t.id)?n.push({path:`${e}.id`,message:`Duplicate shape id: "${t.id}"`,severity:"error"}):i.add(t.id),typeof t.type!="string"?n.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):BE().has(t.type)||r.push({path:`${e}.type`,message:`Unknown shape type: "${t.type}"`,severity:"warning"}),t.state===void 0||t.state===null||typeof t.state!="object")n.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"});else{let o=t.state;QE(o,`${e}.state`,n,r),o.children!==void 0&&!Array.isArray(o.children)?n.push({path:`${e}.state.children`,message:"children must be an array",severity:"error"}):Array.isArray(o.children)&&o.children.forEach((s,a)=>{(s===null||typeof s!="object"||Array.isArray(s))&&n.push({path:`${e}.state.children[${a}]`,message:"Shape must be a non-null object",severity:"error"})})}}var JE=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function Cx(t){return typeof t=="number"?isFinite(t):typeof t=="string"?JE.test(t):!1}function QE(t,e,n,r){if(Me(t.metadata))for(let s of["linkUrl","linkTarget"])Object.hasOwn(t.metadata,s)&&n.push({path:`${e}.metadata.${s}`,message:`${s} is noncanonical; use a Hyperlink container shape`,severity:"error"});if((t.fillType==="linear-gradient"||t.fillType==="radial-gradient"||t.fillType==="pattern")&&t.fillColor==="none"&&t.fillOpacity===0&&n.push({path:`${e}.fillOpacity`,message:"Painted shapes cannot carry the noncanonical no-fill opacity encoding",severity:"error"}),t.charOffsets!==void 0&&t.charOffsets!==null&&(Array.isArray(t.charOffsets)?t.charOffsets.forEach((s,a)=>{let c=`${e}.charOffsets[${a}]`;if(!Me(s)){n.push({path:c,message:"Each charOffsets entry must be a plain object",severity:"error"});return}for(let l of["x","y"]){let d=s[l];d!==null&&(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be null or a finite number`,severity:"error"})}for(let l of["dx","dy","rotate"]){let d=s[l];(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be a finite number`,severity:"error"})}if(s.raw!==void 0)if(!Me(s.raw))n.push({path:`${c}.raw`,message:"raw must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(s.raw))(!["x","y","dx","dy"].includes(l)||typeof d!="string")&&n.push({path:`${c}.raw.${l}`,message:"raw accepts only string x/y/dx/dy members",severity:"error"})}):n.push({path:`${e}.charOffsets`,message:"charOffsets must be an array",severity:"error"})),t.authoredTextPosition!==void 0)if(!Me(t.authoredTextPosition))n.push({path:`${e}.authoredTextPosition`,message:"authoredTextPosition must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(t.authoredTextPosition)){let c=`${e}.authoredTextPosition.${s}`;if(!["x","y"].includes(s)||!Me(a)){n.push({path:c,message:"Authored text position accepts only x/y coordinate objects",severity:"error"});continue}(typeof a.raw!="string"||a.raw.length===0||typeof a.resolved!="number"||!Number.isFinite(a.resolved))&&n.push({path:c,message:"Authored text coordinates require non-empty raw and finite resolved values",severity:"error"});for(let l of Object.keys(a))["raw","resolved"].includes(l)||n.push({path:`${c}.${l}`,message:"Authored text coordinates accept only raw/resolved members",severity:"error"})}if(t.authoredTextStructure!==void 0){let s=`${e}.authoredTextStructure`;if(!Me(t.authoredTextStructure))n.push({path:s,message:"authoredTextStructure must be a plain object",severity:"error"});else{let a=t.authoredTextStructure,c=a.text,l=a.spans;if(typeof c!="string"||!Array.isArray(l))n.push({path:s,message:"Authored text structure requires text and spans",severity:"error"});else{let d=0;l.forEach((u,p)=>{let f=`${s}.spans[${p}]`,m=Me(u)?u.start:void 0,g=Me(u)?u.end:void 0;!Me(u)||typeof m!="number"||typeof g!="number"||!Number.isInteger(m)||!Number.isInteger(g)||m<d||g<=m||g>c.length||typeof u.id!="string"||u.id.length===0||Object.keys(u).some(h=>!["start","end","id"].includes(h))?n.push({path:f,message:"Authored text spans require ordered start/end ranges and a non-empty id",severity:"error"}):d=g});for(let u of Object.keys(a))["text","spans"].includes(u)||n.push({path:`${s}.${u}`,message:"Authored text structure accepts only text/spans members",severity:"error"})}}}if(t.authoredUseGeometry!==void 0)if(!Me(t.authoredUseGeometry))n.push({path:`${e}.authoredUseGeometry`,message:"authoredUseGeometry must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(t.authoredUseGeometry))(!["x","y","width","height"].includes(s)||typeof a!="string")&&n.push({path:`${e}.authoredUseGeometry.${s}`,message:"Authored use geometry accepts only string x/y/width/height members",severity:"error"});let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let s of i)t[s]!==void 0&&!Cx(t[s])&&n.push({path:`${e}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"});for(let s of Ko){let a=t[s];if(a!=null){if(s==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(c=>typeof c=="number"&&Number.isFinite(c)))&&n.push({path:`${e}.${s}`,message:`${s} must be a 6-element finite affine matrix`,severity:"error"});continue}Cx(a)||n.push({path:`${e}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"})}}let o=["width","height","radius","fontSize"];for(let s of o){let a=t[s];typeof a=="number"&&a<=0&&r.push({path:`${e}.${s}`,message:`${s} should be positive (got ${a})`,severity:"warning"})}}function eM(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let i=t;typeof i.id!="string"||i.id.length===0?n.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${e}.id`,message:`Duplicate viewbox id: "${i.id}"`,severity:"error"}):r.add(i.id);for(let o of["x","y","width","height"])(typeof i[o]!="number"||!isFinite(i[o]))&&n.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof i.width=="number"&&i.width<=0&&n.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof i.height=="number"&&i.height<=0&&n.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function tM(t,e,n){if(t===null||typeof t!="object"){n.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let r=t;(typeof r.id!="string"||r.id.length===0)&&n.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&n.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof r.position!="number"||!isFinite(r.position))&&n.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function nM(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let i=t;(typeof i.id!="string"||i.id.length===0)&&n.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),i.type!=="clip"&&i.type!=="mask"&&n.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"});let o=i.clipShapeIds,s=typeof i.rawDefinition=="string"&&i.rawDefinition.length>0;o!==void 0&&!Array.isArray(o)?n.push({path:`${e}.clipShapeIds`,message:"clipShapeIds must be an array",severity:"error"}):o===void 0?n.push({path:`${e}.clipShapeIds`,message:"ClipMaskGroup must carry clipShapeIds",severity:"error"}):Array.isArray(o)&&o.length===0&&!s&&r.push({path:`${e}.clipShapeIds`,message:"ClipMaskGroup has no clip shapes and no rawDefinition; it will clip nothing",severity:"warning"}),Array.isArray(i.contentShapeIds)||n.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function la(t){let e=[],n=new Map,r=new Set,i=new WeakSet,o=[...t].reverse();for(;o.length>0;){let a=o.pop();if(!a||typeof a!="object"||i.has(a))continue;i.add(a),e.push(a);let c=n.get(a.id);c&&c!==a?r.add(a.id):c||n.set(a.id,a);let l=a.state.children;if(Array.isArray(l))for(let d=l.length-1;d>=0;d--){let u=l[d];u&&typeof u=="object"&&typeof u.id=="string"&&o.push(u)}}let s=new Map(n);for(let a of r)s.delete(a);return{ordered:e,uniqueById:s,duplicateIds:r}}function yo(t){let e=[...t??[]],n=new Map;for(let o of e)n.set(o.id,(n.get(o.id)??0)+1);let r=new Set([...n].filter(([,o])=>o>1).map(([o])=>o)),i=new Map;for(let o of e)r.has(o.id)||i.set(o.id,o);return{ordered:e,uniqueById:i,duplicateIds:r,definition:o=>i.get(o),symbol:o=>{let s=i.get(o);return s?.kind==="symbol"?s:void 0}}}function rM(t){let e=t.groupData;if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e.transform;return typeof n=="string"&&n.trim()?n:null}function So(t,e){let n=bt(t,e);if(n)return{matrix:un(t,e),attribute:n,owner:"canonical"};let r=rM(t);return r?{matrix:Ht(r),attribute:r,owner:"group-data"}:{matrix:_e,attribute:null,owner:"none"}}function Lt(t){let e=t.transformMatrix;return ir(e)&&!Et(e)||t.customPivot||typeof t.rawTransform=="string"&&t.rawTransform?!1:(t.rotation??0)!==0||(t.skewX??0)!==0||(t.skewY??0)!==0||(t.scaleX??1)!==1||(t.scaleY??1)!==1}function da(t,e){let n=e?{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2}:void 0;return So(t,n)}var iM=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,oM=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)px$/i,sM=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)%$/;function ua(t,e,n,r){let i=t.trim();if(iM.test(i))return Number(i);let o=oM.exec(i);if(o)return Number(o[1]);let s=sM.exec(i);if(s)return e.percentBasis===void 0?(r.push({code:"unresolved-symbol-viewport",message:`Symbol ${e.axis} percentage ${t} needs a containing viewport basis.`}),null):Number(s[1])/100*e.percentBasis;let a=n.resolveLength?.(t,e)??null;return a!==null&&Number.isFinite(a)?a:(r.push({code:"invalid-symbol-length",message:`Symbol ${e.axis} length ${t} is invalid or requires an unavailable length host.`}),null)}function aM(t){let e=t.state.authoredUseGeometry;return e&&typeof e=="object"?e:{}}function Ti(t,e){let n=t[e];if(typeof n=="string")return n;if(["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(e))return;let r=t.rootAttributes?.[e];return typeof r=="string"?r:void 0}function cM(t,e){if(t===void 0)return;let n=nt(t);return n?n.width<0||n.height<0?(e.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${t} has a non-finite or negative dimension and is ignored.`}),null):n:(e.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${t} is not four finite SVG numbers and is ignored.`}),null)}function $x(t,e,n,r,i,o){return e===void 0?0:ua(e,{axis:n,percentBasis:n==="x"?r?.width:r?.height},i,o)??0}function Nx(t,e,n,r,i,o,s){let a=n==="width"?i?.width:i?.height,c=[r,Ti(e,n)];for(let l of c){if(l===void 0||l.trim().toLowerCase()==="auto")continue;let d=ua(l,{axis:n,percentBasis:a},o,s);if(d!==null){if(d<0){s.push({code:"invalid-symbol-length",message:`Negative symbol ${n} ${l} is invalid and falls back to auto.`});continue}return d}}return a!==void 0?a:(s.push({code:"unresolved-symbol-viewport",message:`Symbol ${n} is auto and needs a containing viewport basis.`}),null)}function Ax(t,e,n,r,i){if(t===void 0)return;let o=t.trim();if(e==="refX"){if(o==="left")return 0;if(o==="center")return(n?.width??0)/2;if(o==="right")return n?.width??0}else{if(o==="top")return 0;if(o==="center")return(n?.height??0)/2;if(o==="bottom")return n?.height??0}return ua(t,{axis:e,percentBasis:e==="refX"?n?.width:n?.height},r,i)??void 0}function bo(t,e,n,r={}){let i=[],o=aM(t),s=$x(t,o.x,"x",n,r,i),a=$x(t,o.y,"y",n,r,i),c=qe(s,a),l=Ti(e,"transform"),d=l?Ht(l):_e;if((e.defKind??"symbol")!=="symbol")return{kind:"group",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:ge(c,d),childPercentBasis:n??null,viewport:null,diagnostics:i};let u=Nx(t,e,"width",o.width,n,r,i),p=Nx(t,e,"height",o.height,n,r,i),f=Ti(e,"x"),m=Ti(e,"y"),g=f!==void 0?ua(f,{axis:"x",percentBasis:n?.width},r,i)??0:0,h=m!==void 0?ua(m,{axis:"y",percentBasis:n?.height},r,i)??0:0,y=cM(e.viewBox,i),b=Qi({width:u,height:p,...y?{viewBoxX:y.x,viewBoxY:y.y,viewBoxWidth:y.width,viewBoxHeight:y.height}:{},preserveAspectRatio:Ti(e,"preserveAspectRatio")},n);for(let w of b.diagnostics)i.push({code:w.code==="unresolved-viewport-size"?"unresolved-symbol-viewport":"invalid-symbol-viewbox",message:w.message.replace("Nested SVG","Symbol")});if(u===null||p===null||!b.renders||!b.contentMatrix)return{kind:"symbol",renders:!1,useX:s,useY:a,useAttributes:o,contentMatrix:ge(c,d),childPercentBasis:b.childPercentBasis,viewport:b,diagnostics:i};let v=Ax(Ti(e,"refX"),"refX",b.childPercentBasis,r,i),I=Ax(Ti(e,"refY"),"refY",b.childPercentBasis,r,i),x=We(b.contentMatrix,{x:v??0,y:I??0}),k=qe(g-(v===void 0?0:x.x),h-(I===void 0?0:x.y)),T=ge(ge(ge(c,d),k),b.contentMatrix);return{kind:"symbol",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:T,childPercentBasis:b.childPercentBasis,viewport:b,diagnostics:i}}function mg(){return{bounds:null,status:"empty",diagnostics:[]}}function xo(t,e,n){return n.resolveOwnTransform?.(t,e)??e}function $n(t,e){return{bounds:null,status:t,diagnostics:[e]}}function Vd(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e}function Cn(t,e,n="empty"){return t?{bounds:t,status:"resolved",diagnostics:e}:e.some(r=>r.code==="container-cycle"||r.code==="reference-cycle"||r.code==="symbol-cycle")?{bounds:null,status:"cycle",diagnostics:e}:e.some(r=>r.code==="unsupported-shape"||r.code==="deferred-tree-kind")?{bounds:null,status:"unsupported",diagnostics:e}:e.some(r=>r.code==="unresolved-shape"||r.code==="unresolved-reference-target"||r.code==="unresolved-reference-pivot"||r.code==="duplicate-shape-id"||r.code==="unresolved-svg-viewport"||r.code==="unresolved-symbol-definition"||r.code==="duplicate-library-id"||r.code==="unresolved-symbol-viewport"||r.code==="unresolved-symbol-pivot")?{bounds:null,status:"unresolved",diagnostics:e}:{bounds:null,status:n,diagnostics:e}}function pg(t){if(t.length===0)return null;let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;for(let o=1;o<t.length;o++){let s=t[o];e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y)}return{minX:e,minY:n,maxX:r,maxY:i}}function gg(t,e){return pg([We(e,{x:t.minX,y:t.minY}),We(e,{x:t.maxX,y:t.minY}),We(e,{x:t.maxX,y:t.maxY}),We(e,{x:t.minX,y:t.maxY})])}function Ex(t,e,n,r,i){return n<0||r<0?null:gg({minX:t,minY:e,maxX:t+n,maxY:e+r},i)}function Mx(t,e,n,r,i){if(n<0||r<0)return null;let o=We(i,{x:t,y:e}),s=Math.hypot(i[0]*n,i[2]*r),a=Math.hypot(i[1]*n,i[3]*r);return{minX:o.x-s,minY:o.y-a,maxX:o.x+s,maxY:o.y+a}}function lM(t,e){let n=Array.isArray(t)?t:[t],r=null;for(let i of n)r=Vd(r,gg(i,e));return r}function dg(t,e,n){return $n("unsupported",{code:e,shapeId:t.id,message:`Object bounds for ${n} require a document resolver policy.`,path:[t.id]})}function Bd(t,e,n={}){let r=Qt(t);if(!r)return $n("unsupported",{code:"unsupported-shape",shapeId:t.id,message:`No geometry kernel is registered for shape type ${t.type}.`,path:[t.id]});let i;switch(r.kind){case"circle":i=Mx(r.cx,r.cy,r.r,r.r,e);break;case"ellipse":i=Mx(r.cx,r.cy,r.rx,r.ry,e);break;case"rectangle":if(r.width<0||r.height<0)i=null;else if(r.pathData)i=fn(r.pathData,e);else if(r.rx>0&&r.ry>0){let o=lm(r.x,r.y,r.width,r.height,r.rx,r.ry);i=o?fn(o,e):null}else i=Ex(r.x,r.y,r.width,r.height,e);break;case"line":if(r.boundsPolicy==="linked-line")return dg(t,"deferred-tree-kind","linked line");i=pg([We(e,{x:r.x1,y:r.y1}),We(e,{x:r.x2,y:r.y2})]);break;case"text":{let o=n.measureText?.(t,r)??null;if(!o)return dg(t,"deferred-tree-kind","text");i=lM(o,e);break}case"path":{let o=r.placement?ge(e,qe(r.placement.x,r.placement.y)):e;i=fn(r.d,o);break}case"polyline":{let o=r.points.length>0?r.points:[{x:0,y:0}];i=pg(o.map(s=>We(e,s)));break}case"positioning-rect":i=Ex(r.x,r.y,r.width,r.height,e);break;case"view":return mg();case"container":case"embedded-svg":case"shape-reference":case"symbol-instance":return dg(t,"deferred-tree-kind",r.kind)}return i?{bounds:i,status:"resolved",diagnostics:[]}:{bounds:null,status:"empty",diagnostics:[]}}function fg(t){let e=t.state.children;return Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}function jn(t){let e=la(t.shapes),n=yo(t.library),r=t.sceneTree??[];if(r.length===0)return{roots:()=>t.shapes,shape:l=>e.uniqueById.get(l),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:fg};let i=new Map,o=new Set;for(let l of r){let d=i.get(l.parentId)??[];i.set(l.parentId,[...d,l]),e.uniqueById.has(l.id)&&o.add(l.id)}let s=l=>{let d=[],u=new Set,p=f=>{for(let m of ut([...i.get(f)??[]])){let g=e.uniqueById.get(m.id);if(g){d.push(g);continue}u.has(m.id)||(u.add(m.id),p(m.id),u.delete(m.id))}};return p(l),d};return{roots:()=>[...s(null),...t.shapes.filter(l=>!o.has(l.id))],shape:l=>e.uniqueById.get(l),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:l=>[...s(l.id),...fg(l).filter(d=>!o.has(d.id))]}}function Ox(t,e){return`${e.identityPrefixes.at(-1)??"document"}\0${t.id}`}var dM=new Set(["block","contents","flex","flow","flow-root","grid","inherit","initial","inline","inline-block","inline-flex","inline-grid","inline-table","list-item","none","revert","revert-layer","ruby","ruby-base","ruby-base-container","ruby-text","ruby-text-container","run-in","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","unset"]),ug=new Set(["block","inline","run-in"]),uM=new Set(["flow","flow-root","table","flex","grid","ruby"]);function pM(t){let e=t.trim().toLowerCase();if(dM.has(e)||/^(?:var|env)\(/.test(e)&&e.endsWith(")"))return!0;let n=e.split(/\s+/);if(n.length<2||n.length>3||new Set(n).size!==n.length)return!1;if(n.includes("list-item")){let r=n.filter(i=>i!=="list-item");return r.filter(i=>ug.has(i)).length<=1&&r.filter(i=>i==="flow"||i==="flow-root").length<=1&&r.every(i=>ug.has(i)||i==="flow"||i==="flow-root")}return n.length===2&&n.some(r=>ug.has(r))&&n.some(r=>uM.has(r))}function fM(t){if(!t)return null;let e=null;for(let n of ai(t,";")){let r=ai(n,":");if(r.length<2||r[0].trim().toLowerCase()!=="display")continue;let i=r.slice(1).join(":").trim(),o=/\s*!important\s*$/i.test(i),s=i.replace(/\s*!important\s*$/i,"").trim().toLowerCase();pM(s)&&(!e||o||!e.important)&&(e={value:s,important:o})}return e}function Dx(t,e){let n=fM(typeof e=="string"?e:void 0);return n?n.value!=="none":typeof t!="string"||t.trim().toLowerCase()!=="none"}function fa(t,e){if(t.state.visible===!1)return!1;let n=t.type==="symbol-instance"?t.state.instancePresentation:void 0,r=n?.display??t.state.display;return Dx(r,n?.style)?e.participatesInRendering?.(t)??!0:!1}function mM(t,e,n){let r=t.rootAttributes;return Dx(r?.display,r?.style)?n.participatesSymbolDefinition?.(t,e)??!0:!1}function gM(t,e={}){return{x:t.x,y:t.y,width:e.width!==void 0?e.width:t.width,height:e.height!==void 0?e.height:t.height,viewBoxX:t.viewBoxX,viewBoxY:t.viewBoxY,viewBoxWidth:t.viewBoxWidth,viewBoxHeight:t.viewBoxHeight,preserveAspectRatio:t.preserveAspectRatio}}function Gr(t,e,n={}){let r=Qt(t);if(!r||r.kind!=="embedded-svg")return{matrix:_e,attribute:null,pivotRequired:!1,pivotResolved:!1,viewport:Qi({})};let i=Qi(gM(r,n),e),o=Lt(t.state),s=i.frame?{x:i.frame.x+i.frame.width/2,y:i.frame.y+i.frame.height/2}:void 0;return{matrix:un(t.state,s),attribute:bt(t.state,s),pivotRequired:o,pivotResolved:!o||s!==void 0,viewport:i}}function zx(t,e,n){return e.diagnostics.map(r=>({code:r.code==="unresolved-viewport-size"?"unresolved-svg-viewport":"invalid-svg-viewport",shapeId:t.id,message:r.message,path:[...n,t.id]}))}function Gd(t,e,n,r){let i=null,o=[],s=n.forceInlineChildren>0?fg(t):n.view.children(t);for(let a of s){if(!fa(a,n.host))continue;let c=ma(a,e,n,r);i=Vd(i,c.bounds),o.push(...c.diagnostics)}return Cn(i,o)}function _x(t,e){return{...t,diagnostics:t.diagnostics.map(n=>n.path.includes(e)?n:{...n,path:[e,...n.path]})}}function hM(t,e,n,r,i={}){let o=Gr(t,r,i),s=zx(t,o.viewport,n.path);if(o.pivotRequired&&!o.pivotResolved)return s.push({code:"unresolved-svg-viewport",shapeId:t.id,message:`Embedded SVG ${t.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`,path:[...n.path,t.id]}),Cn(null,s,"unresolved");if(!o.viewport.renders)return Cn(null,s,o.viewport.status==="zero-disabled"?"empty":"unresolved");let a=Ox(t,n);n.active.add(a),n.path.push(t.id);let l=t.state.isRootSvg===!0?e:ge(ge(e,xo(t,o.matrix,n.host)),o.viewport.contentMatrix??_e),d=Gd(t,l,n,o.viewport.childPercentBasis??r);return n.path.pop(),n.active.delete(a),Cn(d.bounds,[...s,...d.diagnostics],d.status)}function Fx(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let d=typeof e=="string"?e:e.id;return $n("unresolved",{code:"unresolved-shape",shapeId:d,message:`Shape ${d} is not present in the document bounds view.`,path:[d]})}let o=Qt(i);if(!o||o.kind!=="embedded-svg")return $n("unsupported",{code:"unsupported-shape",shapeId:i.id,message:`Shape ${i.id} is not an embedded SVG viewport.`,path:[i.id]});let s=Gr(i,n.parentViewport),a=zx(i,s.viewport,[]);if(!s.viewport.frame||s.pivotRequired&&!s.pivotResolved)return Cn(null,a,"unresolved");let c=ge(n.toTarget??_e,xo(i,s.matrix,r)),l=s.viewport.frame;return{bounds:gg({minX:l.x,minY:l.y,maxX:l.x+l.width,maxY:l.y+l.height},c),status:"resolved",diagnostics:a}}function Lx(t,e,n){let r=n.view.duplicateShapeIds?.().has(e)??!1;return $n("unresolved",{code:r?"duplicate-shape-id":"unresolved-reference-target",shapeId:t.id,message:r?`Shape reference ${t.id} targets ambiguous duplicate id ${e}.`:e?`Shape reference ${t.id} targets ${e}, which is not present in the document.`:`Shape reference ${t.id} has no targetShapeId.`,path:e?[...n.path,e]:[...n.path]})}function yM(t,e){let n=[...e.path,t.id];return $n("cycle",{code:"reference-cycle",shapeId:t.id,message:`Shape reference cycle detected: ${n.join(" -> ")}.`,path:n})}function Bx(t,e,n,r,i){if(!Lt(t.state))return{matrix:un(t.state),attribute:bt(t.state),pivotRequired:!1,pivotResolved:!0,diagnostics:[],contentBounds:null};let s=qe(e.offsetX,e.offsetY),a={width:e.width,height:e.height},c=_x(ma(n,s,r,i,a),t.id),l=c.diagnostics.some(u=>u.code==="unsupported-shape"||u.code==="deferred-tree-kind"||u.code==="unresolved-reference-pivot"),d=c.bounds&&!l?{x:(c.bounds.minX+c.bounds.maxX)/2,y:(c.bounds.minY+c.bounds.maxY)/2}:null;if(!d){let u=c.bounds===null&&(c.status==="empty"||c.status==="cycle"||c.status==="unresolved"),p={code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`,path:[...r.path]};return{matrix:un(t.state),attribute:bt(t.state),pivotRequired:!0,pivotResolved:u,diagnostics:u?c.diagnostics:[...c.diagnostics,p],contentBounds:c}}return{matrix:un(t.state,d),attribute:bt(t.state,d),pivotRequired:!0,pivotResolved:!0,diagnostics:[],contentBounds:c}}function SM(t,e,n,r,i){if(r.activeReferences.has(t.id))return yM(t,r);r.activeReferences.add(t.id),r.path.push(t.id);let o=u=>(r.path.pop(),r.activeReferences.delete(t.id),u),s=e.targetShapeId?.trim()??"",a=s?r.view.shape(s):void 0;if(!a)return o(Lx(t,s,r));if(!fa(a,r.host))return o(mg());let c=Bx(t,e,a,r,i);if(c.pivotRequired&&!c.pivotResolved)return o(Cn(null,[...c.diagnostics],"unresolved"));if(c.contentBounds?.bounds===null&&c.pivotResolved)return o(c.contentBounds);let l=ge(ge(n,xo(t,c.matrix,r.host)),qe(e.offsetX,e.offsetY)),d=_x(ma(a,l,r,i,{width:e.width,height:e.height}),t.id);return o({...d,diagnostics:[...c.diagnostics,...d.diagnostics]})}function vo(t,e){let n=t.state.instancePresentation?.transform,r=typeof n=="string"&&n.trim()?n.trim():null,i=un(t.state,e),o=bt(t.state,e);return r?{matrix:ge(Ht(r),i),attribute:o?`${r} ${o}`:r}:{matrix:i,attribute:o}}function pa(t,e,n,r){return{code:n,shapeId:t.id,message:r,path:[...e.path,t.id]}}function Gx(t,e,n,r,i,o=!1){let s=fi(e,t),a=bo(t,e,i,{resolveLength:r.host.resolveSymbolLength}),c=[...s.diagnostics.map(g=>pa(t,r,g.code,g.message)),...a.diagnostics.map(g=>pa(t,r,g.code==="invalid-symbol-length"||g.code==="invalid-symbol-viewbox"?"invalid-symbol-viewport":"unresolved-symbol-viewport",g.message))];if(!a.renders){let g=a.viewport?.status==="zero-disabled";return{...Cn(null,c,g?"empty":"unresolved"),transform:{...vo(t),pivotRequired:Lt(t.state),pivotResolved:!0,diagnostics:c}}}if(!mM(e,t,r.host))return{...mg(),transform:{...vo(t),pivotRequired:Lt(t.state),pivotResolved:!0,diagnostics:c}};if(r.activeSymbols.has(s.materializationKey)){let g=pa(t,r,"symbol-cycle",`Symbol instance cycle detected through ${e.id}.`);return{...$n("cycle",g),transform:{...vo(t),pivotRequired:Lt(t.state),pivotResolved:!0,diagnostics:[g]}}}r.activeSymbols.add(s.materializationKey),r.identityPrefixes.push(s.materializationKey),r.forceInlineChildren++,r.path.push(t.id);let l=g=>{let h=null,y=[];for(let b of s.shapes){if(!fa(b,r.host))continue;let v=ma(b,g,r,a.childPercentBasis??i);h=Vd(h,v.bounds),y.push(...v.diagnostics)}return Cn(h,y)},d=Lt(t.state),u=vo(t),p=!d,f=[];if(d){let g=l(a.contentMatrix),h=g.diagnostics.some(b=>b.code==="unsupported-shape"||b.code==="deferred-tree-kind"||b.code==="unresolved-symbol-viewport"),y=g.bounds&&!h?{x:(g.bounds.minX+g.bounds.maxX)/2,y:(g.bounds.minY+g.bounds.maxY)/2}:void 0;if(y)u=vo(t,y),p=!0;else{let b=g.bounds===null&&(g.status==="empty"||g.status==="cycle"||g.status==="unresolved");p=b,b||(f=[pa(t,r,"unresolved-symbol-pivot",`Symbol instance ${t.id} needs unavailable contextual geometry or measurement for its decomposed transform pivot.`)]),b&&!o&&(f=[...g.diagnostics])}}let m;if(d&&!p)m=Cn(null,[...c,...f],"unresolved");else{let g=ge(ge(n,xo(t,u.matrix,r.host)),a.contentMatrix),h=l(g);m=Cn(h.bounds,[...c,...f,...h.diagnostics],h.status)}return r.path.pop(),r.forceInlineChildren--,r.identityPrefixes.pop(),r.activeSymbols.delete(s.materializationKey),{...m,transform:{...u,pivotRequired:d,pivotResolved:p,diagnostics:[...c,...f]}}}function bM(t,e,n,r){let i=String(t.state.symbolId??"").trim(),o=i?n.view.duplicateLibraryIds?.().has(i)??!1:!1,s=i?n.view.libraryDefinition?.(i):void 0;if(o||!s||s.kind!=="symbol")return $n("unresolved",pa(t,n,o?"duplicate-library-id":"unresolved-symbol-definition",o?`Symbol instance ${t.id} targets duplicate library id ${i}.`:`Symbol instance ${t.id} targets missing symbol definition ${i||"(blank)"}.`));let a=Gx(t,s,e,n,r),{transform:c,...l}=a;return l}function ma(t,e,n,r,i={}){let o=Ox(t,n);if(n.active.has(o)){if(!n.collectDiagnostics)return{bounds:null,status:"cycle",diagnostics:[]};let l=[...n.path,t.id];return $n("cycle",{code:"container-cycle",shapeId:t.id,message:`Container cycle detected: ${l.join(" -> ")}.`,path:l})}let s=Qt(t);if(!s)return Bd(t,e,n.host);if(s.kind==="shape-reference")return SM(t,s,e,n,r);if(s.kind==="embedded-svg")return hM(t,e,n,r,i);if(s.kind==="symbol-instance")return bM(t,e,n,r);if(s.kind!=="container"){let l=un(t.state,s.defaultPivot??void 0);return Bd(t,ge(e,xo(t,l,n.host)),n.host)}n.active.add(o),n.path.push(t.id);let a=So(t.state).matrix;if(Lt(t.state)){let l=n.collectDiagnostics;n.collectDiagnostics=!1;let d=Gd(t,_e,n,r);n.collectDiagnostics=l;let u=d.diagnostics.some(p=>p.code==="unsupported-shape"||p.code==="deferred-tree-kind");a=da(t.state,u?null:d.bounds).matrix}let c=Gd(t,ge(e,xo(t,a,n.host)),n,r);return n.path.pop(),n.active.delete(o),c}function Io(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let o=typeof e=="string"?e:e.id;return $n("unresolved",{code:"unresolved-shape",shapeId:o,message:`Shape ${o} is not present in the document bounds view.`,path:[o]})}return ma(i,n.toTarget??_e,{view:t,host:r,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},n.parentViewport)}function wo(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let s=typeof e=="string"?e:e.id;return $n("unresolved",{code:"unresolved-shape",shapeId:s,message:`Shape ${s} is not present in the document bounds view.`,path:[s]})}let o={...r,resolveOwnTransform:(s,a)=>s===i?_e:r.resolveOwnTransform?.(s,a)??a};return Io(t,i,{parentViewport:n.parentViewport},o)}function jd(t,e,n={},r){let i=Qt(e);if(!i||i.kind!=="shape-reference")return{matrix:_e,attribute:null,pivotRequired:!1,pivotResolved:!1,diagnostics:[]};let o={view:t,host:n,active:new Set,activeReferences:new Set([e.id]),activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[e.id],collectDiagnostics:!0},s=i.targetShapeId?.trim()??"",a=s?t.shape(s):void 0;if(!a||!fa(a,n)){let l=Lt(e.state);return{matrix:un(e.state),attribute:bt(e.state),pivotRequired:l,pivotResolved:!0,diagnostics:a?[]:Lx(e,s,o).diagnostics}}let c=Bx(e,i,a,o,r);return{matrix:c.matrix,attribute:c.attribute,pivotRequired:c.pivotRequired,pivotResolved:c.pivotResolved,diagnostics:c.diagnostics}}function Ud(t,e,n={},r){let i=Lt(e.state),o=String(e.state.symbolId??"").trim(),s=o?t.duplicateLibraryIds?.().has(o)??!1:!1,a=o?t.libraryDefinition?.(o):void 0;return s||!a||a.kind!=="symbol"?{...vo(e),pivotRequired:i,pivotResolved:!0,diagnostics:[]}:Gx(e,a,_e,{view:t,host:n,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},r,!0).transform}function Vx(t,e={},n={}){let r=null,i=[];for(let o of t.roots()){if(!fa(o,n))continue;let s=Io(t,o,e,n);r=Vd(r,s.bounds),i.push(...s.diagnostics)}return Cn(r,i)}function Hd(t,e={}){if(!Lt(t.state))return{transform:So(t.state),contentBounds:null,pivotRequired:!1,pivotResolved:!0};let i={view:jn({shapes:[t],viewboxes:[]}),host:e,active:new Set([`document\0${t.id}`]),activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[t.id],collectDiagnostics:!0},o=Gd(t,_e,i),a=o.diagnostics.some(c=>c.code==="unsupported-shape"||c.code==="deferred-tree-kind")?null:o.bounds;return{transform:da(t.state,a),contentBounds:o,pivotRequired:!0,pivotResolved:a!==null||o.status==="empty"}}function ko(t,e=t.id){return{kind:"pattern",id:e,name:t.name??e,pattern:{type:"pattern",svgContent:t.svgContent,width:t.width,height:t.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function hg(t){if(t.builtIn)return!1;let e=t.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function yg(t){let e=(t.viewBox??"").trim().split(/[\s,]+/).filter(o=>o.length>0).map(Number),n=e.length===4&&e.every(o=>Number.isFinite(o)),r=n&&e[2]>0?e[2]:t.width??10,i=n&&e[3]>0?e[3]:t.height??10;return{width:r,height:i}}function Wd(t){if(!hg(t))return null;let{width:e,height:n}=yg(t.pattern);return{id:t.id,name:t.name,svgContent:t.pattern.svgContent??"",width:e,height:n}}function Sg(t){return typeof t=="string"&&t.length>0?t:null}function vM(t){let e=Sg(t.groupId);if(e)return e;let n=t.extra;return!n||typeof n!="object"||Array.isArray(n)?null:Sg(n.groupId)}function jx(t){delete t.groupId;let e=t.extra;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;delete n.groupId,Object.keys(n).length===0&&delete t.extra}function xM(t){let e={};return t.transformOrigin&&(e.transformOrigin=t.transformOrigin),t.pluginId&&(e.pluginId=t.pluginId),t.pluginData&&(e.pluginData=t.pluginData),t.attributes&&Object.keys(t.attributes).length>0&&(e.attributes=t.attributes),t.fill&&(e.fill=t.fill),t.fillOpacity&&(e.fillOpacity=t.fillOpacity),t.strokeOpacity&&(e.strokeOpacity=t.strokeOpacity),t.opacity&&(e.opacity=t.opacity),t.filter&&(e.filter=t.filter),t.cssFilter&&(e.cssFilter=t.cssFilter),t.mixBlendMode&&(e.mixBlendMode=t.mixBlendMode),t.isolation&&(e.isolation=t.isolation),t.clipPath&&(e.clipPath=t.clipPath),t.mask&&(e.mask=t.mask),t.rawMetadata&&(e.rawMetadata=t.rawMetadata),t.transform&&(e.transform=t.transform),e}function IM(t){let e=xM(t),n={fillColor:null,borderColor:null,rotation:0,skewX:0,skewY:0,customPivot:null};return Object.keys(e).length>0&&(n.groupData=e),{id:t.id,type:"group",state:n}}function Ux(t,e){let n=t.state.children;if(Array.isArray(n))for(let r of n)e.add(r.id),Ux(r,e)}function Hx(t,e=!1){let n=t.state,r=n.children;return e&&jx(n),Array.isArray(r)&&(n.children=r.map(i=>Hx(i,!0))),t}function wM(t){if(t.length<2)return t.map(s=>s.shape);let e=t.filter(s=>s.shape.type==="group"&&s.siblingIndex!==void 0&&Number.isFinite(s.siblingIndex)).sort((s,a)=>(s.siblingIndex??0)-(a.siblingIndex??0));if(e.length===0)return[...t].sort((s,a)=>s.flatOrder-a.flatOrder).map(s=>s.shape);let n=Array(t.length).fill(null),r=new Set(e);for(let s of e){let a=Math.max(0,Math.min(t.length-1,s.siblingIndex??0));for(;a<n.length&&n[a]!==null;)a++;if(a>=n.length)for(a=n.length-1;a>=0&&n[a]!==null;)a--;a>=0&&(n[a]=s)}let i=t.filter(s=>!r.has(s)).sort((s,a)=>s.flatOrder-a.flatOrder),o=0;for(let s of i){for(;o<n.length&&n[o]!==null;)o++;o<n.length&&(n[o]=s)}return n.filter(s=>s!==null).map(s=>s.shape)}function ga(t,e=[]){let n=structuredClone(t),r=structuredClone(e),i=new Map;for(let h of r)i.set(h.id,h);let o=n.map(h=>Hx(h)),s=new Set;for(let h of o)Ux(h,s);let a=new Map,c=new Map;o.forEach((h,y)=>{s.has(h.id)||c.has(h.id)||(a.set(h.id,y),c.set(h.id,h))});for(let h of r){if(s.has(h.id)||c.has(h.id))continue;let y=IM(h);a.set(y.id,Number.POSITIVE_INFINITY),c.set(y.id,y)}let l=new Map,d=new Map;for(let h of c.values()){let y=h.state,b=i.get(h.id),v=vM(y)??(h.type==="group"?Sg(b?.parentId):null),I=l.get(v)??[];d.set(h.id,v),I.push({shape:h,flatOrder:a.get(h.id)??Number.POSITIVE_INFINITY,siblingIndex:h.type==="group"?b?.siblingIndex:void 0}),l.set(v,I)}let u=new Set,p=h=>{if(u.has(h.id))return null;u.add(h.id);let y=h.state,b=Array.isArray(y.children)?y.children:[],v=f(h.id),I=new Set(b.map(k=>k.id)),x=[...b,...v.filter(k=>!I.has(k.id))];return x.length>0?y.children=x:delete y.children,jx(y),h},f=h=>{let y=[];for(let b of wM(l.get(h)??[])){let v=p(b);v&&y.push(v)}return y},m=f(null),g=h=>{if(!h)return;let y=p(h);y&&m.push(y)};for(let h of c.values()){let y=d.get(h.id);y&&!c.has(y)&&g(h)}for(let h of r)g(c.get(h.id));for(let h of c.values())g(h);return m}var kM=[["splinePoints","pathPoints"],["splineClosed","pathClosed"],["splineCurveType","pathCurveType"],["splineTension","pathTension"],["splineArcParams","pathArcParams"],["splineControlBounds","pathControlBounds"]];function PM(t){let e=!1;if(t.type==="spline"&&(t.type="path",e=!0),t.state&&typeof t.state=="object"){let n=t.state,r=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:null;for(let[i,o]of kM)Object.prototype.hasOwnProperty.call(n,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=n[i]),Reflect.deleteProperty(n,i),e=!0),r&&Object.prototype.hasOwnProperty.call(r,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=r[i]),delete r[i],e=!0);r&&Object.keys(r).length===0&&delete n.extra}return e}function Wx(t){return et(t,{onShape:e=>{PM(e)}}),t}function TM(t){if(t.type!=="connector")return;let e=t.state,n=ha(e.sourcePoint),r=ha(e.targetPoint);t.type="line",t.state={...t.state,x1:typeof e.x1=="number"?e.x1:n?.x??0,y1:typeof e.y1=="number"?e.y1:n?.y??0,x2:typeof e.x2=="number"?e.x2:r?.x??0,y2:typeof e.y2=="number"?e.y2:r?.y??0,routingMode:e.routingMode??"orthogonal"}}function Yx(t){let e=t.customPivot;if(e)return e;let n=t.x,r=t.y,i=t.width,o=t.height;if(typeof n=="number"&&typeof r=="number"&&typeof i=="number"&&typeof o=="number")return{x:n+i/2,y:r+o/2};let s=t.radius;if(typeof n=="number"&&typeof r=="number"&&typeof s=="number")return{x:n,y:r};let a=t.cx,c=t.cy;if(typeof a=="number"&&typeof c=="number")return{x:a,y:c};let l=t.x1,d=t.y1,u=t.x2,p=t.y2;if(typeof l=="number"&&typeof d=="number"&&typeof u=="number"&&typeof p=="number")return{x:(l+u)/2,y:(d+p)/2};let f=t.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let m=t.polylinePoints;if(m?.[0])return{x:m[0].x,y:m[0].y}}function RM(t){return et(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||Sf(n,Yx(n))}}),t.schemaVersion=3,t}function ha(t){let e=t;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 CM(t,e){let n=t.translateX??0,r=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",o=qe(n,r);if(i)return tt(ge(o,Ht(i)));let s=t.rotation??0,a=t.skewX??0,c=t.skewY??0;if(s!==0||a!==0||c!==0){let u=ha(t.customPivot)??e??ha(t.scaleAnchor);u&&(o=ge(o,qe(u.x,u.y)),s!==0&&(o=ge(o,ji(s))),a!==0&&(o=ge(o,vs(a))),c!==0&&(o=ge(o,xs(c))),o=ge(o,qe(-u.x,-u.y)))}let l=t.scaleX??1,d=t.scaleY??1;if(l!==1||d!==1){let u=ha(t.scaleAnchor)??e;u&&(o=ge(o,qe(u.x,u.y)),o=ge(o,li(l,d)),o=ge(o,qe(-u.x,-u.y)))}return tt(o)}function $M(t){return et(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||!("scaleAnchor"in n)||(e.type==="text"&&!ir(n.transformMatrix)&&(n.transformMatrix=CM(n,Yx(n))),delete n.scaleAnchor)}}),t.schemaVersion=4,t}function NM(t){let e=t,n=Array.isArray(t.library)?[...t.library]:[],r=new Set(n.map(l=>l.id));if(Array.isArray(e.symbols))for(let l of e.symbols)!l||r.has(l.id)||(n.push({...l,kind:"symbol"}),r.add(l.id));if(Array.isArray(e.markers))for(let l of e.markers)!l||r.has(l.id)||(n.push({...l,kind:"marker"}),r.add(l.id));let i=new Map,o=(l,d)=>{let{id:u,sourceId:p,...f}=l,m=JSON.stringify({kind:d,...f}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`grd-${Kd()}`:l.id;r.add(h),i.set(m,h);let y=d==="linear-gradient"?{kind:"linear-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:Kx(l)}:{kind:"radial-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:Kx(l)};return n.push(y),h},s=new Map;if(Array.isArray(e.customPatterns))for(let l of e.customPatterns){if(!l)continue;let d=r.has(l.id)?`pat-${Kd()}`:l.id;r.add(d),s.set(l.id,d),n.push(ko(l,d))}let a=l=>{if(l.customPatternId){let b=s.get(l.customPatternId);if(b)return b}let{id:d,sourceId:u,customPatternId:p,...f}=l,m=JSON.stringify({kind:"pattern",...f}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`pat-${Kd()}`:l.id;r.add(h),i.set(m,h);let y={kind:"pattern",id:h,name:l.sourceId??h,sourceId:l.sourceId,pattern:f};return n.push(y),h};for(let l of t.shapes??[]){let d=l.state;if(!d)continue;let u=d.fillGradient;u&&(typeof d.fillType!="string"&&(d.fillType=u.type),u.type==="linear-gradient"||u.type==="radial-gradient"?d.fillLibraryId=o(u,u.type):u.type==="pattern"&&(d.fillLibraryId=a(u)));let p=d.strokeGradient;p&&(typeof d.strokeType!="string"&&(d.strokeType=p.type),p.type==="linear-gradient"||p.type==="radial-gradient"?d.strokeLibraryId=o(p,p.type):p.type==="pattern"&&(d.strokeLibraryId=a(p)));let f=d.filters;if(Array.isArray(f)&&f.length>0){let m=c(f,d,l.id);d.filterLibraryIds=[m]}}return t.library=n,et(t,{onShape:TM}),delete e.customPatterns,delete e.symbols,delete e.markers,t;function c(l,d,u){let p={filters:l,colorInterpolation:d.filterColorInterpolation,filterUnits:d.filterUnits,primitiveUnits:d.primitiveUnits,x:d.filterX,y:d.filterY,width:d.filterWidth,height:d.filterHeight},f=JSON.stringify({kind:"filter",...p}),m=i.get(f);if(m)return m;let g=`filter-${u}`,h=r.has(g)?`flt-${Kd()}`:g;r.add(h),i.set(f,h);let y={kind:"filter",id:h,name:h,filters:p.filters,...p.colorInterpolation?{colorInterpolation:p.colorInterpolation}:{},...p.filterUnits?{filterUnits:p.filterUnits}:{},...p.primitiveUnits?{primitiveUnits:p.primitiveUnits}:{},...p.x!==void 0?{x:p.x}:{},...p.y!==void 0?{y:p.y}:{},...p.width!==void 0?{width:p.width}:{},...p.height!==void 0?{height:p.height}:{}};return n.push(y),h}}function Kx(t){let{id:e,sourceId:n,...r}=t;return r}var bg=0;function Kd(){return bg=bg+1&65535,`${Date.now().toString(36)}-${bg.toString(36)}`}function AM(t){return et(t,{onState:e=>{let n=e,r=Object.prototype.hasOwnProperty.call(n,"richTextData"),i=n.richTextData;if(Qo(e),!r)return;n.richTextData=i;let o=e.extra;o&&(delete o.richTextData,Object.keys(o).length===0&&delete e.extra)}}),t.schemaVersion=5,t}function EM(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(e.richTextRuns!==void 0&&e.richTextRuns!==null)return;let n=e.richTextData;!n||typeof n!="object"||Array.isArray(n)||Array.isArray(n.lines)&&(e.richTextRuns=Jn(n))}function MM(t){return et(t,{onState:e=>EM(e)}),t.schemaVersion=6,t}function vg(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function Po(t){let e=new Set,n=new Set,r=new Map;et(t,{onShape:o=>{if(n.add(o.id),o.type!=="view")return;r.has(o.id)||r.set(o.id,o);let s=o.state.viewName;typeof s=="string"&&s&&e.add(s)}});let i=[];return(t.viewboxes??[]).filter(o=>{let s=r.get(o.id);return!(s&&s.state.viewBoxX===o.x&&s.state.viewBoxY===o.y&&s.state.viewBoxWidth===Math.max(1,o.width)&&s.state.viewBoxHeight===Math.max(1,o.height))}).forEach((o,s)=>{let a=vg(`view-${s+1}`,e);e.add(a);let c=vg(o.id||`legacy-view-${s+1}`,n);n.add(c),i.push({id:c,type:"view",state:{viewBoxX:o.x,viewBoxY:o.y,viewBoxWidth:Math.max(1,o.width),viewBoxHeight:Math.max(1,o.height),viewName:a}})}),i.length>0&&t.shapes.unshift(...i),t.viewboxes=[],t}var OM=["svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio"];function DM(t){if(t.type!=="svg"||t.state.isRootSvg===!0)return;let e=t.state;if(![e.svgViewBoxX,e.svgViewBoxY,e.svgViewBoxWidth,e.svgViewBoxHeight].every(i=>i===0))return;if(e.svgX===0&&e.svgY===0&&e.svgWidth===0&&e.svgHeight===0&&e.svgPreserveAspectRatio===""){for(let i of OM)delete e[i];return}delete e.svgViewBoxX,delete e.svgViewBoxY,delete e.svgViewBoxWidth,delete e.svgViewBoxHeight}function xg(t){return et(t,{onShape:DM}),Po(t),t.schemaVersion=7,t}var zM=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function _M(t,e){if(t.type!=="symbol-instance"||t.state.authoredUseGeometry!==void 0)return;let n={};for(let r of["x","y","width","height"]){if((r==="width"||r==="height")&&e.has(String(t.state.symbolId??"")))continue;let i=t.state[r];typeof i=="number"&&Number.isFinite(i)&&(n[r]=String(i))}Object.keys(n).length>0&&(t.state.authoredUseGeometry=n)}function FM(t){let e=new Set((t.library??[]).filter(n=>n.kind==="symbol"&&n.defKind==="group").map(n=>n.id));for(let n of t.library??[]){if(n.kind!=="symbol")continue;let r=n,i={...r.wrapperAttrs??{},...r.rootAttributes??{}};for(let s of zM){let a=i[s];r[s]===void 0&&a!==void 0&&(r[s]=a),delete i[s]}if(r.overflow!==void 0&&i.overflow===void 0&&(i.overflow=r.overflow),Object.keys(i).length>0?r.rootAttributes=i:delete r.rootAttributes,r.shapes=ga(r.shapes,r.groups),r.variants)for(let[s,a]of Object.entries(r.variants))r.variants[s]=ga(a,r.groups);let o=r;delete o.wrapperAttrs,delete o.groups,delete o.overflow}return et(t,{onShape:n=>_M(n,e)}),t.schemaVersion=8,t}function LM(t){let e=t;Array.isArray(t.shapes)&&(t.shapes=ga(t.shapes,e.groups)),delete e.groups,Array.isArray(e.rawPaintServerDefs)&&!Array.isArray(t.paintServerDefs)&&(t.paintServerDefs=Hy(e.rawPaintServerDefs)),delete e.rawPaintServerDefs;for(let n of t.library??[]){if(n.kind!=="marker")continue;let r=n;r.shapes=ga(r.shapes,r.groups),delete r.groups}return Array.isArray(e.clipMaskGroups)&&(t.clipMaskGroups=e.clipMaskGroups.map(n=>{let r=n,i=Array.isArray(r.clipShapeIds)?r.clipShapeIds:typeof r.clipShapeId=="string"&&r.clipShapeId.length>0?[r.clipShapeId]:[],o={...r,clipShapeIds:i};return delete o.clipShapeId,o})),t.schemaVersion=9,t}function BM(t){return et(t,{onState:e=>{let n=e;n.richTextRuns===void 0&&n.richTextData!==null&&typeof n.richTextData=="object"&&Array.isArray(n.richTextData.lines)&&(n.richTextRuns=Jn(n.richTextData)),delete n.richTextData}}),t.schemaVersion=10,t}function GM(t){let n=(Array.isArray(t)?t.slice(0,6).join(" "):String(t)).trim().toLowerCase();return n==="none"||n==="hidden"||n==="collapse"?"none":"inline"}function Xx(t){let e=new Set(t.keyframes.flatMap(n=>n.id?[n.id]:[]));if(t.keyframes.forEach((n,r)=>{if(n.id)return;let i=`kf${r}`;for(;e.has(i);)i=`${i}x`;n.id=i,e.add(i)}),t.property==="visibility"&&t.sourceSmilAttribute==="display"){t.property="display";for(let n of t.keyframes)n.value=GM(n.value)}delete t.sourceSmilAttribute}function VM(t){if(!Array.isArray(t.shapes))return;let e=new Map,n=new Map,r=new Map,i=(s,a)=>{let c=a?n:e,l=c.get(s.id)??[];l.push(s),c.set(s.id,l),r.set(s.id,(r.get(s.id)??0)+1);let d=s.state.children;Array.isArray(d)&&d.forEach(u=>i(u,!0))};t.shapes.forEach(s=>i(s,!1));let o=new Set;for(let[s,a]of e)a.length!==1||r.get(s)!==2||(n.get(s)??[]).length===1&&o.add(s);t.shapes=t.shapes.filter(s=>!o.has(s.id))}function jM(t){if(!Array.isArray(t.shapes))return;et(t,{onShape:a=>{if(a.type!=="view")return;let c=a.state;Reflect.deleteProperty(c,"viewLinkedSvgId"),typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&Reflect.deleteProperty(c.extra,"viewLinkedSvgId")}});let e=t.shapes.filter(a=>{if(a.type!=="view")return!1;let c=a.state;return c.isHomeView===!0||typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&c.extra.isHomeView===!0});if(e.length===0)return;let n=e[0].state,r=Number(n.viewBoxWidth??0),i=Number(n.viewBoxHeight??0),o=t.shapes.find(a=>a.type==="svg"&&a.state.isRootSvg===!0);if(o&&r>0&&i>0){let a=Number(o.state.svgViewBoxWidth??0),c=Number(o.state.svgViewBoxHeight??0);a>0&&c>0||(o.state.svgViewBoxX=Number(n.viewBoxX??0),o.state.svgViewBoxY=Number(n.viewBoxY??0),o.state.svgViewBoxWidth=r,o.state.svgViewBoxHeight=i,Number(o.state.svgWidth??0)>0||(o.state.svgWidth=r),Number(o.state.svgHeight??0)>0||(o.state.svgHeight=i))}let s=new Set(e.map(a=>a.id));t.shapes=t.shapes.filter(a=>!s.has(a.id)),t.sceneTree=t.sceneTree?.filter(a=>!s.has(a.id))}function UM(t){if(!Array.isArray(t.shapes))return;let e=new Set;et(t,{onShape:i=>{typeof i.id=="string"&&e.add(i.id)}});let n=new Map,r=i=>i.map(o=>{let s=o.state.children;Array.isArray(s)&&(o.state.children=r(s));let a=o.state.metadata;if(!a||typeof a!="object"||Array.isArray(a))return o;let c=typeof a.linkUrl=="string"?a.linkUrl:"",l=typeof a.linkTarget=="string"?a.linkTarget:"";if(!Object.hasOwn(a,"linkUrl")&&!Object.hasOwn(a,"linkTarget"))return o;let{linkUrl:d,linkTarget:u,...p}=a;if(o.state.metadata=p,!c||o.type==="hyperlink")return o;let f=vg(`${o.id}-link`,e);return e.add(f),n.set(o.id,f),{id:f,type:"hyperlink",state:{href:c,...l?{linkTarget:l}:{},children:[o]}}});t.shapes=r(t.shapes);for(let i of t.library??[])if(!(i.kind!=="symbol"&&i.kind!=="marker")&&(i.shapes=r(i.shapes),i.kind==="symbol"&&i.variants))for(let[o,s]of Object.entries(i.variants))i.variants[o]=r(s);if(t.sceneTree&&n.size>0){let i=[];for(let o of t.sceneTree){let s=n.get(o.id);if(!s){i.push(o);continue}i.push({...o,id:s}),i.push({id:o.id,parentId:s,index:0})}t.sceneTree=i}}function HM(t){et(t,{onState:e=>{(e.fillType==="linear-gradient"||e.fillType==="radial-gradient"||e.fillType==="pattern")&&e.fillColor==="none"&&e.fillOpacity===0&&(e.fillOpacity=1)}})}function WM(t){et(t,{onState:e=>{Array.isArray(e.charOffsets)&&(e.charOffsets=e.charOffsets.map(n=>{if(!n||typeof n!="object"||"dx"in n||typeof n.x!="number")return n;let r=n;return{x:null,y:null,dx:r.x,dy:typeof r.y=="number"&&Number.isFinite(r.y)?r.y:0,rotate:typeof r.rotate=="number"&&Number.isFinite(r.rotate)?r.rotate:0}}))}})}function KM(t){et(t,{onShape:e=>{if(e.type!=="group")return;let n=e.state,r=n.groupData;if(!r||typeof r!="object"||Array.isArray(r))return;let i=r,o=i.attributes;if(o&&typeof o=="object"&&!Array.isArray(o)){let s={...o};n.locked===void 0&&s["data-locked"]==="true"&&(n.locked=!0),n.visible===void 0&&s["data-hidden"]==="true"&&(n.visible=!1),delete s["data-locked"],delete s["data-hidden"],Object.keys(s).length>0?i.attributes=s:delete i.attributes}Array.isArray(i.classes)&&(i.classes=i.classes.map(s=>{let a=String(s);return a.startsWith("usr-")?a.slice(4):a}))}})}function XM(t){let e=Wx(t);Po(e),jM(e),VM(e),UM(e),HM(e),WM(e),KM(e);for(let n of e.animationTimeline?.tracks??[])Xx(n);for(let n of e.library??[])if(n.kind==="marker")for(let r of n.animations??[])Xx(r);return e.schemaVersion=11,e}function Ig(t){return t.schemaVersion=12,t}function YM(t){return t.schemaVersion=13,t}var wg=Object.freeze({1:NM,2:RM,3:$M,4:AM,5:MM,6:xg,7:FM,8:LM,9:BM,10:XM,11:Ig,12:YM});function qM(t){let e=t.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function To(t,e=wg){let n=JSON.parse(JSON.stringify(t)),r=qM(n);if(r>_t)return n;if(r===_t)return n.schemaVersion=_t,n;for(;r<_t;){let i=e[r];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${r} \u2192 ${r+1}. Cannot safely upgrade this document to version ${_t}.`);n=i(n),r+=1}return n.schemaVersion=_t,n}var Qx=["unknown-shape-diagnostic","symbol-variants-overrides","smil-timeline","motion-only-partition","paint-server-references","filter-references","document-definition-context","inline-child-containers","isolated-flowchart-nodes","text-path","common-presentation","gradient-definition-envelope","filter-definition-envelope","export-precision-rounding","defs-deduplication","source-id-restoration","orphan-def-exclusion","font-embedding","initial-value-elision","namespace-declaration-completion"],ee=t=>({mode:"supported",by:t}),Vr=t=>({mode:"diagnostic",signal:"warning",by:t}),ye=t=>({mode:"outside-contract",reason:t}),ct=t=>t,qx=ye("DXF is a static CAD geometry contract and has no representation for this SVG behavior."),Zx=ye("Mermaid is a static graph-structure contract and has no representation for this SVG behavior."),Jx=ye("PDF export produces a static page from the current editor SVG projection and does not promise animation playback."),eI={"unknown-shape-diagnostic":ct({renderToSvg:Vr("renderShape reports UNSUPPORTED_SHAPE_TYPE through renderToSvgWithDiagnostics"),codegen:Vr("buildRenderPlan carries UNSUPPORTED_SHAPE_TYPE into generateCodeWithDiagnostics"),dxf:Vr("DxfExportStats records unsupported types and the DXF export UI reports them"),mermaid:Vr("exportMermaidWithDiagnostics records unsupported nodes and both Mermaid UIs report them"),pdf:ye("PDF conversion consumes an already-projected editor SVG; unknown model nodes never enter its input."),"editor-dom":ye("Unknown nodes are preserved for round-trip but require a registered shape implementation for projection.")}),"symbol-variants-overrides":ct({renderToSvg:ee("buildRenderPlan materializes symbol variants and per-instance overrides before emission"),codegen:ee("every component backend consumes buildRenderPlan symbol materialization"),dxf:Vr("DXF unsupported-shape accounting reports symbol instances without a lowering"),mermaid:Vr("Mermaid node-skip diagnostics report symbol instances without a lowering"),pdf:ee("the editor projects SymbolInstance content into the SVG consumed by svg2pdf"),"editor-dom":ee("SymbolInstance projects resolved library variants and overrides")}),"smil-timeline":ct({renderToSvg:ee("buildRenderPlan injects renderAnimationElements output into shape markup"),codegen:ee("component backends preserve SMIL children in planned shape markup"),dxf:qx,mermaid:Zx,pdf:Jx,"editor-dom":ee("AnimationManager and the shared SMIL kernel project live playback")}),"motion-only-partition":ct({renderToSvg:ee("buildRenderPlan diverts motionOnly templates into defs outside visible paint"),codegen:ee("component backends consume the render plan visible and motion-def partitions"),dxf:qx,mermaid:Zx,pdf:Jx,"editor-dom":ye("The authoring DOM retains motion templates for editing instead of applying export partitioning.")}),"paint-server-references":ct({renderToSvg:ee("plan defs and shapes use one library-first paint-server reference resolver"),codegen:ee("buildShapeAttrs and plan defs use the library-first reference resolver"),dxf:ye("DXF promises geometry and basic entity colors, not SVG paint-server definition graphs."),mermaid:ye("Mermaid graph syntax has no SVG gradient or pattern paint-server model."),pdf:ee("the cloned SVG carries paint-server definitions and references into svg2pdf"),"editor-dom":ee("GradientManager maintains live defs matching shape paint references")}),"filter-references":ct({renderToSvg:ee("renderFilterDefs and filterReferenceValue emit matching identifiers"),codegen:ee("planned filter defs and buildShapeAttrs share filter reference resolution"),dxf:ye("DXF entity geometry has no SVG filter graph or filter-reference representation."),mermaid:ye("Mermaid graph syntax has no SVG filter graph or filter-reference representation."),pdf:ee("the cloned SVG carries filter definitions and references into svg2pdf"),"editor-dom":ee("FilterManager maintains live filter definitions and shape references")}),"document-definition-context":ct({renderToSvg:ee("buildRenderPlan consumes the full snapshot definition and style context"),codegen:ee("component codegen accepts snapshot context and clipboard supplies its definitions"),dxf:ye("DXF consumes resolved shapes and does not serialize SVG document definition sections."),mermaid:ye("Mermaid consumes graph nodes and does not serialize SVG definition sections."),pdf:ee("PDF receives a cloned SVG document with its referenced definition context"),"editor-dom":ee("the document aggregate and managers project referenced resources into defs")}),"inline-child-containers":ct({renderToSvg:ee("renderShape recursively renders INLINE_CHILD_CONTAINER_TYPES children"),codegen:ee("component backends preserve recursively rendered plan container markup"),dxf:ee("DXF walks INLINE_CHILD_CONTAINER_TYPES with transforms and cycle guards"),mermaid:Vr("unsupported container nodes are counted by exportMermaidWithDiagnostics"),pdf:ee("the cloned editor SVG preserves nested containers for svg2pdf"),"editor-dom":ee("registered containers project managed children into nested SVG elements")}),"isolated-flowchart-nodes":ct({renderToSvg:ye("Isolated-node declarations are a Mermaid graph concern, not an SVG branch."),codegen:ye("Isolated-node declarations are a Mermaid graph concern, not component SVG output."),dxf:ye("DXF emits geometry independently and has no connector-enrolment requirement."),mermaid:ee("exportMermaid declares mapped nodes before emitting connector edges"),pdf:ye("PDF paints SVG geometry independently and has no graph-node declaration requirement."),"editor-dom":ye("The live SVG projects shapes independently and has no graph-node declaration requirement.")}),"text-path":ct({renderToSvg:ee("renderText emits textPath markup and its referenced path definition"),codegen:ee("component backends preserve planned textPath markup and definitions"),dxf:ye("DXF text entities do not reproduce SVG textPath layout along arbitrary paths."),mermaid:ye("Mermaid labels do not reproduce SVG textPath layout along arbitrary paths."),pdf:Vr("ExportPanel.generatePdfBlob detects textPath content and shows its localized warning"),"editor-dom":ee("Text projects textPath attributes and maintains its referenced path")}),"common-presentation":ct({renderToSvg:ee("commonAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),codegen:ee("buildShapeAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),dxf:ye("DXF is not an SVG presentation-attribute serialization contract."),mermaid:ye("Mermaid is not an SVG presentation-attribute serialization contract."),pdf:ee("svg2pdf consumes common presentation attributes from the cloned SVG"),"editor-dom":ee("COMMON_PROP_RENDERERS derives its dispatch from PRESENTATION_SEMANTICS")}),"gradient-definition-envelope":ct({renderToSvg:ee("gradient renderers serialize the shared typed definition envelopes"),codegen:ee("render plan defs contain gradients serialized from shared typed envelopes"),dxf:ye("DXF has no SVG linearGradient or radialGradient definition envelope."),mermaid:ye("Mermaid has no SVG linearGradient or radialGradient definition envelope."),pdf:ee("the cloned SVG supplies shared-envelope gradient definitions to svg2pdf"),"editor-dom":ee("GradientManager projects shared gradient envelopes into live defs")}),"filter-definition-envelope":ct({renderToSvg:ee("renderFilterElement serializes filterDefinitionEnvelope for each wrapper kind"),codegen:ee("render plan defs contain filters serialized from shared typed envelopes"),dxf:ye("DXF has no SVG filter element or primitive graph envelope representation."),mermaid:ye("Mermaid has no SVG filter element or primitive graph envelope representation."),pdf:ee("the cloned SVG supplies shared-envelope filter definitions to svg2pdf"),"editor-dom":ee("FilterManager projects filterDefinitionEnvelope before primitive emission")}),"export-precision-rounding":ct({renderToSvg:ee("finalizeRenderPlan rounds markup coordinates at the effective documentMetadata.coordinatePrecision"),codegen:ye("Codegen backends consume the un-finalized render plan; component output precision is a code-style concern, not an export boundary."),dxf:ye("DXF numeric precision is owned by the DXF writer, not the SVG export boundary."),mermaid:ye("Mermaid emits graph syntax rather than SVG coordinate attribute streams."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core rounding); selection pages pass through SvgExportFinalizer.roundSvgAttributes"),"editor-dom":ee("static string exports round through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks round through SvgExportFinalizer.roundSvgAttributes; the raster clone sink skips rounding by design (spelling-only, pixel-irrelevant)")}),"defs-deduplication":ct({renderToSvg:ee("finalizeRenderPlan collapses content-identical gradient/pattern/marker defs and rewrites references"),codegen:ye("Codegen backends consume the un-finalized render plan; def duplication in generated components is a code-size concern outside the export contract."),dxf:ye("DXF output has no shared-definition graph in which duplicates could exist."),mermaid:ye("Mermaid output has no shared-definition graph in which duplicates could exist."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core dedup); selection pages pass through SvgExportFinalizer.deduplicateDefsForExport"),"editor-dom":ee("static string exports dedup through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.deduplicateDefsForExport; the raster clone sink skips dedup by design (spelling-only, pixel-irrelevant)")}),"source-id-restoration":ct({renderToSvg:ee("finalizeRenderPlan restores uncontested library sourceIds and rewrites references"),codegen:ye("Generated components keep collision-safe runtime ids; source ids are a document round-trip concern."),dxf:ye("DXF entities carry no SVG id namespace for source ids to be restored into."),mermaid:ye("Mermaid nodes carry no SVG id namespace for source ids to be restored into."),pdf:ye("PDF output has no id namespace to restore; the intermediate SVG string restores ids for fidelity but the PDF consumer never observes them."),"editor-dom":ee("static string exports restore source ids through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.restoreSourceIds; the raster clone sink skips restoration by design (ids are spelling, not pixels)")}),"orphan-def-exclusion":ct({renderToSvg:ee("def emission is demand-driven (collectReferencedLibraryDefs, the referenced-marker gate, the paint-server reachability fixed point) \u2014 unreferenced defs are never emitted, so no pruning pass exists or is needed"),codegen:ee("component backends consume the same demand-driven plan def channels"),dxf:ye("DXF output has no defs graph from which orphans could need excluding."),mermaid:ye("Mermaid output has no defs graph from which orphans could need excluding."),pdf:ee("the editor SVG consumed by svg2pdf passes through pruneOrphanedDefs"),"editor-dom":ee("static string exports are demand-driven via the core plan (no orphans emitted); the raster/selection clone sinks sweep accumulated live defs with SvgExportFinalizer.pruneOrphanedDefs")}),"font-embedding":ct({renderToSvg:ee("finalizeRenderPlan ships @font-face CSS from the injected resolveFontEmbedCss hook (core is platform-free; binary resolution is the caller environment responsibility)"),codegen:ye("Generated components inherit the host page font pipeline; embedding binaries in component source is out of contract."),dxf:ye("DXF text styling is font-name based; the format has no font binary embedding."),mermaid:ye("Mermaid delegates font resolution entirely to the rendering host page."),pdf:ee("svg2pdf consumes the editor SVG after embedFontsInClone inlined @font-face CSS"),"editor-dom":ee("static string exports resolve plan-collected families through fontManager into the core resolveFontEmbedCss hook; the embedded-SVG subtree async export runs SvgExportFinalizer.embedFontsInClone; raster sinks rasterize with the session live font faces and need no embedding")}),"initial-value-elision":ct({renderToSvg:ee("finalizeRenderPlan drops redundant spec initials and product defaults under an initial-valued cascade (elideInitialValuesInPlan)"),codegen:ye("Codegen backends consume the un-finalized plan; explicit values in component source are a readability choice, not an export-boundary concern."),dxf:ye("DXF entities carry explicit CAD attributes with no SVG initial-value cascade."),mermaid:ye("Mermaid emits graph syntax; SVG presentation initial values never appear in its output."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core elision); selection pages pass through SvgExportFinalizer.stripDefaultPaintAttributes"),"editor-dom":ee("static string exports elide through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.stripDefaultPaintAttributes and the output-artifact rules; the raster clone sink keeps default attributes by design (elision is spelling-only)")}),"namespace-declaration-completion":ct({renderToSvg:ee("finalizeRenderPlan declares used prefixes on the root via a well-known URI table (declareUsedNamespacePrefixes); unresolvable prefixes warn undeclarable-namespace-prefix"),codegen:ye("Generated components render into a host document whose framework owns namespace handling; JSX/Vue templates have no xmlns declaration surface to complete."),dxf:ye("DXF is not XML and has no namespace prefixes to declare or complete."),mermaid:ye("Mermaid graph syntax is not XML; no namespace declarations exist."),pdf:ee("svg2pdf consumes the editor SVG string whose serializer declared every namespace it uses"),"editor-dom":ee("static string exports complete declarations through core declareUsedNamespacePrefixes; the raster/selection clone sinks rely on XMLSerializer plus hoistForeignNamespaceDecls")})};function Ri(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}async function Pg(t,e,n,r){let i=t[e];typeof i=="string"&&(t[e]=await r(i,n))}async function kg(t,e){Ri(t)&&await Pg(t,"svgContent","svgMarkup",e)}async function Xd(t,e){if(!Ri(t))return;await Pg(t,"href","href",e),await kg(t.fillGradient,e),await kg(t.strokeGradient,e);let n=t.children;if(Array.isArray(n))for(let r of n)Ri(r)&&await Xd(r.state,e)}async function tI(t,e){if(!Ri(t))return;let n=t.shapes;if(Array.isArray(n))for(let o of n)Ri(o)&&await Xd(o.state,e);let r=t.library;if(Array.isArray(r))for(let o of r)Ri(o)&&o.kind==="pattern"&&await kg(o.pattern,e);let i=t.customPatterns;if(Array.isArray(i))for(let o of i)Ri(o)&&await Pg(o,"svgContent","svgMarkup",e)}function ya(t,e,n={}){let r=Br(t),i=r.errors.filter(o=>!n.ignoreError?.(o));if(i.length>0){let o=i.map(s=>` ${s.path}: ${s.message}`).join(`
10
33
  `);throw new Error(`Invalid .svgs document:
11
- ${a}`)}}return s}function qc(n){return[...n].sort((e,t)=>e.id.localeCompare(t.id))}function ft(n){if(n==null)return n;if(Array.isArray(n))return n.map(ft);if(typeof n!="object")return n;let e={},t=Object.keys(n).sort();for(let r of t)e[r]=ft(n[r]);return e}function Zc(n){let e={};return e.id=n.id,e.type=n.type,e.state=ft(n.state),e}var Re=/\{\{\s*([\w.\-]+)\s*\}\}/g;function dr(n,e){return n.replace(Re,(t,r)=>{let i=e[r];return i!==void 0?String(i):t})}function mr(n,e={}){let t={};if(n.templateVariables)for(let i of n.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(n));let r=JSON.parse(JSON.stringify(n));for(let i of r.shapes)fr(i.state,t);if(r.documentMetadata){let i=r.documentMetadata;fr(i,t)}return r}function fr(n,e){for(let t of Object.keys(n)){let r=n[t];if(typeof r=="string"){if(Re.lastIndex=0,Re.test(r)){Re.lastIndex=0;let i=dr(r,e);if(Jc(r)){let s=Number(i);if(!isNaN(s)&&ed(t)){n[t]=s;continue}}n[t]=i}}else if(Array.isArray(r))for(let i=0;i<r.length;i++)typeof r[i]=="string"?(Re.lastIndex=0,Re.test(r[i])&&(Re.lastIndex=0,r[i]=dr(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&fr(r[i],e);else r!==null&&typeof r=="object"&&fr(r,e)}}function Jc(n){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(n)}var Qc=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...Bt,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function ed(n){return Qc.has(n)}function hr(n){let e=n.templateVariables??[],t=new Set(e.map(s=>s.name)),r=new Set;for(let s of n.shapes)pr(s.state,r);n.documentMetadata&&pr(n.documentMetadata,r);let i=[...r].filter(s=>!t.has(s)).sort();return{defined:[...e],undeclared:i}}function pr(n,e){for(let t of Object.values(n))if(typeof t=="string"){let r;for(Re.lastIndex=0;(r=Re.exec(t))!==null;)e.add(r[1])}else if(Array.isArray(t))for(let r of t)if(typeof r=="string"){let i;for(Re.lastIndex=0;(i=Re.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&pr(r,e);else t!==null&&typeof t=="object"&&pr(t,e)}function nl(n){let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid variable format: "${t}". Expected "name=value".`);let i=t.slice(0,r).trim(),s=t.slice(r+1);if(!i)throw new Error(`Invalid variable format: "${t}". Variable name cannot be empty.`);e[i]=s}return e}var rl=3,il=12;function sl(n){return n==null||!Number.isFinite(n)?3:n<0?0:n>12?12:Math.floor(n)}function yr(n,e){if(!Number.isFinite(n))return n;let t=Math.pow(10,e);return Math.round(n*t)/t}var td=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function Is(n,e){return n.replace(td,t=>{let r=parseFloat(t);return Number.isFinite(r)?String(yr(r,e)):t})}var nd=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),rd=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function De(n,e,t){if(e==null)return e;if(typeof e=="number")return yr(e,t);if(typeof e=="string")return nd.has(n)?Is(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>De(n,r,t));if(typeof e=="object"){if(rd.has(n))return e;if(n==="symbolOverrides"){let i={};for(let[s,o]of Object.entries(e))i[s]=De("state",o,t);return i}let r={};for(let[i,s]of Object.entries(e))r[i]=De(i,s,t);return r}return e}function gr(n,e){return{id:n.id,type:n.type,state:De("state",n.state,e)}}function al(n,e){let t={...n,shapes:n.shapes.map(r=>gr(r,e)),viewboxes:n.viewboxes.map(r=>De("viewbox",r,e))};return n.guides&&(t.guides=n.guides.map(r=>De("guide",r,e))),n.measurements&&(t.measurements=n.measurements.map(r=>De("measurement",r,e))),n.animationTimeline&&(t.animationTimeline=De("animationTimeline",n.animationTimeline,e)),n.symbols&&(t.symbols=n.symbols.map(r=>({...r,shapes:r.shapes.map(i=>gr(i,e))}))),n.markers&&(t.markers=n.markers.map(r=>De("marker",r,e))),n.customPatterns&&(t.customPatterns=n.customPatterns.map(r=>De("customPattern",r,e))),t}function mn(n,e,t=-90){let r=[],i=t*Math.PI/180;for(let s=0;s<n;s++){let o=i+s*2*Math.PI/n;r.push({x:e*Math.cos(o),y:e*Math.sin(o)})}return r}function Sr(n,e,t,r=-90){let i=[],s=e*(t/100),o=r*Math.PI/180;for(let a=0;a<n*2;a++){let l=o+a*Math.PI/n,c=a%2===0?e:s;i.push({x:c*Math.cos(l),y:c*Math.sin(l)})}return i}function xr(n,e,t=0){let r=n*(e/100)/2,i=[{x:-r,y:-n},{x:r,y:-n},{x:r,y:-r},{x:n,y:-r},{x:n,y:r},{x:r,y:r},{x:r,y:n},{x:-r,y:n},{x:-r,y:r},{x:-n,y:r},{x:-n,y:-r},{x:-r,y:-r}];if(t===0)return i;let s=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180);return i.map(a=>({x:a.x*s-a.y*o,y:a.x*o+a.y*s}))}function $r(n,e,t,r,i=-90){let o=n*2*(t/100),a=n*(e/100),l=a*(r/100),c=[{x:n,y:0},{x:n-o,y:-a/2},{x:n-o,y:-l/2},{x:-n,y:-l/2},{x:-n,y:l/2},{x:n-o,y:l/2},{x:n-o,y:a/2}];if(i===0)return c;let f=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180);return c.map(p=>({x:p.x*f-p.y*d,y:p.x*d+p.y*f}))}function vr(n,e,t,r,i=0){let s=n,o=s*(t/100),a=s*(r/100),l=a/2,c=e*Math.PI/180,f=Math.cos(c),d=Math.sin(c),p=Math.abs(f),m=Math.abs(d),h=Math.max(p,m)||1,g={x:f*(s/h),y:d*(s/h)},b={x:g.x+f*o,y:g.y+d*o},$=Math.min(a,s-l),k=-s+l+$,S=s-l-$,x={x:-s,y:-s},v={x:s,y:-s},w={x:s,y:s},T={x:-s,y:s},P;if(p>=m&&f>0){let N=Math.max(k,Math.min(S,g.y)),B={x:s,y:N-l},D={x:s,y:N+l};P=[x,v,B,b,D,w,T]}else if(p>=m&&f<=0){let N=Math.max(k,Math.min(S,g.y)),B={x:-s,y:N+l},D={x:-s,y:N-l};P=[x,v,w,T,B,b,D]}else if(d<0){let N=Math.max(k,Math.min(S,g.x)),B={x:N-l,y:-s},D={x:N+l,y:-s};P=[x,B,b,D,v,w,T]}else{let N=Math.max(k,Math.min(S,g.x)),B={x:N+l,y:s},D={x:N-l,y:s};P=[x,v,w,B,b,D,T]}if(i===0)return P;let R=Math.cos(i*Math.PI/180),M=Math.sin(i*Math.PI/180);return P.map(N=>({x:N.x*R-N.y*M,y:N.x*M+N.y*R}))}function kr(n,e,t,r,i=0){let s=Math.max(2,Math.round(e)),o=n*(t/100),a=n*(r/100)/2,l=s+1,c=[];for(let g=0;g<l;g++){let b=g/(l-1),$=-n+b*2*n,k=0;g>0&&g<l-1&&(k=g%2===1?o:-o),c.push({x:k,y:$})}let f=[],d=[];for(let g=0;g<l;g++){if(g===0||g===l-1){f.push({...c[g]}),d.push({...c[g]});continue}let b=c[g-1],$=c[g],k=c[g+1],S=$.x-b.x,x=$.y-b.y,v=Math.hypot(S,x)||1,w=S/v,T=x/v,P=k.x-$.x,R=k.y-$.y,M=Math.hypot(P,R)||1,N=P/M,B=R/M,D=(w+N)/2,L=(T+B)/2,K=Math.hypot(D,L),C,re;K<1e-6?(C=-T,re=w):(C=-L/K,re=D/K),f.push({x:$.x-C*a,y:$.y-re*a}),d.push({x:$.x+C*a,y:$.y+re*a})}let p=[];p.push(f[0]);for(let g=1;g<l-1;g++)p.push(d[g]);p.push(f[l-1]);for(let g=l-2;g>=1;g--)p.push(f[g]);if(i===0)return p;let m=Math.cos(i*Math.PI/180),h=Math.sin(i*Math.PI/180);return p.map(g=>({x:g.x*m-g.y*h,y:g.x*h+g.y*m}))}function Tr(n,e,t,r=0){let i=n,s=Math.max(.3,Math.min(.9,e/100)),o=-i*(t/100),a={x:0,y:i},l={x:0,y:o},c={x:-i*s,y:i*.4},f={x:-i*s,y:-i},d={x:i*s,y:-i},p={x:i*s,y:i*.4},m=[a,c,f,l,d,p,a],h=r===0?m:(()=>{let v=Math.cos(r*Math.PI/180),w=Math.sin(r*Math.PI/180);return m.map(T=>({x:T.x*v-T.y*w,y:T.x*w+T.y*v}))})(),[g,b,$,k,S,x]=h;return`M ${g.x} ${g.y} C ${b.x} ${b.y} ${$.x} ${$.y} ${k.x} ${k.y} C ${S.x} ${S.y} ${x.x} ${x.y} ${g.x} ${g.y} Z`}function wr(n,e,t,r=0){let i=Math.max(3,Math.round(e)),s=Math.max(.3,Math.min(1,t/100)),o=n,a=o*1.7,l=o*1.15,c=[];for(let T=0;T<i;T++){let R=(90+T/i*360)*Math.PI/180;c.push({x:a/2*Math.cos(R),y:-(l/2)*Math.sin(R)})}let f=.15,d=0;for(let T=0;T<i;T++){let P=c[T],R=c[(T+1)%i];d=Math.max(d,Math.hypot(R.x-P.x,R.y-P.y))}let p=d/(2*(1-f))+.001,m=Math.max(p,d*(.68+s*.35)),h=c.map(T=>{let P=T.y/(l/2);return m*(1-f*P)});function g(T){let P=c[T],R=c[(T+1)%i],M=h[T],N=h[(T+1)%i],B=R.x-P.x,D=R.y-P.y,L=Math.hypot(B,D)||1,K=(M*M-N*N+L*L)/(2*L),C=Math.sqrt(Math.max(0,M*M-K*K)),re=P.x+K/L*B,ee=P.y+K/L*D,Z=-D/L,me=B/L,q={x:re+Z*C,y:ee+me*C},W={x:re-Z*C,y:ee-me*C};return q.x*q.x+q.y*q.y>W.x*W.x+W.y*W.y?q:W}let b=[];for(let T=0;T<i;T++)b.push(g(T));let $=14,k=[];for(let T=0;T<i;T++){let P=c[T],R=h[T],M=b[(T-1+i)%i],N=b[T],B=Math.atan2(M.y-P.y,M.x-P.x),L=Math.atan2(N.y-P.y,N.x-P.x)-B;L<=0&&(L+=2*Math.PI);let K=2*Math.PI-L,C=B+L/2,re=B-K/2,ee={x:P.x+R*Math.cos(C),y:P.y+R*Math.sin(C)},Z={x:P.x+R*Math.cos(re),y:P.y+R*Math.sin(re)},q=ee.x*ee.x+ee.y*ee.y>Z.x*Z.x+Z.y*Z.y?L:-K;for(let W=0;W<$;W++){let fe=W/$,he=B+fe*q;k.push({x:P.x+R*Math.cos(he),y:P.y+R*Math.sin(he)})}}let S=0;for(let T of k){let P=Math.max(Math.abs(T.x),Math.abs(T.y));P>S&&(S=P)}if(S>0&&S!==o){let T=o/S;for(let P of k)P.x*=T,P.y*=T}let x=T=>{if(r===0)return T;let P=Math.cos(r*Math.PI/180),R=Math.sin(r*Math.PI/180);return{x:T.x*P-T.y*R,y:T.x*R+T.y*P}},v=k.map(x),w=`M ${v[0].x} ${v[0].y}`;for(let T=1;T<v.length;T++)w+=` L ${v[T].x} ${v[T].y}`;return w+=" Z",w}function Ae(n,e=0,t=0){if(n.length<3)return"";if(e<=0)return n.map((s,o)=>(o===0?"M":"L")+`${s.x},${s.y}`).join(" ")+" Z";let r=Math.min(e,t*.4),i="";for(let s=0;s<n.length;s++){let o=n[(s-1+n.length)%n.length],a=n[s],l=n[(s+1)%n.length],c={x:o.x-a.x,y:o.y-a.y},f=Math.hypot(c.x,c.y);c.x/=f,c.y/=f;let d={x:l.x-a.x,y:l.y-a.y},p=Math.hypot(d.x,d.y);d.x/=p,d.y/=p;let m=Math.min(r,f/2),h=Math.min(r,p/2),g={x:a.x+c.x*m,y:a.y+c.y*m},b={x:a.x+d.x*h,y:a.y+d.y*h};i+=s===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${a.x},${a.y} ${b.x},${b.y}`}return i+" Z"}function Pr(n,e,t="evenodd"){let r=n*(e/100),i=t==="nonzero"?1:0;return`M ${n} 0 A ${n} ${n} 0 1 1 ${-n} 0 A ${n} ${n} 0 1 1 ${n} 0 Z M ${r} 0 A ${r} ${r} 0 1 ${i} ${-r} 0 A ${r} ${r} 0 1 ${i} ${r} 0 Z`}function _r(n,e,t,r=1,i=0){let s=n*(t/100),a=Math.round(e*36),l=e*2*Math.PI,c=(n-s/2)/l,f=i*Math.PI/180,d=[],p=[];for(let g=0;g<=a;g++){let b=g/a,$=b*l*r+f,k=c*(b*l)+s/2,S=s/2;d.push({x:(k+S*.3)*Math.cos($),y:(k+S*.3)*Math.sin($)}),p.push({x:Math.max(0,k-S*.3)*Math.cos($),y:Math.max(0,k-S*.3)*Math.sin($)})}let m=`M ${d[0].x} ${d[0].y}`;for(let g=1;g<d.length;g++)m+=` L ${d[g].x} ${d[g].y}`;let h=p[p.length-1];m+=` L ${h.x} ${h.y}`;for(let g=p.length-2;g>=0;g--)m+=` L ${p[g].x} ${p[g].y}`;return m+=" Z",m}var id=.2;function Ds(n,e,t,r=0){let i=e*(t/100),s=e,o=e-i,a=2*Math.PI/n,l=a*id/2,c=a/4,f=r*Math.PI/180,d=[];for(let p=0;p<n;p++){let m=f+p*a;d.push({x:o*Math.cos(m),y:o*Math.sin(m)}),d.push({x:s*Math.cos(m+c-l),y:s*Math.sin(m+c-l)}),d.push({x:s*Math.cos(m+c+l),y:s*Math.sin(m+c+l)}),d.push({x:o*Math.cos(m+a/2),y:o*Math.sin(m+a/2)})}return d}function Rr(n,e,t,r=0,i=0,s="evenodd",o=0){let a=Ds(n,e,t,o),l=Math.min(r,e*.1),c=Ae(a,l,e);if(i>0){let f=e*(i/100),d=s==="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 Ar(n,e,t,r,i,s="round",o="uniform",a){let l=Math.min(t,r)/2,c,f,d,p,m,h,g,b;if(o==="non-uniform"&&a?(c=Math.min(a.radiusTL??i,l),f=Math.min(a.radiusTR??i,l),d=Math.min(a.radiusBR??i,l),p=Math.min(a.radiusBL??i,l),m=a.shapeTL??s,h=a.shapeTR??s,g=a.shapeBR??s,b=a.shapeBL??s):(c=f=d=p=Math.min(i,l),m=h=g=b=s),!(s!=="round"||o==="non-uniform"||c>0&&m!=="round"||f>0&&h!=="round"||d>0&&g!=="round"||p>0&&b!=="round")&&c===f&&f===d&&d===p)return null;let k=`M${n+c},${e}`;return k+=` L${n+t-f},${e}`,k+=br(h,f,n+t,e,"tr"),k+=` L${n+t},${e+r-d}`,k+=br(g,d,n+t,e+r,"br"),k+=` L${n+p},${e+r}`,k+=br(b,p,n,e+r,"bl"),k+=` L${n},${e+c}`,k+=br(m,c,n,e,"tl"),k+=" Z",k}function br(n,e,t,r,i){if(e<=0)return"";switch(n){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${t},${r+e}`;case"br":return` A${e},${e} 0 0 1 ${t-e},${r}`;case"bl":return` A${e},${e} 0 0 1 ${t},${r-e}`;case"tl":return` A${e},${e} 0 0 1 ${t+e},${r}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${t},${r+e}`;case"br":return` A${e},${e} 0 0 0 ${t-e},${r}`;case"bl":return` A${e},${e} 0 0 0 ${t},${r-e}`;case"tl":return` A${e},${e} 0 0 0 ${t+e},${r}`}break;case"bevel":switch(i){case"tr":return` L${t},${r+e}`;case"br":return` L${t-e},${r}`;case"bl":return` L${t},${r-e}`;case"tl":return` L${t+e},${r}`}break;case"notch":switch(i){case"tr":return` L${t-e},${r+e} L${t},${r+e}`;case"br":return` L${t-e},${r-e} L${t-e},${r}`;case"bl":return` L${t+e},${r-e} L${t},${r-e}`;case"tl":return` L${t+e},${r+e} L${t+e},${r}`}break}return""}function Ir(n,e,t,r,i,s={}){let o=e+r/2,a=t+i/2;switch(n){case"diamond":return`M${o},${t} L${e+r},${a} L${o},${t+i} L${e},${a} Z`;case"parallelogram":{let l=(s.slantPercent??20)/100*r;return`M${e+l},${t} L${e+r},${t} L${e+r-l},${t+i} L${e},${t+i} Z`}case"trapezoid":{let l=(s.topWidthPercent??70)/100*r,c=(r-l)/2;return`M${e+c},${t} L${e+c+l},${t} L${e+r},${t+i} L${e},${t+i} Z`}case"terminator":{let l=i/2;return`M${e+l},${t} L${e+r-l},${t} A${l},${l} 0 0 1 ${e+r-l},${t+i} L${e+l},${t+i} A${l},${l} 0 0 1 ${e+l},${t} Z`}case"cylinder":{let l=r/2,c=Math.min((s.capHeightPercent??15)/100*i,i/2);return`M${e},${t+c} A${l},${c} 0 0 1 ${e+r},${t+c} A${l},${c} 0 0 1 ${e},${t+c} L${e},${t+i-c} A${l},${c} 0 0 0 ${e+r},${t+i-c} L${e+r},${t+c} M${o-l},${t+c} A${l},${c} 0 0 0 ${o+l},${t+c}`}case"document-shape":{let l=(s.waveAmplitudePercent??15)/100*i;return`M${e},${t} L${e+r},${t} L${e+r},${t+i} C${e+r*.75},${t+i-l*2} ${o+r*.25},${t+i+l} ${o},${t+i} C${o-r*.25},${t+i-l} ${e+r*.25},${t+i+l*.5} ${e},${t+i} Z`}}}function qe(n,e,t=!1,r=.5,i){if(n.length<2)return n.length===1?`M ${n[0].x} ${n[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return ld(n,t,r);case"BASIS":case"basis":return ud(n,t);case"ARC":case"arc":return i&&i.length>0?sd(n,t,i):pn(n,t,"CUBIC");case"LINEAR":case"linear":return pn(n,t,"LINEAR");case"QUADRATIC":case"quadratic":return pn(n,t,"QUADRATIC");case"CUBIC":case"cubic":return pn(n,t,"CUBIC");default:return pn(n,t)}}function sd(n,e,t){let r=`M ${n[0].x} ${n[0].y}`,i=0,s={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<n.length-1;o++){let a=n[o+1];if(a.isSubpathStart){if(e&&o-i>=1){let c=n[i],f=t?.[o]??s;r+=` A ${f.rx} ${f.ry} ${f.rotation} ${f.largeArc?1:0} ${f.sweep?1:0} ${c.x} ${c.y} Z`}r+=` M ${a.x} ${a.y}`,i=o+1;continue}let l=t?.[o]??s;r+=` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.sweep?1:0} ${a.x} ${a.y}`}if(e&&n.length-i>1){let o=n[i],a=t?.[n.length-1]??s;r+=` A ${a.rx} ${a.ry} ${a.rotation} ${a.largeArc?1:0} ${a.sweep?1:0} ${o.x} ${o.y} Z`}return r}function pn(n,e,t){let r=`M ${n[0].x} ${n[0].y}`,i=0,s=null,o=null;for(let a=0;a<n.length-1;a++){let l=n[a],c=n[a+1];if(c.isSubpathStart){if(e&&a-i>=1){let d=n[i];r+=Ms(l,d,d.segmentType,s,o,t),r+=" Z"}r+=` M ${c.x} ${c.y}`,i=a+1,s=null,o=null;continue}r+=Ms(l,c,c.segmentType,s,o,t);let f=od(c.segmentType??t,l,c);s=f,f==="quad"?o=l.handleOut??null:o=null}if(e&&n.length-i>1){let a=n[n.length-1],l=n[i],c=(l.segmentType??t??(a.handleOut||l.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(r+=Ms(a,l,l.segmentType,s,o,t)),r+=" Z"}return r}var ad=.001;function It(n,e){return Math.abs(n-e)<ad}function od(n,e,t){let r=(n??(e.handleOut||t.handleIn?"CUBIC":"LINEAR")).toUpperCase();return r==="CUBIC"||r==="SMOOTH_CUBIC"?"cubic":r==="QUADRATIC"||r==="SMOOTH_QUADRATIC"?"quad":null}function Ms(n,e,t,r,i,s){let o=(t??s??(n.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(o==="LINEAR"||o==="HORIZONTAL"||o==="VERTICAL")return(o==="HORIZONTAL"||o==="LINEAR")&&It(n.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&It(n.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=n.handleOut??{x:(n.x+e.x)/2,y:(n.y+e.y)/2};return r==="quad"&&i&&It(c.x,2*n.x-i.x)&&It(c.y,2*n.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let a=n.handleOut??{x:n.x,y:n.y},l=e.handleIn??{x:e.x,y:e.y};return r==="cubic"&&n.handleIn&&n.handleOut&&It(n.handleOut.x,2*n.x-n.handleIn.x)&&It(n.handleOut.y,2*n.y-n.handleIn.y)?` S ${l.x} ${l.y} ${e.x} ${e.y}`:` C ${a.x} ${a.y} ${l.x} ${l.y} ${e.x} ${e.y}`}function ld(n,e,t){if(n.length<2)return n.length===1?`M ${n[0].x} ${n[0].y}`:"";let r=t,i=e?[n[n.length-1],...n,n[0],n[1]]:[n[0],...n,n[n.length-1]],s=`M ${n[0].x} ${n[0].y}`,o=e?n.length:n.length-1;for(let a=0;a<o;a++){let l=i[a],c=i[a+1],f=i[a+2],d=i[a+3],p=Math.hypot(f.x-c.x,f.y-c.y),m=Math.hypot(c.x-l.x,c.y-l.y),h=Math.hypot(d.x-f.x,d.y-f.y),g=Math.pow(m,r),b=Math.pow(p,r),$=Math.pow(h,r),k=Math.pow(m,2*r),S=Math.pow(p,2*r),x=Math.pow(h,2*r),v,w,T,P;m<1e-8?(v=c.x,w=c.y):(v=(k*f.x-S*l.x+(2*k+3*g*b+S)*c.x)/(3*g*(g+b)),w=(k*f.y-S*l.y+(2*k+3*g*b+S)*c.y)/(3*g*(g+b))),h<1e-8?(T=f.x,P=f.y):(T=(x*c.x-S*d.x+(2*x+3*$*b+S)*f.x)/(3*$*($+b)),P=(x*c.y-S*d.y+(2*x+3*$*b+S)*f.y)/(3*$*($+b))),s+=` C ${v} ${w} ${T} ${P} ${f.x} ${f.y}`}return e&&(s+=" Z"),s}function ud(n,e){let t=n.length;if(t<2)return t===1?`M ${n[0].x} ${n[0].y}`:"";if(t===2)return`M ${n[0].x} ${n[0].y} L ${n[1].x} ${n[1].y}`;if(e){let s=(n[0].x+4*n[1].x+n[2].x)/6,o=(n[0].y+4*n[1].y+n[2].y)/6,a=`M ${s} ${o}`;for(let l=0;l<t;l++){let c=n[(l+1)%t],f=n[(l+2)%t],d=n[(l+3)%t];a+=Cs(c,f,d)}return a+=" Z",a}let r=n,i=`M ${r[0].x} ${r[0].y}`;i+=` L ${(5*r[0].x+r[1].x)/6} ${(5*r[0].y+r[1].y)/6}`;for(let s=0;s<=t-3;s++)i+=Cs(r[s],r[s+1],r[s+2]);return i+=Cs(r[t-2],r[t-1],r[t-1]),i+=` L ${r[t-1].x} ${r[t-1].y}`,i}function Cs(n,e,t){return` C ${(2*n.x+e.x)/3} ${(2*n.y+e.y)/3} ${(n.x+2*e.x)/3} ${(n.y+2*e.y)/3} ${(n.x+4*e.x+t.x)/6} ${(n.y+4*e.y+t.y)/6}`}function Mt(n,e,t){let r=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(t)?Math.max(1,t):4;switch(n){case"dashed":case"dotted":case"custom":return`${r} ${i}`;default:return null}}var cd=[["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 Y(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function dd(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":n.linearGradient?"linear-gradient":n.radialGradient?"radial-gradient":"solid")}function Mr(n){let e=new Map,t=n.state,r=t;switch(n.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 x=t.rx??t.cornerRadius??0,v=t.ry??t.cornerRadius??0;(x>0||v>0)&&(e.set("rx",String(x)),e.set("ry",String(v)))}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",String(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 x=cd.map(([v,w])=>{let T=typeof t[v]=="string"?String(t[v]).trim():"";return T?`${w}: ${T}`:""}).filter(Boolean).join("; ");x&&e.set("style",x)}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)),r.href&&e.set("href",String(r.href));break}let i=dd(r);i==="none"?e.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?e.set("fill",`url(#gradient-fill-${n.id})`):i==="pattern"?e.set("fill",`url(#pattern-fill-${n.id})`):e.set("fill",t.fillColor??"#000000");let s=t.opacity;s!==void 0&&s<1&&e.set("opacity",String(s));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 a=r.strokeType??"solid";if(a==="none")e.set("stroke","none");else if(a==="linear-gradient"||a==="radial-gradient")e.set("stroke",`url(#gradient-stroke-${n.id})`);else{let x=t.borderColor??"none";x!=="none"&&e.set("stroke",x)}let l=t.borderWidth;l!=null&&l!==0&&e.set("stroke-width",String(l));let c=t.strokeOpacity;c!==void 0&&c<1&&e.set("stroke-opacity",String(c));let f=t.lineStyle??"solid",d=t.dashLength??8,p=t.gapLength??4,m=Mt(f,d,p);m&&(e.set("stroke-dasharray",m),f==="dotted"&&e.set("stroke-linecap","round"));let h=fd(r);h&&e.set("transform",h);let g=r.filters;g&&g.length>0&&e.set("filter",`url(#filter-${n.id})`);let b=t.shapeRendering;b&&b!=="auto"&&e.set("shape-rendering",b),t.pathLength!==void 0&&e.set("pathLength",String(t.pathLength));let $=r.startEndpoint,k=r.endEndpoint;$&&$!=="none"&&e.set("marker-start",`url(#line-marker-${$})`),k&&k!=="none"&&e.set("marker-end",`url(#line-marker-${k})`);let S=r.metadata;return S&&(S.role&&e.set("role",S.role),S.ariaLabel&&e.set("aria-label",S.ariaLabel)),e}function ol(n){switch(n.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 fd(n){return At(n)}function Fe(n,e){let t=n.viewboxes?.[0];return{width:e.width??t?.width??800,height:e.height??t?.height??600}}function u(n,e){return e==null||e===""?"":` ${n}="${Y(String(e))}"`}function Dr(n){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);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 pd(n,e,t){let{offsetX:r,offsetY:i,blurRadius:s,spread:o,color:a,opacity:l}=n,c="";if(o===0)c+=`<feDropShadow${u("in",e)}${u("dx",r)}${u("dy",i)}${u("stdDeviation",s/2)}${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_shadow`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_shadow`)}/><feMergeNode${u("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`;let f=o>0?"dilate":"erode",d=Math.abs(o);c+=`<feMorphology${u("in",`${t}_alpha`)}${u("operator",f)}${u("radius",d)}${u("result",`${t}_spread`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_spread`)}${u("stdDeviation",s/2)}${u("result",`${t}_blur`)}/>`,c+=`<feOffset${u("in",`${t}_blur`)}${u("dx",r)}${u("dy",i)}${u("result",`${t}_offset`)}/>`,c+=`<feFlood${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_color`)}/>`,c+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_offset`)}${u("operator","in")}${u("result",`${t}_shadow`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_shadow`)}/><feMergeNode${u("in",e)}/></feMerge>`}return c}function md(n,e,t){let{offsetX:r,offsetY:i,blurRadius:s,choke:o,color:a,opacity:l}=n,c=s*(1-o/100),f="";return f+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,f+=`<feComponentTransfer${u("in",`${t}_alpha`)}${u("result",`${t}_inverted`)}><feFuncA${u("type","table")}${u("tableValues","1 0")}/></feComponentTransfer>`,f+=`<feGaussianBlur${u("in",`${t}_inverted`)}${u("stdDeviation",c/2)}${u("result",`${t}_blur`)}/>`,f+=`<feOffset${u("in",`${t}_blur`)}${u("dx",r)}${u("dy",i)}${u("result",`${t}_offset`)}/>`,f+=`<feFlood${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_color`)}/>`,f+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_offset`)}${u("operator","in")}${u("result",`${t}_coloredShadow`)}/>`,f+=`<feComposite${u("in",`${t}_coloredShadow`)}${u("in2",`${t}_alpha`)}${u("operator","in")}${u("result",`${t}_innerShadow`)}/>`,f+=`<feComposite${u("in",`${t}_innerShadow`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`,f}function hd(n,e,t){let{blurX:r,blurY:i}=n;return r===0&&i===0?H(e,t):`<feGaussianBlur${u("in",e)}${u("stdDeviation",`${r/2} ${i/2}`)}${u("result",t)}/>`}function gd(n,e,t){let{distance:r,angle:i}=n;if(r===0)return H(e,t);let s=i*Math.PI/180,o=Math.abs(Math.cos(s)*r),a=Math.abs(Math.sin(s)*r);return`<feGaussianBlur${u("in",e)}${u("stdDeviation",`${o/2} ${a/2}`)}${u("result",t)}/>`}function ll(n,e,t){let{x:r,y:i,z:s,color:o,surfaceScale:a,diffuseConstant:l,specularConstant:c,specularExponent:f}=n,d="";return d+=`<feDiffuseLighting${u("in","SourceAlpha")}${u("surfaceScale",a)}${u("diffuseConstant",l)}${u("lighting-color",o)}${u("result",`${t}_diffuse`)}>`,d+=`<fePointLight${u("x",r)}${u("y",i)}${u("z",s)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${u("in","SourceAlpha")}${u("surfaceScale",a)}${u("specularConstant",c)}${u("specularExponent",f)}${u("lighting-color",o)}${u("result",`${t}_specular`)}>`,d+=`<fePointLight${u("x",r)}${u("y",i)}${u("z",s)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${u("in",e)}${u("in2",`${t}_diffuse`)}${u("operator","arithmetic")}${u("k1",1)}${u("k2",0)}${u("k3",0)}${u("k4",0)}${u("result",`${t}_lit`)}/>`,d+=`<feComposite${u("in",`${t}_specular`)}${u("in2",`${t}_lit`)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",1)}${u("k3",1)}${u("k4",0)}${u("result",t)}/>`,d}function ul(n,e,t){let{x:r,y:i,z:s,pointsAtX:o,pointsAtY:a,pointsAtZ:l,coneAngle:c,color:f,surfaceScale:d,specularConstant:p,specularExponent:m}=n,h="";return h+=`<feSpecularLighting${u("in","SourceAlpha")}${u("surfaceScale",d)}${u("specularConstant",p)}${u("specularExponent",m)}${u("lighting-color",f)}${u("result",`${t}_specular`)}>`,h+=`<feSpotLight${u("x",r)}${u("y",i)}${u("z",s)}${u("pointsAtX",o)}${u("pointsAtY",a)}${u("pointsAtZ",l)}${u("limitingConeAngle",c)}/>`,h+="</feSpecularLighting>",h+=`<feComposite${u("in",`${t}_specular`)}${u("in2","SourceAlpha")}${u("operator","in")}${u("result",`${t}_clipped`)}/>`,h+=`<feComposite${u("in",`${t}_clipped`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",1)}${u("k3",1)}${u("k4",0)}${u("result",t)}/>`,h}function cl(n){switch(n.kind){case"point":return`<fePointLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}/>`;case"spot":{let e=`<feSpotLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}${u("pointsAtX",n.pointsAtX)}${u("pointsAtY",n.pointsAtY)}${u("pointsAtZ",n.pointsAtZ)}`;return n.limitingConeAngle!==void 0&&(e+=u("limitingConeAngle",n.limitingConeAngle)),n.specularExponent!==void 0&&(e+=u("specularExponent",n.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${u("azimuth",n.azimuth)}${u("elevation",n.elevation)}/>`}}function yd(n,e,t){return`<feDiffuseLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("diffuseConstant",n.diffuseConstant)}${u("lighting-color",n.color)}${u("result",t)}>`+cl(n.lightSource)+"</feDiffuseLighting>"}function bd(n,e,t){return`<feSpecularLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("specularConstant",n.specularConstant)}${u("specularExponent",n.specularExponent)}${u("lighting-color",n.color)}${u("result",t)}>`+cl(n.lightSource)+"</feSpecularLighting>"}function Sd(n,e,t){let{width:r,color:i,opacity:s,position:o}=n,a="";if(o==="inside")a+=`<feMorphology${u("in","SourceAlpha")}${u("operator","erode")}${u("radius",r)}${u("result",`${t}_eroded`)}/>`,a+=`<feComposite${u("in","SourceAlpha")}${u("in2",`${t}_eroded`)}${u("operator","out")}${u("result",`${t}_outlineAlpha`)}/>`,a+=`<feFlood${u("flood-color",i)}${u("flood-opacity",s)}${u("result",`${t}_color`)}/>`,a+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_outlineAlpha`)}${u("operator","in")}${u("result",`${t}_outline`)}/>`,a+=`<feComposite${u("in",`${t}_outline`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`;else{let l=o==="outside"?r:r/2;a+=`<feMorphology${u("in","SourceAlpha")}${u("operator","dilate")}${u("radius",l)}${u("result",`${t}_dilated`)}/>`,a+=`<feComposite${u("in",`${t}_dilated`)}${u("in2","SourceAlpha")}${u("operator","out")}${u("result",`${t}_outlineAlpha`)}/>`,a+=`<feFlood${u("flood-color",i)}${u("flood-opacity",s)}${u("result",`${t}_color`)}/>`,a+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_outlineAlpha`)}${u("operator","in")}${u("result",`${t}_outline`)}/>`,a+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_outline`)}/><feMergeNode${u("in",e)}/></feMerge>`}return a}function xd(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=1+4*r,s=-r,o=[0,s,0,s,i,s,0,s,0].join(" ");return`<feConvolveMatrix${u("in",e)}${u("order","3")}${u("kernelMatrix",o)}${u("divisor","1")}${u("bias","0")}${u("preserveAlpha","true")}${u("edgeMode","duplicate")}${u("result",t)}/>`}function $d(n,e,t){let{blockSize:r}=n;if(r<=1)return H(e,t);let i=r/2,s="";return s+=`<feMorphology${u("in",e)}${u("operator","erode")}${u("radius",i)}${u("result",`${t}_eroded`)}/>`,s+=`<feMorphology${u("in",`${t}_eroded`)}${u("operator","dilate")}${u("radius",i)}${u("result",t)}/>`,s}function vd(n,e,t){let{scale:r,frequency:i,octaves:s,warpType:o}=n;if(r===0)return H(e,t);let a="";return a+=`<feTurbulence${u("type",o)}${u("baseFrequency",i)}${u("numOctaves",s)}${u("seed",0)}${u("result",`${t}_turbulence`)}/>`,a+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_turbulence`)}${u("scale",r)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",t)}/>`,a}function kd(n,e,t){let{operator:r,radiusX:i,radiusY:s}=n;return i===0&&s===0?H(e,t):`<feMorphology${u("in",e)}${u("operator",r)}${u("radius",`${i} ${s}`)}${u("result",t)}/>`}function Td(n,e,t){let{levels:r}=n;if(r<2)return H(e,t);let i=[];for(let a=0;a<r;a++)i.push(a/(r-1));let s=i.join(" "),o=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return o+=`<feFuncR${u("type","discrete")}${u("tableValues",s)}/>`,o+=`<feFuncG${u("type","discrete")}${u("tableValues",s)}/>`,o+=`<feFuncB${u("type","discrete")}${u("tableValues",s)}/>`,o+="</feComponentTransfer>",o}function wd(n,e,t){let{levels:r,contrast:i}=n;if(r<2)return H(e,t);let s=[];for(let l=0;l<r;l++){let c=l/(r-1),f=c;i!==1&&(f=.5+(c-.5)*i,f=Math.max(0,Math.min(1,f))),s.push(f)}let o=s.join(" "),a=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return a+=`<feFuncR${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function Pd(n,e,t){let{radius:r}=n;if(r===0)return H(e,t);let i="";return i+=`<feGaussianBlur${u("in","SourceAlpha")}${u("stdDeviation",r)}${u("result",`${t}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${u("in",`${t}_blurredAlpha`)}${u("result",`${t}_thresholdAlpha`)}><feFuncA${u("type","linear")}${u("slope",20)}${u("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${u("in",e)}${u("in2",`${t}_thresholdAlpha`)}${u("operator","in")}${u("result",t)}/>`,i}function _d(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=1-r;return`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","saturate")}${u("values",i)}${u("result",t)}/>`}function Rd(n,e,t){let{red:r,green:i,blue:s}=n;if(r===1&&i===1&&s===1)return H(e,t);let o=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return o+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,o+=`<feFuncG${u("type","linear")}${u("slope",i)}${u("intercept",0)}/>`,o+=`<feFuncB${u("type","linear")}${u("slope",s)}${u("intercept",0)}/>`,o+="</feComponentTransfer>",o}function Ad(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return i+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+=`<feFuncG${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+=`<feFuncB${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+="</feComponentTransfer>",i}function Id(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=.5*(1-r),s=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return s+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+=`<feFuncG${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+=`<feFuncB${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+="</feComponentTransfer>",s}function Md(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return i+=`<feFuncA${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+="</feComponentTransfer>",i}function Cd(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=r,s=1-r,o=`${i} ${s}`,a=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return a+=`<feFuncR${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function Dd(n,e,t){let{angle:r}=n;return r===0||r===360?H(e,t):`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","hueRotate")}${u("values",r)}${u("result",t)}/>`}function Fd(n,e,t){let{amount:r}=n;return r===1?H(e,t):`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","saturate")}${u("values",r)}${u("result",t)}/>`}function Ed(n,e,t){let{threshold:r}=n,i="";if(i+=`<feColorMatrix${u("in",e)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`,r===.5)i+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,i+=`<feFuncR${u("type","discrete")}${u("tableValues","0 1")}/>`,i+=`<feFuncG${u("type","discrete")}${u("tableValues","0 1")}/>`,i+=`<feFuncB${u("type","discrete")}${u("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let o=[];for(let l=0;l<256;l++)o.push(l/255<r?0:1);let a=o.join(" ");i+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,i+=`<feFuncR${u("type","table")}${u("tableValues",a)}/>`,i+=`<feFuncG${u("type","table")}${u("tableValues",a)}/>`,i+=`<feFuncB${u("type","table")}${u("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function Od(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=[.393,.769,.189,0,0],s=[.349,.686,.168,0,0],o=[.272,.534,.131,0,0],a=[1,0,0,0,0],l=[0,1,0,0,0],c=[0,0,1,0,0],f=(g,b)=>g.map(($,k)=>$*(1-r)+b[k]*r),d=f(a,i),p=f(l,s),m=f(c,o),h=[...d,...p,...m,0,0,0,1,0].join(" ");return`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","matrix")}${u("values",h)}${u("result",t)}/>`}function Ld(n,e,t){let{shadowColor:r,highlightColor:i}=n,s=Dr(r),o=Dr(i),a="";return a+=`<feColorMatrix${u("in",e)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`,a+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,a+=`<feFuncR${u("type","table")}${u("tableValues",`${s.r} ${o.r}`)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",`${s.g} ${o.g}`)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",`${s.b} ${o.b}`)}/>`,a+="</feComponentTransfer>",a}function Nd(n,e,t){let{intensity:r}=n;if(r===0)return H(e,t);let i="";i+=`<feComponentTransfer${u("in",e)}${u("result",`${t}_invert`)}>`,i+=`<feFuncR${u("type","table")}${u("tableValues","1 0")}/>`,i+=`<feFuncG${u("type","table")}${u("tableValues","1 0")}/>`,i+=`<feFuncB${u("type","table")}${u("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${u("in",`${t}_invert`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`;let s=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],l=[1,0,0,0,0],c=[0,1,0,0,0],f=[0,0,1,0,0],d=(b,$)=>b.map((k,S)=>k*(1-r)+$[S]*r),p=d(l,s),m=d(c,o),h=d(f,a),g=[...p,...m,...h,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${u("in",`${t}_gray`)}${u("type","matrix")}${u("values",g)}${u("result",t)}/>`,i}function Bd(n,e,t){let{amount:r,scale:i}=n;if(r===0)return H(e,t);let s=1/i,o="";return o+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",s)}${u("numOctaves",3)}${u("seed",0)}${u("result",`${t}_noise`)}/>`,o+=`<feColorMatrix${u("in",`${t}_noise`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_noiseGray`)}/>`,o+=`<feBlend${u("in",e)}${u("in2",`${t}_noiseGray`)}${u("mode","overlay")}${u("result",`${t}_blended`)}/>`,o+=`<feComposite${u("in",`${t}_blended`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",r)}${u("k3",1-r)}${u("k4",0)}${u("result",`${t}_amt`)}/>`,o+=`<feComposite${u("in",`${t}_amt`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,o}function zd(n,e,t){let{strength:r,angle:i}=n;if(r===0)return H(e,t);let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=r,c=[-(l*(o+a)),-(l*a),l*(-o+a),-(l*o),1,l*o,l*(o-a),l*a,l*(o+a)].join(" ");return`<feConvolveMatrix${u("in",e)}${u("order","3 3")}${u("kernelMatrix",c)}${u("divisor",1)}${u("bias",.5)}${u("preserveAlpha","true")}${u("result",t)}/>`}function Gd(n,e,t){let{amount:r,size:i}=n;if(r===0)return H(e,t);let s=.5/i,o="";return o+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",`${s} ${s}`)}${u("numOctaves",5)}${u("seed",0)}${u("stitchTiles","stitch")}${u("result",`${t}_grain`)}/>`,o+=`<feColorMatrix${u("in",`${t}_grain`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_grainGray`)}/>`,o+=`<feBlend${u("in",e)}${u("in2",`${t}_grainGray`)}${u("mode","soft-light")}${u("result",`${t}_blended`)}/>`,o+=`<feComposite${u("in",`${t}_blended`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",r)}${u("k3",1-r)}${u("k4",0)}${u("result",`${t}_amt`)}/>`,o+=`<feComposite${u("in",`${t}_amt`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,o}function Vd(n,e,t){let{wetness:r,turbulence:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",.02+i*.03)}${u("numOctaves",4)}${u("seed",42)}${u("result",`${t}_turb`)}/>`,s+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_turb`)}${u("scale",r*15)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feGaussianBlur${u("in",`${t}_disp`)}${u("stdDeviation",r*2)}${u("result",`${t}_blur`)}/>`,s+=`<feBlend${u("in",`${t}_blur`)}${u("in2",e)}${u("mode","multiply")}${u("result",t)}/>`,s}function Ud(n,e,t){let{thickness:r,texture:i}=n;if(r===0&&i===0)return H(e,t);let s="";s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.03+i*.02)}${u("numOctaves",3)}${u("seed",1e3)}${u("result",`${t}_brush`)}/>`;let o=Math.max(3,8-Math.floor(r*5)),a=Array.from({length:o+1},(l,c)=>c/o).join(" ");s+=`<feComponentTransfer${u("in",e)}${u("result",`${t}_poster`)}>`;for(let l of["R","G","B"])s+=`<feFunc${l}${u("type","discrete")}${u("tableValues",a)}/>`;return s+="</feComponentTransfer>",s+=`<feDisplacementMap${u("in",`${t}_poster`)}${u("in2",`${t}_brush`)}${u("scale",i*4)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feMorphology${u("in",`${t}_disp`)}${u("operator","dilate")}${u("radius",r*.5)}${u("result",`${t}_thick`)}/>`,s+=`<feComposite${u("in",`${t}_thick`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,s}function Wd(n,e,t){let{spread:r,edges:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",.01+i*.02)}${u("numOctaves",5)}${u("seed",1100)}${u("result",`${t}_ink`)}/>`,s+=`<feMorphology${u("in",e)}${u("operator","dilate")}${u("radius",r*3)}${u("result",`${t}_dilate`)}/>`,s+=`<feDisplacementMap${u("in",`${t}_dilate`)}${u("in2",`${t}_ink`)}${u("scale",i*10)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feGaussianBlur${u("in",`${t}_disp`)}${u("stdDeviation",r*.5)}${u("result",t)}/>`,s}function Hd(n,e,t){let{wrinkles:r,shine:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.02)}${u("numOctaves",4)}${u("seed",1200)}${u("result",`${t}_wrinkle`)}/>`,s+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_wrinkle`)}${u("scale",r*15)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feSpecularLighting${u("in",`${t}_wrinkle`)}${u("surfaceScale",r*2)}${u("specularConstant",i*1.5)}${u("specularExponent",20)}${u("result",`${t}_sheen`)}>`,s+=`<feDistantLight${u("azimuth",45)}${u("elevation",60)}/>`,s+="</feSpecularLighting>",s+=`<feBlend${u("in",`${t}_disp`)}${u("in2",`${t}_sheen`)}${u("mode","screen")}${u("result",`${t}_blend`)}/>`,s+=`<feComposite${u("in",`${t}_blend`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,s}function jd(n,e,t){let{density:r,size:i}=n;if(r===0)return H(e,t);let s="",o=1-r;s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.1/i)}${u("numOctaves",1)}${u("seed",1400)}${u("result",`${t}_hole`)}/>`,s+=`<feComponentTransfer${u("in",`${t}_hole`)}${u("result",`${t}_thresh`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${u("type","linear")}${u("slope",10)}${u("intercept",-o*10+5)}/>`;s+="</feComponentTransfer>",s+=`<feComponentTransfer${u("in",`${t}_thresh`)}${u("result",`${t}_clamp`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${u("type","table")}${u("tableValues","0 0 1 1")}/>`;return s+="</feComponentTransfer>",s+=`<feComposite${u("in",e)}${u("in2",`${t}_clamp`)}${u("operator","in")}${u("result",t)}/>`,s}function Kd(n,e,t){let{color:r,radius:i,intensity:s}=n;if(s===0||i===0)return H(e,t);let{r:o,g:a,b:l}=Dr(r),c="";return c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_alpha`)}${u("stdDeviation",i/2)}${u("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${u("in",`${t}_blur`)}${u("type","matrix")}${u("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${s} 0`)}${u("result",`${t}_color`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_color`)}/><feMergeNode${u("in",e)}/></feMerge>`,c}function Xd(n,e,t){let{color:r,radius:i,intensity:s}=n;if(s===0||i===0)return H(e,t);let{r:o,g:a,b:l}=Dr(r),c="";return c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,c+=`<feMorphology${u("in",`${t}_alpha`)}${u("operator","erode")}${u("radius",i/4)}${u("result",`${t}_erode`)}/>`,c+=`<feComposite${u("in",`${t}_alpha`)}${u("in2",`${t}_erode`)}${u("operator","out")}${u("result",`${t}_edge`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_edge`)}${u("stdDeviation",i/3)}${u("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${u("in",`${t}_blur`)}${u("type","matrix")}${u("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${s*2} 0`)}${u("result",`${t}_color`)}/>`,c+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_alpha`)}${u("operator","in")}${u("result",`${t}_clipped`)}/>`,c+=`<feComposite${u("in",`${t}_clipped`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`,c}function H(n,e){return`<feMerge${u("result",e)}><feMergeNode${u("in",n)}/></feMerge>`}function Fr(n){switch(n.type){case"feBlend":return Yd(n);case"feColorMatrix":return qd(n);case"feComponentTransfer":return Zd(n);case"feComposite":return Jd(n);case"feConvolveMatrix":return Qd(n);case"feDiffuseLighting":return ef(n);case"feSpecularLighting":return tf(n);case"feDisplacementMap":return nf(n);case"feDropShadow":return rf(n);case"feFlood":return sf(n);case"feGaussianBlur":return af(n);case"feImage":return of(n);case"feMerge":return lf(n);case"feMorphology":return uf(n);case"feOffset":return cf(n);case"feTile":return df(n);case"feTurbulence":return ff(n)}}function ue(n){let e="";if(e+=u("in",n.in),e+=u("x",n.x),e+=u("y",n.y),e+=u("width",n.width),e+=u("height",n.height),e+=u("color-interpolation-filters",n.colorInterpolationFilters),e+=u("result",n.result),n.unknownAttrs){let t=Object.keys(n.unknownAttrs).sort();for(let r of t)e+=u(r,n.unknownAttrs[r])}return e}function ce(n){return n.animations&&n.animations.length>0?n.animations.join(""):""}function Yd(n){let e=`<feBlend${ue(n)}${u("in2",n.in2)}${u("mode",n.mode)}`;n.noComposite&&(e+=' no-composite="no-composite"');let t=ce(n);return t?`${e}>${t}</feBlend>`:`${e}/>`}function qd(n){let e=`<feColorMatrix${ue(n)}${u("type",n.matrixType)}${u("values",n.values)}`,t=ce(n);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function Cr(n,e){if(!e)return"";let t=`feFunc${n}`;switch(e.type){case"identity":return`<${t} type="identity"/>`;case"table":case"discrete":return`<${t} type="${e.type}"${u("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${t} type="linear"${u("slope",e.slope)}${u("intercept",e.intercept)}/>`;case"gamma":return`<${t} type="gamma"${u("amplitude",e.amplitude)}${u("exponent",e.exponent)}${u("offset",e.offset)}/>`}}function Zd(n){let e="";return e+=Cr("R",n.funcR),e+=Cr("G",n.funcG),e+=Cr("B",n.funcB),e+=Cr("A",n.funcA),e+=ce(n),`<feComponentTransfer${ue(n)}>${e}</feComponentTransfer>`}function Jd(n){let e=`<feComposite${ue(n)}${u("in2",n.in2)}${u("operator",n.operator)}`;n.operator==="arithmetic"&&(e+=u("k1",n.k1),e+=u("k2",n.k2),e+=u("k3",n.k3),e+=u("k4",n.k4));let t=ce(n);return t?`${e}>${t}</feComposite>`:`${e}/>`}function Qd(n){let e=`<feConvolveMatrix${ue(n)}`;e+=u("order",n.order),e+=u("kernelMatrix",n.kernelMatrix),e+=u("divisor",n.divisor),e+=u("bias",n.bias),e+=u("targetX",n.targetX),e+=u("targetY",n.targetY),e+=u("edgeMode",n.edgeMode),e+=u("kernelUnitLength",n.kernelUnitLength),n.preserveAlpha!==void 0&&(e+=u("preserveAlpha",n.preserveAlpha?"true":"false"));let t=ce(n);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function dl(n){switch(n.kind){case"feDistantLight":return`<feDistantLight${u("azimuth",n.azimuth)}${u("elevation",n.elevation)}/>`;case"fePointLight":return`<fePointLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}${u("pointsAtX",n.pointsAtX)}${u("pointsAtY",n.pointsAtY)}${u("pointsAtZ",n.pointsAtZ)}`;return e+=u("specularExponent",n.specularExponent),e+=u("limitingConeAngle",n.limitingConeAngle),e+"/>"}}}function ef(n){let e=`<feDiffuseLighting${ue(n)}`;e+=u("surfaceScale",n.surfaceScale),e+=u("diffuseConstant",n.diffuseConstant),e+=u("kernelUnitLength",n.kernelUnitLength),e+=u("lighting-color",n.lightingColor);let t="";return n.lightSource&&(t+=dl(n.lightSource)),t+=ce(n),`${e}>${t}</feDiffuseLighting>`}function tf(n){let e=`<feSpecularLighting${ue(n)}`;e+=u("surfaceScale",n.surfaceScale),e+=u("specularConstant",n.specularConstant),e+=u("specularExponent",n.specularExponent),e+=u("kernelUnitLength",n.kernelUnitLength),e+=u("lighting-color",n.lightingColor);let t="";return n.lightSource&&(t+=dl(n.lightSource)),t+=ce(n),`${e}>${t}</feSpecularLighting>`}function nf(n){let e=`<feDisplacementMap${ue(n)}`;e+=u("in2",n.in2),e+=u("scale",n.scale),e+=u("xChannelSelector",n.xChannelSelector),e+=u("yChannelSelector",n.yChannelSelector);let t=ce(n);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function rf(n){let e=`<feDropShadow${ue(n)}`;e+=u("dx",n.dx),e+=u("dy",n.dy),e+=u("stdDeviation",n.stdDeviation),e+=u("flood-color",n.floodColor),e+=u("flood-opacity",n.floodOpacity);let t=ce(n);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function sf(n){let e=`<feFlood${ue(n)}${u("flood-color",n.floodColor)}${u("flood-opacity",n.floodOpacity)}`,t=ce(n);return t?`${e}>${t}</feFlood>`:`${e}/>`}function af(n){let e=`<feGaussianBlur${ue(n)}${u("stdDeviation",n.stdDeviation)}${u("edgeMode",n.edgeMode)}`,t=ce(n);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function of(n){let e=`<feImage${ue(n)}`;n.href!==void 0?e+=u("href",n.href):n.xlinkHref!==void 0&&(e+=u("xlink:href",n.xlinkHref)),e+=u("preserveAspectRatio",n.preserveAspectRatio),e+=u("crossorigin",n.crossorigin);let t=ce(n);return t?`${e}>${t}</feImage>`:`${e}/>`}function lf(n){let e="";for(let t of n.nodes)e+=`<feMergeNode${u("in",t.in)}/>`;return e+=ce(n),`<feMerge${ue(n)}>${e}</feMerge>`}function uf(n){let e=`<feMorphology${ue(n)}${u("operator",n.operator)}${u("radius",n.radius)}`,t=ce(n);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function cf(n){let e=`<feOffset${ue(n)}${u("dx",n.dx)}${u("dy",n.dy)}`,t=ce(n);return t?`${e}>${t}</feOffset>`:`${e}/>`}function df(n){let e=`<feTile${ue(n)}`,t=ce(n);return t?`${e}>${t}</feTile>`:`${e}/>`}function ff(n){let e=`<feTurbulence${ue(n)}`;e+=u("baseFrequency",n.baseFrequency),e+=u("numOctaves",n.numOctaves),e+=u("seed",n.seed),e+=u("stitchTiles",n.stitchTiles),e+=u("type",n.turbulenceType);let t=ce(n);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function Fs(n,e){let t=`<filter${u("id",n)}`;t+=u("x",e.x),t+=u("y",e.y),t+=u("width",e.width),t+=u("height",e.height),t+=u("filterUnits",e.filterUnits),t+=u("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(t+=u("color-interpolation-filters",e.filterColorInterpolation)),t+=u("flood-color",e.floodColor),t+=u("flood-opacity",e.floodOpacity),t+=u("lighting-color",e.lightingColor),t+=">",e.filterTitle&&(t+=`<title>${Y(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${Y(e.filterDescription)}</desc>`);for(let r of e.primitives)t+=Fr(r);if(e.filterAnimations)for(let r of e.filterAnimations)t+=r;return t+="</filter>",t}function Es(n,e,t,r){switch(n.type){case"drop-shadow":return pd(n,e,t);case"inner-shadow":return md(n,e,t);case"gaussian-blur":return hd(n,e,t);case"motion-blur":return gd(n,e,t);case"point-light":{let i=n;return ll(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,t)}case"spot-light":{let i=n;return ul(r?{...i,x:i.x+r.x,y:i.y+r.y,pointsAtX:i.pointsAtX+r.x,pointsAtY:i.pointsAtY+r.y}:i,e,t)}case"diffuse-lighting":return yd(n,e,t);case"specular-lighting":return bd(n,e,t);case"outline":return Sd(n,e,t);case"sharpen":return xd(n,e,t);case"pixelate":return $d(n,e,t);case"warp":return vd(n,e,t);case"morphology":return kd(n,e,t);case"contouring-discrete":return Td(n,e,t);case"contouring-table":return wd(n,e,t);case"round-edges":return Pd(n,e,t);case"grayscale":return _d(n,e,t);case"channel-painter":return Rd(n,e,t);case"brightness":return Ad(n,e,t);case"contrast":return Id(n,e,t);case"opacity":return Md(n,e,t);case"invert":return Cd(n,e,t);case"hue-rotate":return Dd(n,e,t);case"saturate":return Fd(n,e,t);case"black-and-white":return Ed(n,e,t);case"sepia":return Od(n,e,t);case"duotone":return Ld(n,e,t);case"xray":return Nd(n,e,t);case"noise":return Bd(n,e,t);case"emboss":return zd(n,e,t);case"film-grain":return Gd(n,e,t);case"watercolor":return Vd(n,e,t);case"gouache":return Ud(n,e,t);case"ink-blot":return Wd(n,e,t);case"crumpled-plastic":return Hd(n,e,t);case"riddled":return jd(n,e,t);case"glow":return Kd(n,e,t);case"inner-glow":return Xd(n,e,t);case"raw-svg":return n.svgContent;case"svg-primitive-chain":return n.primitives.map(Fr).join("");default:return H(e,t)}}function pf(n){return n.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 Os(n,e,t={}){let r=e.filter(x=>x.enabled);if(r.length===0)return"";let i=t.colorInterpolation&&t.colorInterpolation!=="auto"?u("color-interpolation-filters",t.colorInterpolation):"",s=r.find(x=>x.type==="raw-svg");if(s){let x=t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:s.colorInterpolationFilters,v=t.filterUnits??s.filterUnits,w=t.primitiveUnits??s.primitiveUnits,T=t.x??s.x,P=t.y??s.y,R=t.width??s.width,M=t.height??s.height;return`<filter${u("id",n)}${u("x",T)}${u("y",P)}${u("width",R)}${u("height",M)}${u("filterUnits",v)}${u("primitiveUnits",w)}${u("color-interpolation-filters",x)}${u("flood-color",s.floodColor)}${u("flood-opacity",s.floodOpacity)}${u("lighting-color",s.lightingColor)}${u("display",s.display)}>${s.svgContent}</filter>`}let o=r.find(x=>x.type==="svg-primitive-chain");if(o){let x={...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 Fs(n,x)}let a=r.some(x=>x.type==="gaussian-blur"&&x.quality==="high"||x.type==="motion-blur"&&x.quality==="high"),l=pf(r),c=l?a?"-200%":"-100%":"-10%",f=l?a?"500%":"300%":"120%",d="",p="SourceGraphic",m=0;for(let x of r){let v=`result${m++}`;d+=Es(x,p,v),p=v}let h=t.filterUnits??"objectBoundingBox",g=t.primitiveUnits??"userSpaceOnUse",b=t.x??c,$=t.y??c,k=t.width??f,S=t.height??f;return`<filter${u("id",n)}${u("x",b)}${u("y",$)}${u("width",k)}${u("height",S)}${u("filterUnits",h)}${u("primitiveUnits",g)}${i}>${d}</filter>`}function fl(n){let e="",t=new Set;for(let r of n){let i=r.state.filters;if(!i||i.length===0)continue;let s=i.filter(c=>c.enabled);if(s.length===0)continue;let o=r.state.filterLibraryIds,a=Array.isArray(o)&&o.length>0?o[0]:`filter-${r.id}`;if(t.has(a))continue;t.add(a);let l=r.state;e+=Os(a,s,{colorInterpolation:l.filterColorInterpolation,filterUnits:l.filterUnits,primitiveUnits:l.primitiveUnits,x:l.filterX,y:l.filterY,width:l.filterWidth,height:l.filterHeight})}return e}function Er(n,e,t){return!e||e.length===0||e.filter(i=>i.enabled).length===0?"":Array.isArray(t)&&t.length>0?` filter="${t.map(s=>`url(#${Y(s)})`).join(" ")}"`:` filter="url(#filter-${Y(n)})"`}function mf(n){if(n instanceof Map)return n;let e=new Map;for(let t of n)e.set(t.id,t);return e}function hf(n){if(n.kind==="marker")return n.shapes;if(n.kind!=="symbol")return[];if(!n.variants)return n.shapes;let e=[...n.shapes];for(let t of Object.values(n.variants))e.push(...t);return e}function pl(n,e,t,r){let i=mf(t),s=new Set,o=[],a=[],l=d=>{if(typeof d!="string"||!d||s.has(d))return;let p=i.get(d);p&&(p.kind!=="symbol"&&p.kind!=="marker"||(s.add(d),o.push(p)))},c=d=>{a.push(d)},f=d=>{let p=d.state;if(!p)return;l(p.symbolId),l(p.markerStart),l(p.markerMid),l(p.markerEnd);let m=p.children;if(Array.isArray(m))for(let g of m)c(g);let h=p.symbolOverrides;if(h&&typeof h=="object"&&!Array.isArray(h))for(let[g,b]of Object.entries(h))!b||typeof b!="object"||Array.isArray(b)||c({id:g,type:"symbol-override",state:b})};for(let d of n)c(d);for(let d of e)l(d);for(;;){let d=a.shift();if(d){r(d),f(d);continue}let p=o.shift();if(!p)break;for(let m of hf(p))c(m)}}var gf=[],yf=[];function gn(n,e,t){pl(n,yf,e,t)}function ml(n,e,t){pl(gf,n,e,t)}function hl(n,e){if(!n)return;let t=n,r=t.markerStart;typeof r=="string"&&r&&e(r);let i=t.markerMid;typeof i=="string"&&i&&e(i);let s=t.markerEnd;typeof s=="string"&&s&&e(s);let o=t.startEndpoint;typeof o=="string"&&o&&o!=="none"&&e(hn(o));let a=t.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(hn(a))}function hn(n){return`line-marker-${n}`}function gl(n,e,t){if(!n)return;let r=n,i=o=>{typeof o=="string"&&o&&t(o)};i(r.fillLibraryId),i(r.strokeLibraryId),i(r.markerStart),i(r.markerMid),i(r.markerEnd),i(r.symbolId);let s=r.filterLibraryIds;if(Array.isArray(s)&&s.length>0)for(let o of s)i(o);else Array.isArray(r.filters)&&r.filters.length>0&&t(`filter-${e}`);r.fillLibraryId||i(r.fillGradient?.id),r.strokeLibraryId||i(r.strokeGradient?.id)}function yn(n,e=[]){let t=new Set,r=new Set;return gn(n,e,i=>{let s=i.state;if(!s)return;typeof s.markerStart=="string"&&s.markerStart&&t.add(s.markerStart),typeof s.markerMid=="string"&&s.markerMid&&t.add(s.markerMid),typeof s.markerEnd=="string"&&s.markerEnd&&t.add(s.markerEnd);let o=s.startEndpoint,a=s.endEndpoint;typeof o=="string"&&o&&o!=="none"&&r.add(o),typeof a=="string"&&a&&a!=="none"&&r.add(a)}),{ids:t,legacyEndpoints:r}}function yl(n,e){let{ids:t,legacyEndpoints:r}=yn(n,e);for(let i of r)t.add(hn(i));return t}function bn(n,e,t,r){let i=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/10);switch(n){case"stripes":return[{tag:"rect",attrs:{width:r?.strokeWidth!=null?Math.max(.01,Math.min(1,r.strokeWidth))*e:e/2,height:e,fill:t}}];case"dots":{let s=r?.dotRadius!=null?Math.max(.05,Math.min(.45,r.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*s,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 s=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:t,"stroke-width":s}}]}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 s=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,o=e*s;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 s=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,o=e*s,a=e/2;return[{tag:"path",attrs:{d:`M 0 ${a} Q ${e/4} ${a-o} ${e/2} ${a} T ${e} ${a}`,fill:"none",stroke:t,"stroke-width":i}}]}case"triangles":{let s=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${s} L 0 ${s} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"hexagons":{let s=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${s*.5} L ${e*.75} ${s} L ${e*.25} ${s} L 0 ${s*.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 s=r?.strokeWidth!=null?Math.max(.5,e*r.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":s}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":s}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":s}}]}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 bf(n){let e=Object.entries(n.attrs).map(([t,r])=>` ${t}="${r}"`).join("");return`<${n.tag}${e}/>`}function Or(n,e,t,r,i){let s=10*e,o="";o+=`<rect width="${s}" height="${s}" fill="${r}"/>`;let a=bn(n,s,t,i);for(let l of a)o+=bf(l);return{svgContent:o,width:s,height:s}}var Sn="0 0 10 10",Lr=6,Nr=6;function pt(){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 Ls={"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"},Sf={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function bl(){return pt().map(n=>{let e=Ls[n.id]??n.id;return{kind:"marker",id:e,name:Sf[e]??e,viewBox:Sn,refX:n.refX,refY:n.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function xf(n){return n.replace(/[^a-zA-Z0-9_-]/g,"_")}function $f(n){let e=n.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function Ct(n){let e=n.state.symbolId??"",t=n.state.variantKey??"";return $f(n)?`${e}--ovr-${n.id}`:t?`${e}--${xf(t)}`:e}function Br(n,e){let t=e.state.variantKey??"",r=t?n.variants?.[t]??n.shapes:n.shapes,i=e.state.symbolOverrides;return!i||Object.keys(i).length===0?r:r.map(s=>{let o=i[s.id];return!o||Object.keys(o).length===0?s:{...s,state:{...s.state,...o}}})}function xn(n,e){switch(e){case"uppercase":return n.toLocaleUpperCase();case"lowercase":return n.toLocaleLowerCase();case"capitalize":return n.replace(/\b\p{L}/gu,t=>t.toLocaleUpperCase());default:return n}}var vf=[["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 Dt(n){return vf.map(([e,t])=>{let r=n[e],i=typeof r=="string"?r.trim():"";return i?`${t}: ${i}`:""}).filter(Boolean).join("; ")}function zr(n,e){let t=[],r=(a,l)=>{l!==""&&t.push({name:a,value:l})};n.fontFamily!==e.fontFamily&&r("font-family",String(n.fontFamily)),n.fontSize!==e.fontSize&&r("font-size",String(n.fontSize)),n.fontWeight!==e.fontWeight&&r("font-weight",String(n.fontWeight)),n.fontStyle!==e.fontStyle&&r("font-style",String(n.fontStyle));let i=Dt(n);i&&i!==Dt(e)&&r("style",i);let s=n.textDecoration,o=e.textDecoration;if(s.underline!==o.underline||s.strikethrough!==o.strikethrough||s.overline!==o.overline){let a=[];s.underline&&a.push("underline"),s.strikethrough&&a.push("line-through"),s.overline&&a.push("overline"),r("text-decoration",a.join(" "))}if(n.baselineShift!==e.baselineShift){let a=n.baselineShift;a==="super"||a==="sub"?r("baseline-shift",a):typeof a=="number"&&r("baseline-shift",`${a}px`)}return n.letterSpacing!==e.letterSpacing&&r("letter-spacing",String(n.letterSpacing)),n.fill!==e.fill&&r("fill",String(n.fill)),n.fillOpacity!==e.fillOpacity&&r("fill-opacity",String(n.fillOpacity)),n.direction!==e.direction&&r("direction",String(n.direction)),n.unicodeBidi!==e.unicodeBidi&&r("unicode-bidi",String(n.unicodeBidi)),t}function y(n,e){return e==null||e===""?"":` ${n}="${Y(String(e))}"`}function Ft(n,e){return e==null?"":` ${n}="${Y(e)}"`}function kf(n){let e=n.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?y("style",e):""}function Tf(n,e){return typeof e=="number"&&e>0?`${n}: ${e}px`:""}function wf(n){if(n&&typeof n=="object"){let e=n;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 Sl(n,e){let t=-1;for(let i=n.length-1;i>=0;i--)if(n[i][e]!==null){t=i;break}if(t<0)return[];let r=new Array(t+1);for(let i=0;i<=t;i++)r[i]=n[i][e]??0;return r}function xl(n,e){let t=-1;for(let i=n.length-1;i>=0;i--)if(n[i][e]!==0){t=i;break}if(t<0)return[];let r=new Array(t+1);for(let i=0;i<=t;i++)r[i]=n[i][e];return r}function Pf(n){if(n.length===0)return[];let e=n.length-1,t=n[e].rotate;for(;e>0&&n[e-1].rotate===t;)e--;if(e===0&&t===0)return[];let r=new Array(e+1);for(let i=0;i<=e;i++)r[i]=n[i].rotate;return r}function Me(n,e){return At(n,e)}function _f(n,e,t){return Ts(n,e,t)}function Rf(n){if(typeof n=="string"){let r=n.trim();return r.length>0?r:void 0}if(!n||typeof n!="object")return;let e=n,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 Af(n){if(typeof n.strokeDasharray=="string")return n.strokeDasharray;let e=n.lineStyle??"solid",t=n.dashLength??8,r=n.gapLength??4;return Mt(e,t,r)}function Gr(n,e){let t=n[e];return t!==void 0?t:n.extra?.[e]}function If(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":Gr(n,"linearGradient")?"linear-gradient":Gr(n,"radialGradient")?"radial-gradient":"solid")}function Mf(n){return n.fillGradient??Gr(n,"linearGradient")??Gr(n,"radialGradient")??void 0}function Ie(n,e){let t=y("data-shape-id",e),r=If(n),i=Mf(n);if(r==="none")t+=y("fill","none");else if(r==="linear-gradient"||r==="radial-gradient"){let w=n.fillLibraryId??i?.id;t+=y("fill",`url(#${w??`gradient-fill-${e}`})`)}else if(r==="pattern"){let w=n.fillLibraryId??i?.id;t+=y("fill",`url(#${w??`pattern-fill-${e}`})`)}else t+=y("fill",n.fillColor??"#000000");let s=n.opacity;s!==void 0&&s<1&&(t+=y("opacity",s));let o=n.fillOpacity;o!==void 0&&o<1&&(t+=y("fill-opacity",o));let a=n.fillRule;a&&a!=="nonzero"&&(t+=y("fill-rule",a));let l=n.strokeType??"solid",c=n.strokeGradient;if(l==="none")t+=y("stroke","none");else if(l==="linear-gradient"||l==="radial-gradient"){let w=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${w??`gradient-stroke-${e}`})`)}else if(l==="pattern"){let w=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${w??`pattern-stroke-${e}`})`)}else t+=y("stroke",n.borderColor??"none");let f=n.borderWidth;f!=null&&(t+=y("stroke-width",f));let d=n.strokeOpacity;d!==void 0&&d<1&&(t+=y("stroke-opacity",d));let p=n.paintOrder;p&&p!=="normal"&&(t+=y("paint-order",p));let m=n.markerStart,h=n.markerMid,g=n.markerEnd;m&&(t+=y("marker-start",`url(#${m})`)),h&&(t+=y("marker-mid",`url(#${h})`)),g&&(t+=y("marker-end",`url(#${g})`));let b=Af(n);b&&(t+=y("stroke-dasharray",b),!n.strokeDasharray&&n.lineStyle==="dotted"&&(t+=y("stroke-linecap","round")));let $=n.dashOffset;$!==void 0&&$!==0&&(t+=y("stroke-dashoffset",$));let k=n.shapeRendering;k&&k!=="auto"&&(t+=y("shape-rendering",k)),t+=Er(e,n.filters,n.filterLibraryIds),t+=Ft("systemLanguage",n.systemLanguage),t+=Ft("requiredExtensions",n.requiredExtensions);let S=n.vectorEffect;S&&S!=="none"&&(t+=y("vector-effect",S));let x=n.visibility;x&&x!=="visible"&&(t+=y("visibility",x));let v=n.metadata;return v&&(v.role&&(t+=y("role",v.role)),v.ariaLabel&&(t+=y("aria-label",v.ariaLabel))),t}function Ns(n){let e=n.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${Y(e.title)}</title>`),e.description&&(t+=`<desc>${Y(e.description)}</desc>`),t}function Cf(n,e){let t=Ns(e);if(!t)return n;let r=n.lastIndexOf("/>");if(r===-1){let o=n.indexOf(">");return o===-1?n:n.slice(0,o+1)+t+n.slice(o+1)}let i=n.match(/^<(\w+)/),s=i?i[1]:"g";return n.slice(0,r)+">"+t+`</${s}>`}function Bs(n){let e="",t=n.startEndpoint,r=n.endEndpoint;return t&&t!=="none"&&(e+=y("marker-start",`url(#line-marker-${t})`)),r&&r!=="none"&&(e+=y("marker-end",`url(#line-marker-${r})`)),e}function zs(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.radius??50,s=Me(e,{x:t,y:r});return`<circle${y("cx",t)}${y("cy",r)}${y("r",i)}${Ie(e,n.id)}${s?y("transform",s):""}/>`}function Gs(n){let e=n.state,t=e.cx??0,r=e.cy??0,i=e.rx??50,s=e.ry??30,o=e.pathLength,a=Me(e,{x:t,y:r});return`<ellipse${y("cx",t)}${y("cy",r)}${y("rx",i)}${y("ry",s)}${o!==void 0?y("pathLength",o):""}${Ie(e,n.id)}${a?y("transform",a):""}/>`}function Vs(n){let e=n.state,t=e,r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100,a=e.cornerRadius??0,l=e.rx??a,c=e.ry??a,f=t.cornerShape??"round",d=t.cornerMode??"uniform",p={x:r+s/2,y:i+o/2},m=Me(e,p);if(f!=="round"||d==="non-uniform"){let h=Ar(r,i,s,o,a,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(h)return`<path${y("d",h)}${Ie(e,n.id)}${m?y("transform",m):""}/>`}return`<rect${y("x",r)}${y("y",i)}${y("width",s)}${y("height",o)}${l>0||c>0?`${y("rx",l)}${y("ry",c)}`:""}${Ie(e,n.id)}${m?y("transform",m):""}/>`}function Us(n){let e=n.state,t=e.x1??0,r=e.y1??0,i=e.x2??0,s=e.y2??0,o={x:(t+i)/2,y:(r+s)/2},a=Me(e,o),l={...e,fillType:"none"};return`<line${y("x1",t)}${y("y1",r)}${y("x2",i)}${y("y2",s)}${Ie(l,n.id)}${Bs(e)}${a?y("transform",a):""}/>`}function Ws(n){let e=n.state,t=e.x??0,r=e.y??0,i=xn(e.text??"",e.textTransform),s=e.fontSize??16,o=e.fontFamily??"sans-serif",a=e.fontWeight??"normal",l=e.fontStyle??"normal",c=e.textAnchor??"start",f=Rf(e.textDecoration),d=e.letterSpacing,p=e.wordSpacing,m=e.lineHeight??1.25,g=Me(e,{x:t,y:r}),b=y("x",t)+y("y",r);b+=y("font-size",s),b+=y("font-family",o),a!=="normal"&&(b+=y("font-weight",a)),l!=="normal"&&(b+=y("font-style",l)),c!=="start"&&(b+=y("text-anchor",c)),f&&(b+=y("text-decoration",f)),d&&(b+=y("letter-spacing",d)),p&&(b+=y("word-spacing",p));let $=e.baselineShift;$&&$!=="baseline"&&(b+=y("baseline-shift",$));let k=e.dominantBaseline;k&&k!=="auto"&&(b+=y("dominant-baseline",k));let S=e.writingMode;S&&S!=="horizontal-tb"&&(b+=y("writing-mode",S));let x=e.textLength;x!==void 0&&x>0&&(b+=y("textLength",x),e.lengthAdjust==="spacingAndGlyphs"&&(b+=y("lengthAdjust","spacingAndGlyphs")));let v=e.textDirection;v&&v!=="ltr"&&(b+=y("direction",v));let w=e.unicodeBidi;w&&w!=="normal"&&(b+=y("unicode-bidi",w));let T=e.shapeInsideRef;if(T){b+=y("shape-inside",`url(#${T})`);let D=e.shapePadding;D!==void 0&&(b+=y("shape-padding",D))}let P=Dt(e),R=e.fontVariationSettings,M="";if(R&&Object.keys(R).length>0&&(M=`font-variation-settings: ${Object.entries(R).map(([L,K])=>`'${L}' ${K}`).join(", ")}`),b+=kf([P,M,Tf("inline-size",e.inlineSize),typeof e.overflowWrap=="string"?`overflow-wrap: ${e.overflowWrap}`:"",typeof e.whiteSpace=="string"?`white-space: ${e.whiteSpace}`:"",typeof e.lineHeight=="number"?`line-height: ${e.lineHeight}`:""]),b+=Ie(e,n.id),g&&(b+=y("transform",g)),e.isTextPath&&e.textPathPoints){let D=e.textPathPoints,L=e.textPathStartOffset??0,K=e.textPathSide,C=`text-path-${n.id}`,re=e.textPathMethod,ee=e.textPathSpacing,Z=e.textPathLengthAdjust,me=e.textPathLength,q="";if(D.length>=2)if(K==="right"){let W=D[D.length-1];q=`M ${W.x} ${W.y}`;for(let fe=D.length-1;fe>0;fe--){let he=D[fe],Te=D[fe-1],ve=he.handleIn??he,gt=Te.handleOut??Te;q+=` C ${ve.x} ${ve.y}, ${gt.x} ${gt.y}, ${Te.x} ${Te.y}`}}else{q=`M ${D[0].x} ${D[0].y}`;for(let W=0;W<D.length-1;W++){let fe=D[W],he=D[W+1],Te=fe.handleOut??fe,ve=he.handleIn??he;q+=` C ${Te.x} ${Te.y}, ${ve.x} ${ve.y}, ${he.x} ${he.y}`}}return`<defs><path id="${Y(C)}"${y("d",q)} fill="none"/></defs><text${b}><textPath href="#${Y(C)}"${y("startOffset",`${L}%`)}${y("method",re)}${y("spacing",ee)}${y("lengthAdjust",Z)}${y("textLength",me)}>${Y(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let D=e.charOffsets.map(wf),L=i.split(`
12
- `),K=e.linePositions??[],C=s*m,re="",ee=0;return L.forEach((Z,me)=>{let q=Array.from(Z).length,W=D.slice(ee,ee+q),fe=K[me],he=fe?t+fe.x:me>0?t:NaN,Te=fe?fe.dy:me>0?C:NaN,ve="",gt=Sl(W,"x");if(Number.isFinite(he)||gt.length>0){let Hi=gt.length>0?gt.slice():[];Number.isFinite(he)&&(Hi[0]=Hi[0]??he),ve+=y("x",Hi.join(" "))}let wa=Sl(W,"y");wa.length>0&&(ve+=y("y",wa.join(" ")));let Pa=xl(W,"dx");Pa.length>0&&(ve+=y("dx",Pa.join(" ")));let _a=xl(W,"dy"),je=_a.length>0||Number.isFinite(Te)?_a.slice():[];for(Number.isFinite(Te)&&(je[0]=(je[0]??0)+Te);je.length>0&&je[je.length-1]===0;)je.pop();je.length>0&&(ve+=y("dy",je.join(" ")));let Ra=Pf(W);Ra.length>0&&(ve+=y("rotate",Ra.join(" "))),re+=`<tspan${ve}>${Y(Z)}</tspan>`,ee+=q+1}),`<text${b}>${re}</text>`}let B=Zn(e);if(B){let D=Ve(B),L=e.linePositions,K=s*D.lineHeight,C="";return D.lines.forEach((re,ee)=>{re.segments.forEach((Z,me)=>{let q="";if(me===0){let W=L?.[ee];W?((Math.abs(W.x)>.001||ee>0)&&(q+=y("x",t+W.x)),(Math.abs(W.dy)>.001||ee>0)&&(q+=y("dy",W.dy))):ee>0&&(q+=y("x",t),q+=y("dy",`${K}px`))}for(let{name:W,value:fe}of zr(Z.style,D.baseStyle))q+=y(W,fe);q+=' xml:space="preserve"',C+=`<tspan${q}>${Y(xn(Z.text,Z.style.textTransform))}</tspan>`})}),`<text${b}>${C}</text>`}return`<text${b}>${Y(i)}</text>`}function Hs(n){let e=n.state,t=e.pathPoints??[],r=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,s=e.pathTension??.5,o=e.pathArcParams,a=qe(t,r,i,s,o),l=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=l?Me(e,l):null;return`<path${y("d",a)}${Ie(e,n.id)}${Bs(e)}${c?y("transform",c):""}/>`}function js(n){let e=n.state,t=e.polylinePoints??[],r=e.polylineClosed??!1,i=t.map(l=>`${l.x},${l.y}`).join(" "),s=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,o=s?Me(e,s):null;return`<${r?"polygon":"polyline"}${y("points",i)}${Ie(e,n.id)}${Bs(e)}${o?y("transform",o):""}/>`}function Ks(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.width??100,s=e.height??100,o=e.href??"",a=e.imageOpacity,l=e.preserveAspectRatio?"xMidYMid meet":"none",c={x:t+i/2,y:r+s/2},f=Me(e,c);return`<image${y("x",t)}${y("y",r)}${y("width",i)}${y("height",s)}${y("href",o)}${y("preserveAspectRatio",l)}${a!==void 0&&a<1?y("opacity",a):""}${Ie(e,n.id)}${f?y("transform",f):""}/>`}function Vr(n){return!n||n.length===0?"":n.map(e=>de(e)).join("")}function $l(n){let e=n.state,t="",r=Me(e);r&&(t+=y("transform",r));let i=e.opacity;i!==void 0&&i<1&&(t+=y("opacity",i));let s=e.metadata;s&&(s.role&&(t+=y("role",s.role)),s.ariaLabel&&(t+=y("aria-label",s.ariaLabel)));let o=e.containerPresentation;if(o)for(let[l,c]of Object.entries(o))/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)&&(t+=` ${l}="${Y(c)}"`);let a=e.authoredAttributes;if(a)for(let[l,c]of Object.entries(a))c===null||!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)||(t+=` ${l}="${Y(c)}"`);return t}function Df(n){let e=n.state,t=e.href,r=e.hrefXlink,i="<a";return t!==void 0&&(i+=y("href",t)),r!==void 0&&(i+=y("xlink:href",r)),i+=y("target",e.linkTarget),i+=y("rel",e.linkRel),e.linkDownload===""?i+=' download=""':i+=y("download",e.linkDownload),i+=y("ping",e.linkPing),i+=y("hreflang",e.linkHreflang),i+=y("type",e.linkType),i+=y("referrerpolicy",e.linkReferrerPolicy),i+=$l(n),i+=y("data-shape-id",n.id),i+=">",i+=Ns(e),i+=Vr(e.children),i+="</a>",i}function Ff(n){let e=n.state,t="<switch";return t+=Ft("systemLanguage",e.switchSystemLanguage),t+=Ft("requiredExtensions",e.switchRequiredExtensions),t+=$l(n),t+=y("data-shape-id",n.id),t+=">",t+=Ns(e),t+=Vr(e.children),t+="</switch>",t}function Ef(n){let e=n.state,t=Me(e),r="<g";return r+=y("data-shape-id",n.id),t&&(r+=y("transform",t)),e.opacity!==void 0&&e.opacity<1&&(r+=y("opacity",e.opacity)),e.visibility&&(r+=y("visibility",e.visibility)),e.blendMode&&(r+=y("style",`mix-blend-mode:${e.blendMode}`)),r+=">",r+=Vr(e.children),r+="</g>",r}function Of(n){let e=n.state,t=e.viewBoxX,r=e.viewBoxY,i=e.viewBoxWidth,s=e.viewBoxHeight,o=t!==void 0&&r!==void 0&&i!==void 0&&s!==void 0?`${t} ${r} ${i} ${s}`:void 0,a="<view";return a+=y("id",n.id),a+=y("viewBox",o),a+=y("preserveAspectRatio",e.viewPreserveAspectRatio),a+=y("zoomAndPan",e.viewZoomAndPan),a+=y("viewTarget",e.viewTarget),e.viewName&&(a+=y("data-view-name",e.viewName)),a+="/>",a}function Lf(n){let e=n.state,t=e.svgX,r=e.svgY,i=e.svgWidth,s=e.svgHeight,o=e.svgViewBoxX,a=e.svgViewBoxY,l=e.svgViewBoxWidth,c=e.svgViewBoxHeight,f=o!==void 0&&a!==void 0&&l!==void 0&&c!==void 0?`${o} ${a} ${l} ${c}`:void 0,d="<svg";return d+=y("xmlns","http://www.w3.org/2000/svg"),d+=y("x",t),d+=y("y",r),d+=y("width",i),d+=y("height",s),d+=y("viewBox",f),d+=y("preserveAspectRatio",e.svgPreserveAspectRatio),d+=y("data-shape-id",n.id),d+=">",d+=Vr(e.children),d+="</svg>",d}function Nf(n){let e=n.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${Y(n.id)} has no targetShapeId -->`;let r=e.offsetX??0,i=e.offsetY??0,s="<use";return s+=y("href",`#${t}`),s+=y("x",r),s+=y("y",i),e.width!==void 0&&(s+=y("width",e.width)),e.height!==void 0&&(s+=y("height",e.height)),s+=y("data-shape-id",n.id),e.opacity!==void 0&&e.opacity<1&&(s+=y("opacity",e.opacity)),s+="/>",s}function Xs(n){let e=n.state,t=Ct(n),r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100;return`<use href="#${Y(t)}" x="${r}" y="${i}" width="${s}" height="${o}"/>`}function Bf(n){let e=n.state,t=e.mediaKind??n.type,r=e.x??0,i=e.y??0,s=e.width??320,o=e.height??180,a=e.href??"",l=e.mediaMimeType,c=e.posterHref,f=e.mediaOpacity,d=`<${t} xmlns="http://www.w3.org/1999/xhtml"`;d+=y("src",a),l&&(d+=y("type",l)),c&&t==="video"&&(d+=y("poster",c)),e.muted&&(d+=' muted=""'),e.loop&&(d+=' loop=""'),e.playbackRate!==void 0&&(d+=y("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(d+=y("data-volume",e.volume)),d+=' preload="auto" playsinline=""',d+=t==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let p="<foreignObject";return p+=y("x",r),p+=y("y",i),p+=y("width",s),p+=y("height",o),p+=y("data-shape-id",n.id),p+=y("data-media-kind",t),e.naturalDuration!==void 0&&(p+=y("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(p+=y("data-begin",e.begin)),e.trimStart!==void 0&&(p+=y("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(p+=y("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(p+=y("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(p+=y("data-fade-out",e.fadeOutDuration)),p+=Ft("systemLanguage",e.systemLanguage),p+=Ft("requiredExtensions",e.requiredExtensions),f!==void 0&&f<1&&(p+=y("opacity",f)),p+=">",p+=d,p+="</foreignObject>",p}function Ys(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.width??100,s=e.height??60,o={x:t+i/2,y:r+s/2},a=Me(e,o),l=Ir(n.type,t,r,i,s,{slantPercent:e.slantPercent,topWidthPercent:e.topWidthPercent,capHeightPercent:e.capHeightPercent,waveAmplitudePercent:e.waveAmplitudePercent});return`<path${y("d",l)}${Ie(e,n.id)}${a?y("transform",a):""}/>`}function qs(n){let e=n.state,t=e.cx??0,r=e.cy??0,i=e.radius??50,s=e.cornerRadius??0,o=e.shiftAngle??-90,a=e.fillRule??"nonzero",l=_f(e,t,r),c="";switch(n.type){case"triangle":c=Ae(mn(3,i,o),s,i);break;case"ngon":{let d=e.sides??6;c=Ae(mn(d,i,o),s,i);break}case"star":{let d=e.arms??5,p=e.innerRadiusPercent??50;c=Ae(Sr(d,i,p,o),s,i);break}case"cross":{let d=e.armWidthPercent??40;c=Ae(xr(i,d,o),s,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=Pr(i,d,a);break}case"spiral":{let d=e.turns??3,p=e.thicknessPercent??20,m=e.spiralDirection??1;c=_r(i,d,p,m,o);break}case"gear":{let d=e.teeth??8,p=e.toothDepthPercent??30,m=e.holeRadiusPercent??0;c=Rr(d,i,p,s,m,a,o);break}case"arrow":{let d=e.headWidthPercent??100,p=e.headLengthPercent??30,m=e.shaftWidthPercent??40;c=Ae($r(i,d,p,m,o),s,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,p=e.tailLengthPercent??40,m=e.tailWidthPercent??25;c=Ae(vr(i,d,p,m,o),s,i);break}case"lightning":{let d=e.boltSegments??3,p=e.boltJaggednessPercent??40,m=e.boltWidthPercent??30;c=Ae(kr(i,d,p,m,o),s,i);break}case"heart":{let d=e.lobeRadiusPercent??50,p=e.cleftDepthPercent??25;c=Tr(i,d,p,o);break}case"cloud":{let d=e.cloudBumps??5,p=e.cloudPuffinessPercent??60;c=wr(i,d,p,o);break}default:return`<!-- unsupported polygon shape: ${Y(n.type)} -->`}let f="";return(n.type==="ring"||n.type==="gear")&&(f=y("fill-rule",a)),`<path${y("d",c)}${f}${Ie(e,n.id)}${y("transform",l)}/>`}function de(n){let e;switch(n.type){case"circle":e=zs(n);break;case"ellipse":e=Gs(n);break;case"rectangle":case"square":e=Vs(n);break;case"line":e=Us(n);break;case"text":e=Ws(n);break;case"path":e=Hs(n);break;case"polyline":e=js(n);break;case"image":e=Ks(n);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=qs(n);break;case"diamond":case"parallelogram":case"trapezoid":case"terminator":case"cylinder":case"document-shape":e=Ys(n);break;case"hyperlink":e=Df(n);break;case"switch":e=Ff(n);break;case"container":case"group":e=Ef(n);break;case"view":e=Of(n);break;case"svg":e=Lf(n);break;case"shape-reference":e=Nf(n);break;case"symbol-instance":e=Xs(n);break;case"audio":case"video":e=Bf(n);break;default:return`<!-- unsupported shape type: ${Y(n.type)} -->`}return Cf(e,n.state)}function vl(n,e){let t=(e.stops??[]).map(o=>{let a=`<stop${y("offset",`${o.offset*100}%`)}${y("stop-color",o.color)}`;return o.opacity!==void 0&&o.opacity<1&&(a+=y("stop-opacity",o.opacity)),a+="/>",a}).join(""),r=e.gradientUnits==="userSpaceOnUse",i=o=>r?String(o):`${o*100}%`,s=r?y("gradientUnits","userSpaceOnUse"):"";return`<linearGradient${y("id",n)}${s}${y("x1",i(e.x1))}${y("y1",i(e.y1))}${y("x2",i(e.x2))}${y("y2",i(e.y2))}${e.spreadMethod?y("spreadMethod",e.spreadMethod):""}>${t}</linearGradient>`}function kl(n,e){let t=(e.stops??[]).map(f=>{let d=`<stop${y("offset",`${f.offset*100}%`)}${y("stop-color",f.color)}`;return f.opacity!==void 0&&f.opacity<1&&(d+=y("stop-opacity",f.opacity)),d+="/>",d}).join(""),r=e.gradientUnits==="userSpaceOnUse",i=f=>r?String(f):`${f*100}%`,s=r?y("gradientUnits","userSpaceOnUse"):"",o="",a=e.ry!==void 0&&e.ry!==e.r,l=!!e.rotation;if(a||l){let f=e.cx??(r?0:.5),d=e.cy??(r?0:.5),p=[];p.push(`translate(${f}, ${d})`),l&&p.push(`rotate(${e.rotation})`),a&&e.ry!==0&&p.push(`scale(1, ${e.ry/e.r})`),p.push(`translate(-${f}, -${d})`),o=y("gradientTransform",p.join(" "))}let c=e.fr!==void 0&&e.fr>0?y("fr",i(e.fr)):"";return`<radialGradient${y("id",n)}${s}${y("cx",i(e.cx))}${y("cy",i(e.cy))}${y("fx",i(e.fx))}${y("fy",i(e.fy))}${y("r",i(e.r))}${c}${e.spreadMethod?y("spreadMethod",e.spreadMethod):""}${o}>${t}</radialGradient>`}function Tl(n,e){if(e.svgContent!=null){let a=e.width??10,l=e.height??10,c=e.patternUnits??"userSpaceOnUse",f=e.patternContentUnits,d=e.patternTransform,p=e.viewBox,m=e.preserveAspectRatio,h=e.x??0,g=e.y??0,b=`<pattern${y("id",n)}`;return b+=y("patternUnits",c),f&&(b+=y("patternContentUnits",f)),h&&(b+=y("x",h)),g&&(b+=y("y",g)),b+=y("width",a),b+=y("height",l),p&&(b+=y("viewBox",p)),m&&(b+=y("preserveAspectRatio",m)),d&&(b+=y("patternTransform",d)),b+=`>${e.svgContent}</pattern>`,b}let t=10*(e.scale??1),r=e.rotation??0,i=e.color||"#000000",s=e.backgroundColor||"#ffffff",o="";return o+=`<rect${y("width",t)}${y("height",t)}${y("fill",s)}/>`,o+=zf(e.patternType,t,i),`<pattern${y("id",n)}${y("patternUnits","userSpaceOnUse")}${y("width",t)}${y("height",t)}${r?y("patternTransform",`rotate(${r})`):""}>${o}</pattern>`}function zf(n,e,t){return bn(n,e,t).map(i=>{let s=Object.entries(i.attrs).map(([o,a])=>y(o,a)).join("");return`<${i.tag}${s}/>`}).join("")}function Ee(n,e=[]){let t=Array.isArray(n)?yn(n,e):n;if(t.ids.size===0&&t.legacyEndpoints.size===0)return"";let r="",i=pt();for(let s of i){let o=s.id,a=o.replace("line-marker-",""),l=`mkr-builtin-${a}`,c=t.legacyEndpoints.has(a)||t.ids.has(o),f=t.ids.has(l);if(!c&&!f)continue;let d=s.element,p=Object.entries(d.attrs).map(([g,b])=>y(g,b)).join(""),m=`<${d.tag}${p}/>`,h=g=>{r+=`<marker${y("id",g)}${y("viewBox",Sn)}${y("refX",s.refX)}${y("refY",s.refY)}${y("markerWidth",6)}${y("markerHeight",6)}${y("orient","auto-start-reverse")}>${m}</marker>`};c&&h(o),f&&h(l)}return r}var He=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Zs=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Js(n){switch(n.kind){case"symbol":return Qs(n);case"marker":return ea(n);case"linear-gradient":return ta(n);case"radial-gradient":return na(n);case"pattern":return ra(n);case"filter":return ia(n)}}function Qs(n){let e=n.shapes.map(i=>de(i)).join(""),t=n.viewBox?` viewBox="${He(n.viewBox)}"`:"",r=n.overflow?` overflow="${He(n.overflow)}"`:"";return`<symbol id="${He(n.id)}"${t}${r}>${e}</symbol>`}function ea(n){let e;if(n.builtIn){let s=pt().find(o=>n.id.includes(o.id)||n.id===o.id);if(s){let o=Object.entries(s.element.attrs).map(([a,l])=>` ${a}="${He(String(l))}"`).join("");e=`<${s.element.tag}${o}/>`}else e=""}else e=n.shapes.map(s=>de(s)).join("");let t=typeof n.orient=="number"?String(n.orient):n.orient,r=n.viewBox?` viewBox="${He(n.viewBox)}"`:"",i=n.overflow?` overflow="${He(n.overflow)}"`:"";return`<marker id="${He(n.id)}"${r} refX="${n.refX}" refY="${n.refY}" markerWidth="${n.markerWidth}" markerHeight="${n.markerHeight}" markerUnits="${He(n.markerUnits)}" orient="${He(t)}"${i}>${e}</marker>`}function ta(n){let e={...n.gradient,type:"linear-gradient",id:n.id};return vl(n.id,e)}function na(n){let e={...n.gradient,type:"radial-gradient",id:n.id};return kl(n.id,e)}function ra(n){let e={...n.pattern,type:"pattern",id:n.id};return Tl(n.id,e)}function ia(n){return Os(n.id,n.filters,{colorInterpolation:n.colorInterpolation,filterUnits:n.filterUnits,primitiveUnits:n.primitiveUnits,x:n.x,y:n.y,width:n.width,height:n.height})}function $n(n){let e=new Map;for(let r of n){let i=e.get(r.kind);i?i.push(r):e.set(r.kind,[r])}let t="";for(let r of Zs){let i=e.get(r);if(i)for(let s of i)t+=Js(s)}return t}function Ze(n,e){let t=vn(n,e);return t.length===0?"":$n(t)}function vn(n,e){let t=new Map;for(let l of e)t.set(l.id,l);let r=new Map,i=l=>{if(!l)return;let c=t.get(l);c&&r.set(l,c)},s=(l,c)=>{if(!l||typeof l!="object")return;let f=l;if(!f.id||r.has(f.id))return;let d=c==="linear-gradient"?"linear-gradient":c==="radial-gradient"?"radial-gradient":c==="pattern"?"pattern":null;if(!d)return;let{id:p,sourceId:m,...h}=l,g;if(d==="linear-gradient")g={kind:"linear-gradient",id:f.id,name:m??f.id,sourceId:m,gradient:h};else if(d==="radial-gradient")g={kind:"radial-gradient",id:f.id,name:m??f.id,sourceId:m,gradient:h};else{let{customPatternId:b,...$}=h;g={kind:"pattern",id:f.id,name:m??f.id,sourceId:m,pattern:$}}r.set(f.id,g)},o=(l,c)=>{let f=l.filters;if(!Array.isArray(f)||f.length===0)return;let d=`filter-${c}`;r.has(d)||r.set(d,{kind:"filter",id:d,name:d,filters:f,...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}:{}})},a=l=>{let c=l.state;if(!c)return;i(c.fillLibraryId),i(c.strokeLibraryId),i(c.markerStart),i(c.markerMid),i(c.markerEnd),i(c.symbolId);let f=c.filterLibraryIds;if(Array.isArray(f))for(let d of f)typeof d=="string"&&i(d);c.fillLibraryId||s(c.fillGradient,c.fillType),c.strokeLibraryId||s(c.strokeGradient,c.strokeType),(!Array.isArray(f)||f.length===0)&&o(c,l.id)};for(let l of n)a(l);return gn(n,e,a),Array.from(r.values())}function sa(n){return n.easing==="custom-bezier"&&n.customBezier?n.customBezier:Cn[n.easing]??null}function aa(n,e,t,r,i){if(n===e&&t===r)return i;let s=1e-6,o=8,a=m=>(((1-3*t+3*n)*m+(3*t-6*n))*m+3*n)*m,l=m=>(((1-3*r+3*e)*m+(3*r-6*e))*m+3*e)*m,c=m=>(3*(1-3*t+3*n)*m+2*(3*t-6*n))*m+3*n,f=i;for(let m=0;m<o;m++){let h=a(f)-i;if(Math.abs(h)<s)return l(f);let g=c(f);if(Math.abs(g)<s)break;f-=h/g}let d=0,p=1;for(f=i;d<p;){let m=a(f);if(Math.abs(m-i)<s)return l(f);i>m?d=f:p=f;let h=(p-d)*.5+d;if(h===f)break;f=h}return l(f)}function oa(n){let e=n.split(/\s+/).map(parseFloat);if(e.length!==4||e.some(o=>!Number.isFinite(o)))return n;let[t,r,i,s]=e;return`${1-i} ${1-s} ${1-t} ${1-r}`}function be(n){return!Number.isFinite(n)||Math.abs(n)<1e-9?"0":Math.abs(n-1)<1e-9?"1":parseFloat(n.toFixed(6)).toString()}function Wr([n,e,t,r]){let i=s=>Number.isFinite(s)?parseFloat(s.toFixed(6)).toString():"0";return`${i(n)} ${i(e)} ${i(t)} ${i(r)}`}function la(n){return n.length>0&&n.every(e=>e==="0 0 1 1")}function kn(n){if(n.length<2)return!1;let e=n.length-1,t=1e-4;for(let r=0;r<n.length;r++){let i=r/e,s=parseFloat(n[r]);if(!Number.isFinite(s)||Math.abs(s-i)>t)return!1}return!0}function Hr(n){if(n.length<2)return!1;let e=n.length-1,t=1e-4;for(let r=0;r<n.length;r++)if(Math.abs(n[r]-r/e)>t)return!1;return!0}function Qe(n){let e=n.cycleDuration??(n.keyframes.length>0?n.keyframes[n.keyframes.length-1].time:0);return n.cycleBehavior==="alternate"?e*2:e}function mt(n){let e=n.beginTrigger;if(e)switch(e.type){case"time":{let r=parseFloat(e.value);return Number.isNaN(r)?"":Number.isFinite(r)?r!==0?`${r}s`:"":"indefinite"}case"event":return e.value;case"expression":return"";default:break}let t=n.keyframes[0]?.time??0;return t!==0?`${t}s`:""}function jr(n){return n.keyframes.length===1&&n.cycleDuration===void 0}function Kr(n){return n.calcMode!=="discrete"?!1:n.sourceSmilElement==="set"?!0:!n.sourceSmilElement&&!n.cycleInfinite&&n.keyframes.every(e=>e.easing!=="steps")}function Xr(n,e){if(e<=0)return mt(n);if(mt(n)==="indefinite")return"indefinite";let t=n.keyframes[e]?.time??0;return t!==0?`${t}s`:""}function Yr(n){return n.cycleInfinite?"indefinite":n.cycleRepeats&&n.cycleRepeats>1?String(n.cycleRepeats):null}function ht(n){return n.cycleInfinite||n.fill==="remove"?null:"freeze"}function qr(n){return n.additive==="sum"?"sum":null}function Zr(n){return n.keyframes.map(e=>{let t=typeof e.value=="number"?e.value:parseFloat(String(e.value));return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0})}function Gf(n){let e=t=>Math.max(0,Math.min(1,t));return[n[0],e(n[1]),n[2],e(n[3])]}function Vf(n){let[e,t,r,i]=n,s=new Set,o=8;for(let d=1;d<=o;d++)s.add(d/o);let a=t-2*i+1,l=2*(i-2*t),c=t,f=d=>{if(!Number.isFinite(d)||d<=0||d>=1)return;let p=3*(1-d)**2*d*e+3*(1-d)*d**2*r+d**3;p>0&&p<1&&s.add(Number(p.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(l)>=1e-9&&f(-c/l);else{let d=l*l-4*a*c;if(d>=0){let p=Math.sqrt(d);f((-l+p)/(2*a)),f((-l-p)/(2*a))}}return[...s].sort((d,p)=>d-p)}function Uf(n,e,t,r,i,s){let o=typeof n.value=="number"&&typeof e.value=="number",a=Je(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(o){let b=e.linearPoints;for(let $=1;$<b.length;$++){let k=b[$],S=n.time+(e.time-n.time)*k.position,x=n.value+(e.value-n.value)*k.value;r.push(x),i.push(be(t(S))),s.push("0 0 1 1")}return}r.push(a),i.push(be(t(e.time))),s.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(be(t(e.time))),s.push("0 0 1 1");return}let l=sa(e);if(!l){r.push(a),i.push(be(t(e.time))),s.push("0 0 1 1");return}let[,c,,f]=l;if(!(c<0||c>1||f<0||f>1)){r.push(a),i.push(be(t(e.time))),s.push(Wr(l));return}if(!o){r.push(a),i.push(be(t(e.time))),s.push(Wr(Gf(l)));return}let p=Vf(l),m=n.value,h=e.value,g=e.time-n.time;for(let b of p){let $=aa(l[0],l[1],l[2],l[3],b),k=n.time+g*b,S=m+(h-m)*$;r.push(S),i.push(be(t(k))),s.push("0 0 1 1")}}function Je(n){return Array.isArray(n)?n.join(" "):n}function Wf(n,e,t){let r=[],{count:i,position:s}=t,o=e.time-n.time,a=Je(n.value),l=Je(e.value),c=typeof a=="number"&&typeof l=="number",f=typeof a=="string"&&typeof l=="string",d=h=>f?h<.5?a:l:c?a+(l-a)*h:h>=1?l:a,p=h=>{let g=Math.floor(h*i);(s==="jump-start"||s==="jump-both")&&(g+=1);let b;switch(s){case"jump-start":case"jump-end":b=i;break;case"jump-none":b=i-1;break;case"jump-both":b=i+1;break}return g>b&&(g=b),g<0&&(g=0),g/b},m=p(0);for(let h=1;h<=i;h++){let g=h/i,b=p(g);if(b===m)continue;let $=n.time+g*o;r.push({value:d(b),time:$}),m=b}return r.length===0||r[r.length-1].time<e.time?r.push({value:l,time:e.time}):r[r.length-1]={value:l,time:e.time},r}function Hf(n,e){let t=[],r=[],i=(s,o)=>{t.push(s),r.push(be(e(o)))};i(Je(n[0].value),n[0].time);for(let s=1;s<n.length;s++){let o=n[s-1],a=n[s];if(a.easing==="steps"&&a.stepsParams){let l=Wf(o,a,a.stepsParams);for(let c of l)i(c.value,c.time)}else i(Je(a.value),a.time)}return{values:t,keyTimes:r}}function Ur(n,e,t,r,i){if(i.cycleBehavior!=="alternate"||n.length<2)return{values:n,keyTimes:e,keySplines:t,calcMode:r};let s=n.slice(0,-1).reverse(),o=e.slice(0,-1).reverse().map(l=>be(1-parseFloat(l))),a=t.slice().reverse().map(oa);return{values:[...n,...s],keyTimes:[...e,...o],keySplines:[...t,...a],calcMode:r}}function et(n){let e=n.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let t=Qe(n),r=e[0]?.time??0,i=c=>t>0?(c-r)/t:0;if(e.some(c=>c.easing==="steps")){let{values:c,keyTimes:f}=Hf(e,i);return Ur(c,f,[],"discrete",n)}if(n.calcMode==="discrete"){let c=e.map(d=>Je(d.value)),f=e.map(d=>be(i(d.time)));return Ur(c,f,[],"discrete",n)}if(n.calcMode==="paced"){let c=e.map(d=>Je(d.value)),f=e.map(d=>be(i(d.time)));return Ur(c,f,[],"paced",n)}let o=[Je(e[0].value)],a=[be(i(e[0].time))],l=[];for(let c=1;c<e.length;c++)Uf(e[c-1],e[c],i,o,a,l);return Ur(o,a,l,"spline",n)}function Tn(n,e={}){let t=e.defaultCalcMode??"linear",r={};if(n.calcMode==="paced")return t!=="paced"&&(r.calcMode="paced"),r;if(n.calcMode==="discrete")return r.keyTimes=n.keyTimes.join(";"),r.calcMode="discrete",r;let i=n.keySplines.length>0&&!la(n.keySplines);return kn(n.keyTimes)||(r.keyTimes=n.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=n.keySplines.join(";")),r}function ua(n,e){if(n.shapeId!==e.shapeId||n.keyframes.length!==e.keyframes.length||(n.cycleDuration??-1)!==(e.cycleDuration??-1)||(n.cycleRepeats??1)!==(e.cycleRepeats??1)||!!n.cycleInfinite!=!!e.cycleInfinite||(n.cycleBehavior??"restart")!==(e.cycleBehavior??"restart")||(n.additive??"replace")!==(e.additive??"replace")||(n.calcMode??"linear")!==(e.calcMode??"linear")||!!n.locked!=!!e.locked)return!1;let t=(r,i)=>!r&&!i||!!r&&!!i&&r.type===i.type&&r.value===i.value;if(!t(n.beginTrigger,e.beginTrigger)||!t(n.endTrigger,e.endTrigger))return!1;for(let r=0;r<n.keyframes.length;r++){let i=n.keyframes[r],s=e.keyframes[r];if(i.time!==s.time||i.easing!==s.easing)return!1;let o=i.customBezier,a=s.customBezier;if(!!o!=!!a)return!1;if(o&&a){for(let l=0;l<4;l++)if(o[l]!==a[l])return!1}if(JSON.stringify(i.linearPoints??null)!==JSON.stringify(s.linearPoints??null)||JSON.stringify(i.stepsParams??null)!==JSON.stringify(s.stepsParams??null))return!1}return!0}function Jr(n){let e=new Map,t=new Set,r=new Map;for(let i of n){if(!i.enabled||i.keyframes.length<2||i.property!=="translateX"&&i.property!=="translateY"&&i.property!=="scaleX"&&i.property!=="scaleY")continue;let s=r.get(i.shapeId)??[];s.push(i),r.set(i.shapeId,s)}for(let i of r.values()){let s=new Set;for(let o=0;o<i.length;o++){let a=i[o];if(s.has(a.id))continue;let l=a.property==="translateX"||a.property==="translateY",c=l?"translateX":"scaleX",f=l?"translateY":"scaleY";if(!(a.property!==c&&a.property!==f))for(let d=o+1;d<i.length;d++){let p=i[d];if(s.has(p.id)||!(a.property===c&&p.property===f||a.property===f&&p.property===c)||!ua(a,p))continue;let m=a.property===c?a:p,h=a.property===f?a:p;e.set(m.id,h),t.add(h.id),s.add(m.id),s.add(h.id);break}}}return{partner:e,skip:t}}function Qr(n,e,t,r){if(r){let s=e?r.values:n.values,o=e?n.values:r.values,a=Math.min(s.length,o.length),l=[];for(let c=0;c<a;c++)l.push(`${s[c]} ${o[c]}`);return l}let i=t?"1":"0";return n.values.map(s=>e?`${i} ${s}`:`${s} ${i}`)}var Pl={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",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",display:"display",visibility:"visibility",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",pathMorph:"d",polylinePoints:"points"},_l=new Set(["transformMatrix","rotation","skewX","skewY"]),Rl=new Set(["translateX","translateY","scaleX","scaleY"]);function ei(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j(n,e){return e==null?"":` ${n}="${ei(e)}"`}function ca(n,e){let t=Tn(n,e);return j("keyTimes",t.keyTimes)+j("calcMode",t.calcMode)+j("keySplines",t.keySplines)}function ti(n,e){return j("dur",`${e}s`)+j("begin",mt(n)||null)+j("repeatCount",Yr(n))}function jf(n){let e=Pl[n.property];if(!e)return"";let t=Qe(n);if(t<=0)return"";let r=et(n);return r.values.length<2?"":"<animate"+j("attributeName",e)+j("values",r.values.join(";"))+ca(r)+ti(n,t)+j("fill",ht(n))+"/>"}function Kf(n){let e;switch(n.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=Qe(n);if(t<=0)return"";let r=et(n),i=e==="matrix"?r.values.map(o=>Yf(o)):r.values.map(o=>String(o));if(i.length<2||i.some(o=>o.length===0))return"";let s=e==="rotate"&&n.transformOrigin?i.map(o=>`${o} ${n.transformOrigin.x} ${n.transformOrigin.y}`):i;return'<animateTransform attributeName="transform"'+j("type",e)+j("values",s.join(";"))+ca(r)+ti(n,t)+j("additive",qr(n))+j("fill",ht(n))+"/>"}function Xf(n,e,t){let r=n.property==="scaleX"||n.property==="scaleY",i=n.property==="translateY"||n.property==="scaleY",s=r?"scale":"translate",o=Qe(n);if(o<=0)return"";let a=et(n);if(a.values.length<2)return"";let l=e?et(e):void 0,c=Qr(a,i,r,l);if(c.length<2)return"";let f=!n.replacesCarrierBase||t?"sum":null;return'<animateTransform attributeName="transform"'+j("type",s)+j("values",c.join(";"))+ca(a)+ti(n,o)+j("additive",f)+j("fill",ht(n))+"/>"}function Yf(n){if(Array.isArray(n)&&n.length>=6){let e=n.slice(0,6);if(e.every(t=>typeof t=="number"&&Number.isFinite(t)))return e.join(" ")}if(typeof n=="string"){let e=n.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 qf(n){if(!n.motionPath)return"";let e=Qe(n);if(e<=0)return"";let t=et(n),r=Zr(n),i=!!n.motionPathRef&&(n.motionPathRef.mode??"trackShape")==="curveTemplate",s=Tn(t,{defaultCalcMode:"paced"}),o=Hr(r)&&kn(t.keyTimes)&&t.calcMode!=="discrete"&&s.calcMode===void 0,a="<animateMotion";return i||(a+=j("path",n.motionPath)),a+=j("keyTimes",s.keyTimes),o||(a+=j("keyPoints",r.join(";"))),a+=j("calcMode",s.calcMode)+j("keySplines",s.keySplines),a+=ti(n,e),a+=j("fill",ht(n)),n.motionRotate!==void 0&&(a+=j("rotate",typeof n.motionRotate=="number"?String(n.motionRotate):n.motionRotate)),i?a+=`><mpath href="#${ei(n.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function wl(n,e){if(_l.has(n.property)||Rl.has(n.property)||n.property==="pathMotion")return"";let t=Pl[n.property];if(!t)return"";let r=n.keyframes[e];return r?"<set"+j("attributeName",t)+j("to",Array.isArray(r.value)?r.value.join(" "):String(r.value))+j("begin",Xr(n,e)||null)+"/>":""}function Zf(n){let e=mt(n);return e?`<discard begin="${ei(e)}"/>`:"<discard/>"}function ni(n){let e=new Map,t=n.tracks.map(a=>({...a,locked:a.locked??!1,keyframes:[...a.keyframes].sort((l,c)=>l.time-c.time).map(l=>({...l,time:l.time,value:l.value,easing:l.easing}))})),r=Jr(t),i=new Set,s=new Set,o=(a,l,c)=>{if(!l)return;let f=l;c.sourceSmilId&&!i.has(c.sourceSmilId)&&(i.add(c.sourceSmilId),f=l.replace(/^(<[a-zA-Z]+)/,`$1 id="${ei(c.sourceSmilId)}"`));let d=e.get(a)??[];d.push(f),e.set(a,d)};for(let a of t){if(!a.enabled||r.skip.has(a.id)||a.keyframes.length<1)continue;if(a.property==="discard"){o(a.shapeId,Zf(a),a);continue}if(jr(a)){o(a.shapeId,wl(a,0),a);continue}if(Kr(a)){for(let c=0;c<a.keyframes.length;c++)o(a.shapeId,wl(a,c),a);continue}if(a.keyframes.length<2)continue;let l="";a.property==="pathMotion"&&a.motionPath?l=qf(a):_l.has(a.property)?(l=Kf(a),l&&s.add(a.shapeId)):Rl.has(a.property)?(l=Xf(a,r.partner.get(a.id),s.has(a.shapeId)),l&&s.add(a.shapeId)):l=jf(a),o(a.shapeId,l,a)}return e}function Et(n,e={}){let{xmlDeclaration:t=!0,backgroundColor:r,indent:i=!0,className:s}=e,o=n.viewboxes?.[0],a=e.width??o?.width??800,l=e.height??o?.height??600,c=e.viewBox??`0 0 ${a} ${l}`,f=i?`
13
- `:"",d=i?" ":"",p=n.shapes??[],m=p.filter(D=>D.state?.displayMode==="motionOnly"),h=p.filter(D=>D.state?.displayMode!=="motionOnly"),g=tp(n),b=np(n),$=[...Array.isArray(n.library)?n.library:[],...(b??[]).filter(D=>!D.builtIn&&!(Array.isArray(n.library)&&n.library.some(L=>L.id===D.id)))],k=vn(h,$),S=k.length>0?$n(k):"",x=Ee(h,$),v=rp(g,h,new Set(k.map(D=>D.id))),w=Jf(m),T=S.length>0||x.length>0||v.length>0||w.length>0,P="";T&&(P=`${f}${d}<defs>${f}`,S.length>0&&(P+=`${d}${d}${S}${f}`),x.length>0&&(P+=`${d}${d}${x}${f}`),v.length>0&&(P+=`${d}${d}${v}${f}`),w.length>0&&(P+=`${d}${d}${w}${f}`),P+=`${d}</defs>`);let R="";r&&(R=`${f}${d}<rect width="${a}" height="${l}" fill="${r}"/>`);let M=n.animationTimeline?ni(n.animationTimeline):null,N=h.map(D=>{let L=de(D),K=M?.get(D.id);return K&&K.length>0&&(L=ip(L,K,d)),`${d}${L}`}).join(f),B="";return t&&(B+=`<?xml version="1.0" encoding="UTF-8"?>${f}`),B+='<svg xmlns="http://www.w3.org/2000/svg"',B+=` width="${a}" height="${l}"`,B+=` viewBox="${c}"`,s&&(B+=` class="${s}"`),B+=">",B+=P,B+=R,h.length>0&&(B+=`${f}${N}`),B+=`${f}</svg>${f}`,B}function Jf(n){if(n.length===0)return"";let e=[];for(let t of n){let r=Qf(t);if(!r)continue;let i=ep(r);e.push(`<path id="${Al(t.id)}" d="${Al(i)}"/>`)}return e.join("")}function Qf(n){let e=n.state;if(typeof e?.d=="string")return e.d;switch(n.type){case"rectangle":{let t=e?.x??0,r=e?.y??0,i=e?.width??0,s=e?.height??0;return i<=0||s<=0?null:`M${t},${r}h${i}v${s}h${-i}Z`}case"circle":{let t=e?.cx??0,r=e?.cy??0,i=e?.radius??0;return i<=0?null:`M${t-i},${r}A${i},${i} 0 1 0 ${t+i},${r}A${i},${i} 0 1 0 ${t-i},${r}Z`}case"ellipse":{let t=e?.cx??0,r=e?.cy??0,i=e?.rx??0,s=e?.ry??0;return i<=0||s<=0?null:`M${t-i},${r}A${i},${s} 0 1 0 ${t+i},${r}A${i},${s} 0 1 0 ${t-i},${r}Z`}case"line":{let t=e?.x1??0,r=e?.y1??0,i=e?.x2??0,s=e?.y2??0;return`M${t},${r}L${i},${s}`}default:return null}}function ep(n){let e=/[Mm]\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[\s,]+(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(n);if(!e)return n;let t=parseFloat(e[1]),r=parseFloat(e[2]);if(!isFinite(t)||!isFinite(r)||t===0&&r===0)return n;let i=!0;return n.replace(/([MLCQSTHVAZ])\s*([\d\s.,e+-]*)/gi,(s,o,a)=>{let l=o.toUpperCase(),c=o!==l,f=i;if(i=!1,l==="Z")return s;let d=a.trim().split(/[\s,]+/).filter(m=>m.length>0).map(Number);if(d.length===0||c&&!f)return s;let p=[];if(l==="H")for(let m of d)p.push(m-t);else if(l==="V")for(let m of d)p.push(m-r);else if(l==="A")for(let m=0;m<d.length;m+=7)p.push(d[m],d[m+1],d[m+2],d[m+3],d[m+4]),m+5<d.length&&p.push(d[m+5]-t),m+6<d.length&&p.push(d[m+6]-r);else for(let m=0;m<d.length;m+=2)p.push(d[m]-t),m+1<d.length&&p.push(d[m+1]-r);return`${o} ${p.join(" ")}`})}function Al(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function tp(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="symbol");return t.length>0?t:n.symbols??[]}function np(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="marker");return t.length>0?t:n.markers}var da=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function rp(n,e,t=new Set){if(n.length===0)return"";let r=new Map;for(let l of n)r.set(l.id,l);let i=new Map,s=new Set,o=[...e];for(let l=0;l<o.length;l++){let c=o[l],f=c.state?.children;if(Array.isArray(f)&&o.push(...f),c.type!=="symbol-instance")continue;let d=r.get(c.state.symbolId??"");if(!d)continue;let p=Ct(c);if(s.has(p))continue;s.add(p);let m=Br(d,c);o.push(...m),!t.has(p)&&i.set(p,{def:d,resolved:m})}if(i.size===0)return"";let a=[];for(let[l,{def:c,resolved:f}]of i){let d=f.map(h=>de(h)).join(""),p=c.viewBox?` viewBox="${da(c.viewBox)}"`:"",m=c.overflow?` overflow="${da(c.overflow)}"`:"";a.push(`<symbol id="${da(l)}"${p}${m}>${d}</symbol>`)}return a.join("")}function ip(n,e,t){let r=e.join(""),i=0;for(;i<n.length;){let c=n.slice(i);if(!/^<defs[\s>]/.test(c))break;let f=n.indexOf("</defs>",i);if(f===-1)break;i=f+7}let s=n.slice(0,i),o=n.slice(i),a=o.lastIndexOf("/>");if(a!==-1){let c=o.match(/^<(\w+)/),f=c?c[1]:"g";return s+o.slice(0,a)+">"+r+`</${f}>`}let l=o.match(/<\/(\w+)>$/);if(l){let c=o.lastIndexOf(`</${l[1]}>`);return s+o.slice(0,c)+r+o.slice(c)}return s+o+r}var Ot=Math.PI*2;function sp(n,e,t,r){let i=e*e-4*n*t;if(!(i>=0))return;let s=Math.sqrt(i),o=-.5*(e+(e>=0?s:-s));if(n!==0){let a=o/n;a>0&&a<1&&r.push(a)}if(o!==0){let a=t/o;a>0&&a<1&&r.push(a)}}function ap(n,e,t,r,i){let s=1-i;return s*s*s*n+3*s*s*i*e+3*s*i*i*t+i*i*i*r}function op(n,e,t,r){let i=1-r;return i*i*n+2*i*r*e+r*r*t}function si(n,e,t,r){let i=n<r?n:r,s=n>r?n:r,o=-n+3*e-3*t+r,a=2*(n-2*e+t),l=e-n,c=[];sp(o,a,l,c);for(let f of c){let d=ap(n,e,t,r,f);d<i&&(i=d),d>s&&(s=d)}return{min:i,max:s}}function ai(n,e,t){let r=n<t?n:t,i=n>t?n:t,s=n-2*e+t;if(s!==0){let o=(n-e)/s;if(o>0&&o<1){let a=op(n,e,t,o);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function Il(n,e,t,r){let i=n*r-e*t>=0?1:-1,s=Math.sqrt((n*n+e*e)*(t*t+r*r));if(s===0)return 0;let o=(n*t+e*r)/s;return o<-1?o=-1:o>1&&(o=1),i*Math.acos(o)}function pa(n,e,t,r,i,s,o,a,l){if(n===a&&e===l||t===0||r===0)return null;let c=Math.abs(t),f=Math.abs(r),d=i%360*Math.PI/180,p=Math.cos(d),m=Math.sin(d),h=(n-a)/2,g=(e-l)/2,b=p*h+m*g,$=-m*h+p*g,k=b*b,S=$*$,x=c*c,v=f*f,w=k/x+S/v;if(w>1){let me=Math.sqrt(w);c*=me,f*=me,x=c*c,v=f*f}let T=x*S+v*k;if(T===0)return null;let P=(x*v-T)/T;P<0&&(P=0);let R=Math.sqrt(P);s===o&&(R=-R);let M=R*(c*$/f),N=R*(-(f*b)/c),B=p*M-m*N+(n+a)/2,D=m*M+p*N+(e+l)/2,L=(b-M)/c,K=($-N)/f,C=(-b-M)/c,re=(-$-N)/f,ee=Il(1,0,L,K),Z=Il(L,K,C,re);return!o&&Z>0?Z-=Ot:o&&Z<0&&(Z+=Ot),{cx:B,cy:D,rx:c,ry:f,phi:d,theta1:ee,deltaTheta:Z}}function lp(n,e){let t=Math.cos(n.phi),r=Math.sin(n.phi),i=Math.cos(e),s=Math.sin(e);return{x:n.cx+n.rx*t*i-n.ry*r*s,y:n.cy+n.rx*r*i+n.ry*t*s}}function up(n,e,t){if(t>=0){let i=(n-e)%Ot;return i<0&&(i+=Ot),i<=t}let r=(e-n)%Ot;return r<0&&(r+=Ot),r<=-t}function ma(n,e,t,r,i,s,o,a,l){let c={minX:Math.min(n,a),minY:Math.min(e,l),maxX:Math.max(n,a),maxY:Math.max(e,l)},f=pa(n,e,t,r,i,s,o,a,l);if(!f)return c;let d=Math.cos(f.phi),p=Math.sin(f.phi),m=Math.atan2(-f.ry*p,f.rx*d),h=Math.atan2(f.ry*d,f.rx*p),g=[m,m+Math.PI,h,h+Math.PI];for(let b of g){if(!up(b,f.theta1,f.deltaTheta))continue;let $=lp(f,b);$.x<c.minX&&(c.minX=$.x),$.x>c.maxX&&(c.maxX=$.x),$.y<c.minY&&(c.minY=$.y),$.y>c.maxY&&(c.maxY=$.y)}return c}var cp="MmLlHhVvCcSsQqTtAaZz";function ri(n){return n>=48&&n<=57}function dp(n){return n===32||n===9||n===10||n===12||n===13}var fa=class{constructor(e){this.d=e}d;i=0;skipWsp(){for(;this.i<this.d.length&&dp(this.d.charCodeAt(this.i));)this.i++}skipCommaWsp(){this.skipWsp(),this.d.charCodeAt(this.i)===44&&(this.i++,this.skipWsp())}atEnd(){return this.skipWsp(),this.i>=this.d.length}readCommand(){this.skipWsp();let e=this.d[this.i];return e!==void 0&&cp.indexOf(e)>=0?(this.i++,e):null}nextIsNumber(){this.skipCommaWsp();let e=this.d.charCodeAt(this.i);return ri(e)||e===43||e===45||e===46}readNumber(){this.skipCommaWsp();let e=this.d,t=this.i,r=this.i,i=e.charCodeAt(r);(i===43||i===45)&&r++;let s=0;for(;r<e.length&&ri(e.charCodeAt(r));)r++,s++;if(e.charCodeAt(r)===46)for(r++;r<e.length&&ri(e.charCodeAt(r));)r++,s++;if(s===0)return null;let o=e.charCodeAt(r);if(o===101||o===69){let l=r+1,c=e.charCodeAt(l);(c===43||c===45)&&l++;let f=0;for(;l<e.length&&ri(e.charCodeAt(l));)l++,f++;f>0&&(r=l)}let a=Number.parseFloat(e.slice(t,r));return Number.isFinite(a)?(this.i=r,a):null}readFlag(){this.skipCommaWsp();let e=this.d[this.i];return e==="0"?(this.i++,!1):e==="1"?(this.i++,!0):null}};function ii(n,e,t){e<n.minX&&(n.minX=e),e>n.maxX&&(n.maxX=e),t<n.minY&&(n.minY=t),t>n.maxY&&(n.maxY=t),n.any=!0}function ha(n,e){e.minX<n.minX&&(n.minX=e.minX),e.maxX>n.maxX&&(n.maxX=e.maxX),e.minY<n.minY&&(n.minY=e.minY),e.maxY>n.maxY&&(n.maxY=e.maxY),n.any=!0}function Ml(n,e,t,r,i,s,o,a,l){let c=si(e,r,s,a),f=si(t,i,o,l);ha(n,{minX:c.min,maxX:c.max,minY:f.min,maxY:f.max})}function Cl(n,e,t,r,i,s,o){let a=ai(e,r,s),l=ai(t,i,o);ha(n,{minX:a.min,maxX:a.max,minY:l.min,maxY:l.max})}function ga(n){if(!n)return null;let e=new fa(n),t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},r=0,i=0,s=0,o=0,a=0,l=0,c=null,f="",d=!1,p=()=>t.any?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null;for(;!e.atEnd();){let m=e.readCommand();if(m!==null)f=m;else if(f===""||f==="Z"||f==="z"||!e.nextIsNumber())break;if(!d){if(f!=="M"&&f!=="m")return null;d=!0}let h=f>="a"&&f<="z";switch(f){case"M":case"m":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();r=h?r+g:g,i=h?i+b:b,s=r,o=i,ii(t,r,i),c=null,f=h?"l":"L";break}case"L":case"l":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();r=h?r+g:g,i=h?i+b:b,ii(t,r,i),c=null;break}case"H":case"h":{let g=e.readNumber();if(g===null)return p();r=h?r+g:g,ii(t,r,i),c=null;break}case"V":case"v":{let g=e.readNumber();if(g===null)return p();i=h?i+g:g,ii(t,r,i),c=null;break}case"C":case"c":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber(),S=e.readNumber(),x=e.readNumber();if(g===null||b===null||$===null||k===null||S===null||x===null)return p();let v=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+k:k,R=h?r+S:S,M=h?i+x:x;Ml(t,r,i,v,w,T,P,R,M),a=T,l=P,c="cubic",r=R,i=M;break}case"S":case"s":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber();if(g===null||b===null||$===null||k===null)return p();let S=c==="cubic"?2*r-a:r,x=c==="cubic"?2*i-l:i,v=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+k:k;Ml(t,r,i,S,x,v,w,T,P),a=v,l=w,c="cubic",r=T,i=P;break}case"Q":case"q":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber();if(g===null||b===null||$===null||k===null)return p();let S=h?r+g:g,x=h?i+b:b,v=h?r+$:$,w=h?i+k:k;Cl(t,r,i,S,x,v,w),a=S,l=x,c="quad",r=v,i=w;break}case"T":case"t":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();let $=c==="quad"?2*r-a:r,k=c==="quad"?2*i-l:i,S=h?r+g:g,x=h?i+b:b;Cl(t,r,i,$,k,S,x),a=$,l=k,c="quad",r=S,i=x;break}case"A":case"a":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readFlag(),S=e.readFlag(),x=e.readNumber(),v=e.readNumber();if(g===null||b===null||$===null||k===null||S===null||x===null||v===null)return p();let w=h?r+x:x,T=h?i+v:v;ha(t,ma(r,i,g,b,$,k,S,w,T)),r=w,i=T,c=null;break}case"Z":case"z":{r=s,i=o,c=null;break}default:return p()}}return p()}function Dl(n,e,t=!1,r=.5,i){return n.length===0?null:ga(qe(n,e,t,r,i))}function oi(n,e){let t=Fe(n,e);return Et(n,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function fp(n){return n==="class"?"className":n==="for"?"htmlFor":n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Fl(n){return n.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${fp(t)}=`)}function li(n,e){let t=e.componentName??"SvgComponent",r=Fe(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=Ze(s,a),c=Ee(s,a),f=l+c,d=f.length>0,p=s.map(h=>{let g=de(h);return`${i}${i}${i}${Fl(g)}`}),m=[];m.push("import React from 'react';"),m.push(""),o?(m.push(`interface ${t}Props {`),m.push(`${i}className?: string;`),m.push(`${i}style?: React.CSSProperties;`),m.push("}"),m.push(""),m.push(`const ${t}: React.FC<${t}Props> = ({ className, style }) => {`)):m.push(`const ${t} = ({ className, style }) => {`),m.push(`${i}return (`),m.push(`${i}${i}<svg xmlns="http://www.w3.org/2000/svg" width="${r.width}" height="${r.height}" viewBox="0 0 ${r.width} ${r.height}" className={className} style={style}>`),d&&(m.push(`${i}${i}${i}<defs>`),m.push(`${i}${i}${i}${i}${Fl(f)}`),m.push(`${i}${i}${i}</defs>`));for(let h of p)m.push(h);return m.push(`${i}${i}</svg>`),m.push(`${i});`),m.push("};"),m.push(""),m.push(`export default ${t};`),m.push(""),m.join(`
14
- `)}function ui(n,e){let t=e.componentName??"SvgComponent",r=Fe(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=Ze(s,a),c=Ee(s,a),f=l+c,d=f.length>0,p=s.map(h=>`${i}${i}${de(h)}`),m=[];m.push("<template>"),m.push(`${i}<svg xmlns="http://www.w3.org/2000/svg" width="${r.width}" height="${r.height}" viewBox="0 0 ${r.width} ${r.height}" :class="className" :style="style">`),d&&(m.push(`${i}${i}<defs>`),m.push(`${i}${i}${i}${f}`),m.push(`${i}${i}</defs>`));for(let h of p)m.push(h);return m.push(`${i}</svg>`),m.push("</template>"),m.push(""),o?m.push('<script setup lang="ts">'):m.push("<script setup>"),m.push(`// ${t}`),o?(m.push("defineProps<{"),m.push(`${i}className?: string;`),m.push(`${i}style?: Record<string, string>;`),m.push("}>();")):(m.push("defineProps({"),m.push(`${i}className: { type: String, default: '' },`),m.push(`${i}style: { type: Object, default: () => ({}) },`),m.push("});")),m.push("</script>"),m.push(""),m.join(`
15
- `)}var pp=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function El(n){return n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Ol(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function mp(n){if(!pp.has(n.type))return!0;let e=n.state.metadata;return!!(e?.title||e?.description||n.type==="text"&&n.state.isTextPath)}function ci(n,e){let t=e.componentName??"createSvg",r=Fe(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=[];a.push("import * as d3 from 'd3';"),a.push(""),o?a.push(`export function ${t}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):a.push(`export function ${t}(container) {`),a.push(`${i}const svg = d3.select(container)`),a.push(`${i}${i}.append('svg')`),a.push(`${i}${i}.attr('xmlns', 'http://www.w3.org/2000/svg')`),a.push(`${i}${i}.attr('width', ${r.width})`),a.push(`${i}${i}.attr('height', ${r.height})`),a.push(`${i}${i}.attr('viewBox', '0 0 ${r.width} ${r.height}');`),a.push("");let l=Array.isArray(n.library)?n.library:[],c=Ze(s,l),f=Ee(s,l),d=`${c}${f}`;d.length>0&&(a.push(`${i}svg.append('defs').html(\`${Ol(d)}\`);`),a.push(""));for(let p=0;p<s.length;p++){let m=s[p];if(a.push(`${i}// ${m.type}${m.state.metadata?.name?` \u2014 ${m.state.metadata.name}`:""}`),mp(m)){a.push(`${i}svg.append('g').html(\`${Ol(de(m))}\`);`),a.push("");continue}let h=ol(m),g=Mr(m),b=`shape${p+1}`;a.push(`${i}const ${b} = svg.append('${h}')`);for(let[$,k]of g)a.push(`${i}${i}.attr('${$}', '${El(k)}')`);m.type==="text"&&m.state.text&&a.push(`${i}${i}.text('${El(m.state.text)}')`),a[a.length-1]=a[a.length-1]+";",a.push("")}return a.push(`${i}return svg;`),a.push("}"),a.push(""),a.join(`
16
- `)}function Ll(n,e){let t=n.state.metadata?.name;return t?t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${n.type}-${e+1}`}var hp=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function di(n,e){let t=Fe(n,e),r=e.indent??" ",i=n.shapes??[],s=[];for(let l=0;l<i.length;l++){let c=i[l],f=Ll(c,l),d=Mr(c),p=[];for(let[m,h]of d)hp.has(m)&&p.push(`${r}${m}: ${h};`);p.length>0&&s.push(`.${f} {
17
- ${p.join(`
34
+ ${o}`)}return n.includeWarnings===!1?[]:r.warnings.map(o=>({severity:"warning",code:/\.type$/.test(o.path)&&/Unknown shape type/.test(o.message)?"unavailable-shape-descriptor":"native-validation-warning",source:"native-document",entrypoint:e,message:o.message,documentPath:o.path}))}function Yd(t,e={}){let{indent:n=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=Br(t);if(!a.valid){let c=a.errors.map(l=>` ${l.path}: ${l.message}`).join(`
35
+ `);throw new Error(`Invalid document:
36
+ ${c}`)}}let o={};for(let a of Zd){let c=a==="unknownFields"?Jd(t):t[a];c!==void 0&&(o[a]=ZM(wt[a].serialization,c))}let s=JSON.stringify(o,null,n);return r?s+`
37
+ `:s}function ZM(t,e){switch(t.kind){case"verbatim":return e;case"shape-array":return e.map(n=>eO(cc(structuredClone(n))));case"id-sorted-array":return QM(e).map(Ro);case"ordered-array":return e.map(Ro);case"deep-sorted-object":case"unknown-bag":return Ro(e);default:return JM(t)}}function JM(t){throw new Error(`Unhandled serialization kind: ${JSON.stringify(t)}`)}function qd(t,e={}){return Tg(t,e).value}function Tg(t,e={}){let{validate:n=!0,migrate:r=!0}=e,i;try{i=JSON.parse(t)}catch(a){throw new Error(`Failed to parse .svgs document: ${a.message}`)}if(i===null||typeof i!="object"||Array.isArray(i))throw new Error("Invalid .svgs document: root must be a JSON object");let o=i;o=Co(o),r&&(o=To(o)),o=$o(o);let s=[];return n&&s.push(...ya(o,"native-document-open")),{value:o,diagnostics:s}}function QM(t){return[...t].sort((e,n)=>e.id.localeCompare(n.id))}function Ro(t){if(t==null)return t;if(Array.isArray(t))return t.map(Ro);if(typeof t!="object")return t;let e={},n=Object.keys(t).sort();for(let r of n)e[r]=Ro(t[r]);return e}function eO(t){let e={id:t.id,type:t.type},n=Object.keys(t).filter(r=>r!=="id"&&r!=="type").sort();for(let r of n)e[r]=Ro(t[r]);return e}var Nn=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Qd(t,e){return t.replace(Nn,(n,r)=>{let i=e[r];return i!==void 0?String(i):n})}function Sa(t,e={}){let n={};if(t.templateVariables)for(let i of t.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(n[i.name]=i.defaultValue);if(Object.assign(n,e),Object.keys(n).length===0)return JSON.parse(JSON.stringify(t));let r=JSON.parse(JSON.stringify(t));if(r.templateVariables)for(let i of r.templateVariables)Object.prototype.hasOwnProperty.call(e,i.name)&&(i.defaultValue=String(e[i.name]));return Rg(r,n),r}function Rg(t,e){for(let n of Object.keys(t)){let r=t[n];if(typeof r=="string"){if(Nn.lastIndex=0,Nn.test(r)){Nn.lastIndex=0;let i=Qd(r,e);if(tO(r)){let o=Number(i);if(!isNaN(o)&&rO(n)){t[n]=o;continue}}t[n]=i}}else if(Array.isArray(r))for(let i=0;i<r.length;i++)typeof r[i]=="string"?(Nn.lastIndex=0,Nn.test(r[i])&&(Nn.lastIndex=0,r[i]=Qd(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&Rg(r[i],e);else r!==null&&typeof r=="object"&&Rg(r,e)}}function tO(t){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(t)}var nO=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...Ko,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function rO(t){return nO.has(t)}function eu(t){let e=t.templateVariables??[],n=new Set(e.map(o=>o.name)),r=new Set;Cg(t,r);let i=[...r].filter(o=>!n.has(o)).sort();return{defined:[...e],undeclared:i}}function Cg(t,e){for(let n of Object.values(t))if(typeof n=="string"){let r;for(Nn.lastIndex=0;(r=Nn.exec(n))!==null;)e.add(r[1])}else if(Array.isArray(n))for(let r of n)if(typeof r=="string"){let i;for(Nn.lastIndex=0;(i=Nn.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&Cg(r,e);else n!==null&&typeof n=="object"&&Cg(n,e)}function nI(t){let e={};for(let n of t){let r=n.indexOf("=");if(r===-1)throw new Error(`Invalid variable format: "${n}". Expected "name=value".`);let i=n.slice(0,r).trim(),o=n.slice(r+1);if(!i)throw new Error(`Invalid variable format: "${n}". Variable name cannot be empty.`);e[i]=o}return e}var ba=3,tu=12;function nu(t){return t==null||!Number.isFinite(t)?ba:t<0?0:t>tu?tu:Math.floor(t)}function An(t,e){if(!Number.isFinite(t))return t;let n=Math.pow(10,e);return Math.round(t*n)/n}var iO=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function va(t,e){return t.replace(iO,n=>{let r=parseFloat(n);return Number.isFinite(r)?String(An(r,e)):n})}var oO=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),sO=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","cssMaskProperties","rawMetadata"]);function Ci(t,e,n){if(e==null)return e;if(typeof e=="number")return An(e,n);if(typeof e=="string")return oO.has(t)?va(e,n):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Ci(t,r,n));if(typeof e=="object"){if(sO.has(t))return e;if(t==="symbolOverrides"){let i={};for(let[o,s]of Object.entries(e))i[o]=Ci("state",s,n);return i}let r={};for(let[i,o]of Object.entries(e))r[i]=Ci(i,o,n);return r}return e}function $g(t,e){return{id:t.id,type:t.type,state:Ci("state",t.state,e)}}function rI(t,e){let n=t,r={...n};for(let i of Object.keys(wt)){let o=n[i];if(o!==void 0)switch(wt[i].precision){case"opaque":break;case"numeric-leaves":r[i]=Ci(i,o,e);break;case"animation-timeline":r[i]=aO(o,e);break;case"shape-trees":r[i]=cO(i,o,e);break}}return r}function aO(t,e){return{...t,tracks:t.tracks.map(n=>({...n,...n.motionPathMatrix?{motionPathMatrix:n.motionPathMatrix.map(r=>An(r,e))}:{},...n.ancestorMatrix?{ancestorMatrix:n.ancestorMatrix.map(r=>An(r,e))}:{},...n.transformOrigin?{transformOrigin:{x:An(n.transformOrigin.x,e),y:An(n.transformOrigin.y,e)}}:{},...n.pasteOffset?{pasteOffset:{x:An(n.pasteOffset.x,e),y:An(n.pasteOffset.y,e)}}:{},...typeof n.motionRotate=="number"?{motionRotate:An(n.motionRotate,e)}:{},keyframes:n.keyframes.map(r=>({...r,value:Ci("value",r.value,e)}))}))}}function cO(t,e,n){return Array.isArray(e)?t==="shapes"?e.map(r=>$g(r,n)):e.map(r=>Ci("libraryDef",r,n)):e}var ru=["unsupported-shape-type","unsupported-polygon-type","unresolved-reference","undeclarable-namespace-prefix","unresolved-container-pivot","unresolved-reference-pivot","duplicate-shape-id","reference-cycle","unresolved-svg-viewport","symbol-cycle","unresolved-symbol-definition","duplicate-library-id","invalid-symbol-viewport","unresolved-symbol-viewport","unresolved-symbol-pivot","unknown-symbol-variant","ambiguous-symbol-override-target","unresolved-symbol-override-target"],No=class{collected=[];seen=new Set;report(e){let n=`${e.severity}|${e.code}|${e.shapeId??""}|${e.message}`;this.seen.has(n)||(this.seen.add(n),this.collected.push(e))}get diagnostics(){return[...this.collected]}},Ag=[];function iu(t,e){Ag.push(t);try{return e()}finally{Ag.pop()}}function Bt(t){for(let e of Ag)e.report(t)}var Ia="0 0 10 10",ou=6,su=6;function $i(){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 wa={"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"},lO={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function sI(){return $i().map(t=>{let e=wa[t.id]??t.id;return{kind:"marker",id:e,name:lO[e]??e,viewBox:Ia,refX:t.refX,refY:t.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function jr(t,e){switch(e){case"uppercase":return t.toLocaleUpperCase();case"lowercase":return t.toLocaleLowerCase();case"capitalize":return t.replace(/\b\p{L}/gu,n=>n.toLocaleUpperCase());default:return t}}var dO=[["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 Ao(t){return dO.map(([e,n])=>{let r=t[e],i=typeof r=="string"?r.trim():"";return i?`${n}: ${i}`:""}).filter(Boolean).join("; ")}function au(t,e){let n=[],r=(a,c)=>{c!==""&&n.push({name:a,value:c})};t.fontFamily!==e.fontFamily&&r("font-family",String(t.fontFamily)),t.fontSize!==e.fontSize&&r("font-size",String(t.fontSize)),t.fontWeight!==e.fontWeight&&r("font-weight",String(t.fontWeight)),t.fontStyle!==e.fontStyle&&r("font-style",String(t.fontStyle));let i=Ao(t);i&&i!==Ao(e)&&r("style",i);let o=t.textDecoration,s=e.textDecoration;if(o.underline!==s.underline||o.strikethrough!==s.strikethrough||o.overline!==s.overline){let a=[];o.underline&&a.push("underline"),o.strikethrough&&a.push("line-through"),o.overline&&a.push("overline"),r("text-decoration",a.join(" "))}if(t.baselineShift!==e.baselineShift){let a=t.baselineShift;a==="super"||a==="sub"?r("baseline-shift",a):typeof a=="number"&&r("baseline-shift",`${a}px`)}return t.letterSpacing!==e.letterSpacing&&r("letter-spacing",String(t.letterSpacing)),t.fill!==e.fill&&r("fill",String(t.fill)),t.fillOpacity!==e.fillOpacity&&r("fill-opacity",String(t.fillOpacity)),t.direction!==e.direction&&r("direction",String(t.direction)),t.unicodeBidi!==e.unicodeBidi&&r("unicode-bidi",String(t.unicodeBidi)),n}function Og(t,e){if(t===null||typeof t=="string"||typeof t=="boolean")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError("Text layout keys require finite numbers.");return Object.is(t,-0)?0:t}if(t!==void 0){if(Array.isArray(t)){if(e.has(t))throw new TypeError("Text layout keys cannot contain cycles.");e.add(t);let n=t.map(r=>Og(r,e)??null);return e.delete(t),n}if(typeof t=="object"){let n=t;if(e.has(n))throw new TypeError("Text layout keys cannot contain cycles.");e.add(n);let r={};for(let i of Object.keys(n).sort()){let o=Og(n[i],e);o!==void 0&&(r[i]=o)}return e.delete(n),r}throw new TypeError(`Text layout keys cannot contain ${typeof t} values.`)}}function uO(t){return`text-layout-v1:${JSON.stringify(Og(t,new Set))}`}function dr(t,e){if(!Number.isFinite(t))throw new TypeError(`${e} must be finite.`);return Object.is(t,-0)?0:t}function Eo(t,e){let n=dr(t,e);if(n<0)throw new TypeError(`${e} must be non-negative.`);return n}function En(t,e,n=!1){if(!Number.isInteger(t)||t<(n?-1:0))throw new TypeError(`${e} must be an integer${n?" greater than or equal to -1":""}.`);return t}function Eg(t,e){return Object.freeze({x:dr(t.x,`${e}.x`),y:dr(t.y,`${e}.y`)})}function Mg(t,e){return Object.freeze({x:dr(t.x,`${e}.x`),y:dr(t.y,`${e}.y`),width:Eo(t.width,`${e}.width`),height:Eo(t.height,`${e}.height`)})}function pO(t){if(!t.key)throw new TypeError("Text layout product key must not be empty.");let e=t.glyphs.map((s,a)=>Object.freeze({index:En(s.index,`glyphs[${a}].index`),modelIndex:En(s.modelIndex,`glyphs[${a}].modelIndex`,!0),text:s.text,lineIndex:En(s.lineIndex,`glyphs[${a}].lineIndex`),cell:Mg(s.cell,`glyphs[${a}].cell`),start:Eg(s.start,`glyphs[${a}].start`),end:Eg(s.end,`glyphs[${a}].end`),rotation:dr(s.rotation,`glyphs[${a}].rotation`),advance:Eo(s.advance,`glyphs[${a}].advance`)})),n=t.carets.map((s,a)=>Object.freeze({index:En(s.index,`carets[${a}].index`),modelIndex:En(s.modelIndex,`carets[${a}].modelIndex`,!0),lineIndex:En(s.lineIndex,`carets[${a}].lineIndex`),x:dr(s.x,`carets[${a}].x`),y:dr(s.y,`carets[${a}].y`),height:Eo(s.height,`carets[${a}].height`),rotation:dr(s.rotation,`carets[${a}].rotation`)})),r=t.lines.map((s,a)=>Object.freeze({index:En(s.index,`lines[${a}].index`),startGlyph:En(s.startGlyph,`lines[${a}].startGlyph`),endGlyph:En(s.endGlyph,`lines[${a}].endGlyph`),baseline:Eg(s.baseline,`lines[${a}].baseline`),bounds:Mg(s.bounds,`lines[${a}].bounds`),advance:Eo(s.advance,`lines[${a}].advance`)})),i=t.modelToGlyphMap.map((s,a)=>En(s,`modelToGlyphMap[${a}]`,!0)),o=t.glyphToModelMap.map((s,a)=>En(s,`glyphToModelMap[${a}]`,!0));return Object.freeze({key:t.key,bounds:t.bounds?Mg(t.bounds,"bounds"):null,advance:Eo(t.advance,"advance"),glyphs:Object.freeze(e),carets:Object.freeze(n),lines:Object.freeze(r),modelToGlyphMap:Object.freeze(i),glyphToModelMap:Object.freeze(o)})}function fO(t){return{text:t.text,style:{...t.style}}}function cu(t){return{segments:[{text:"",style:t}]}}function mO(t){let e=[];for(let n of t.segments){let r=n.text.match(/\S+|\s+/g);if(r)for(let i of r)e.push({text:i,style:n.style})}return e}function gO(t,e){if(e<=0)return t;let n=t.width-e*2;return n>0?{x:t.x+e,width:n}:null}function aI(t,e,n){let r=t.measureText(e,n);if(!Number.isFinite(r)||r<0)throw new TypeError(`TextMeasurementHost returned invalid width ${String(r)}`);return r}function cI(t,e,n,r){if(t.length===0)return;let i=t[t.length-1],o=i.text.replace(/\s+$/,""),s=i.text.length-o.length;if(s!==0){n.length=r-s;for(let a=0;a<s;a++)e[e.length-s+a]=-1;t[t.length-1]={...i,text:o}}}function lI(t,e){let n=t.whiteSpace==="normal"||t.whiteSpace==="nowrap"||t.whiteSpace==="pre-line",r=t.whiteSpace==="normal"||t.whiteSpace==="nowrap",i=t.whiteSpace!=="pre"&&t.whiteSpace!=="nowrap",o=t.whiteSpace!=="break-spaces",s=t.shapeInsideGeometry??null,a=Math.max(0,t.shapePadding??0),c=[],l=[],d=new Map,u=x=>{if(!s)return t.inlineSize;let k=t.baseStyle.fontSize*t.lineHeight,T=s.bounds.minY+t.baseStyle.fontSize+x*k;if(T>s.bounds.maxY)return l.push(s.bounds.minX),0;let w=Math.round(T*256),P=d.get(w);if(P===void 0){let N=s.getSpanAtY(T);P=N?gO(N,a):null,d.set(w,P)}return P?(l.push(P.x),P.width):(l.push(s.bounds.minX),0)},p=[];for(let x=0;x<t.lines.length;x++){x>0&&p.push(r?{text:" ",style:t.baseStyle,modelLen:1,isHardBreak:!1,isWhitespace:!0}:{text:"",style:t.baseStyle,modelLen:1,isHardBreak:!0,isWhitespace:!1});for(let k of mO(t.lines[x])){let T=/^\s+$/.test(k.text);p.push({text:n&&T?" ":k.text,style:k.style,modelLen:k.text.length,isHardBreak:!1,isWhitespace:T})}}if(n)for(let x=p.length-1;x>0;x--){let k=p[x],T=p[x-1];k.isWhitespace&&!k.isHardBreak&&T.isWhitespace&&!T.isHardBreak&&(T.modelLen+=k.modelLen,p.splice(x,1))}let f=[],m=[],g=0,h=0,y=[],b=0,v=u(0),I=!0;for(let x of p){if(x.isHardBreak){y.length===0&&(m.push(g),h++,s&&l.length<=c.length&&u(c.length)),f.push(h),g++,c.push(y.length>0?{segments:y}:cu(t.baseStyle)),y=[],b=0,v=u(c.length),I=!0;continue}if(n&&x.isWhitespace&&I){for(let w=0;w<x.modelLen;w++)f.push(-1),g++;continue}let k=aI(e,x.text,x.style);if(i&&v>0&&b+k>v&&b>0&&(o&&(cI(y,f,m,h),h=m.length),c.push(y.length>0?{segments:y}:cu(t.baseStyle)),y=[],b=0,v=u(c.length),I=!0,x.isWhitespace)){for(let w=0;w<x.modelLen;w++)f.push(-1),g++;continue}if(i&&v>0&&k>v&&t.overflowWrap!=="normal"){for(let P of x.text){let N=aI(e,P,x.style);b+N>v&&b>0&&(c.push(y.length>0?{segments:y}:cu(t.baseStyle)),y=[],b=0,v=u(c.length)),f.push(h),m.push(g),g++,h++;let R=y[y.length-1];R&&Zn(R.style,x.style)?y[y.length-1]={...R,text:R.text+P}:y.push({text:P,style:{...x.style}}),b+=N}let w=x.modelLen-x.text.length;for(let P=0;P<w;P++)f.push(-1),g++;I=!1;continue}for(let w of x.text)f.push(h),m.push(g),g++,h++;for(let w=x.text.length;w<x.modelLen;w++)f.push(-1),g++;let T=y[y.length-1];T&&Zn(T.style,x.style)?y[y.length-1]={...T,text:T.text+x.text}:x.text&&y.push(fO(x)),b+=k,I=!1}return n&&y.length>0&&cI(y,f,m,h),y.length===0&&p.length===0&&m.push(g),c.push(y.length>0?{segments:y}:cu(t.baseStyle)),{lines:c,modelToSvgMap:f,svgToModelMap:m,shapeInsideLineXOffsets:l}}var ka=class{constructor(e){this.measurementHost=e}measurementHost;layout(e){return lI(e,this.measurementHost)}};function Pa(t){let e=0;for(;e<t.length;){let r=t.slice(e);if(!/^<defs[\s>]/.test(r))break;let i=t.indexOf("</defs>",e);if(i===-1)break;e=i+7}let n=/^<([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/.exec(t.slice(e));return n?{prefixEnd:e,openStart:e,openEnd:e+n[0].length,tagName:n[1],attributes:n[2],selfClosing:n[3]==="/"}:null}function D(t,e){return e==null||e===""?"":` ${t}="${fe(String(e))}"`}function pI(t){let e=Hd(t);return e.pivotRequired&&!e.pivotResolved&&Bt({severity:"warning",code:"unresolved-container-pivot",shapeId:t.id,message:`Container ${t.id} has decomposed rotation/scale/skew channels, but its local content bounds include contextual geometry unavailable without its document resolver or measurement host; the transform was emitted without a derived pivot.`}),e.transform.attribute}function Dt(t,e){let n=Qt(t);if(!n||n.kind!==e)throw new Error(`Shape geometry registry mismatch for ${t.type}: expected ${e}`);return n}function Mo(t,e){return e==null?"":` ${t}="${fe(e)}"`}function hO(t){let e=t.map(n=>(n??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?D("style",e):""}function yO(t,e){return typeof e=="number"&&e>0?`${t}: ${e}px`:""}function SO(t){if(t&&typeof t=="object"){let e=t;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 dI(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==null){n=i;break}if(n<0)return[];let r=new Array(n+1);for(let i=0;i<=n;i++)r[i]=t[i][e]??0;return r}function uI(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==0){n=i;break}if(n<0)return[];let r=new Array(n+1);for(let i=0;i<=n;i++)r[i]=t[i][e];return r}function bO(t){if(t.length===0)return[];let e=t.length-1,n=t[e].rotate;for(;e>0&&t[e-1].rotate===n;)e--;if(e===0&&n===0)return[];let r=new Array(e+1);for(let i=0;i<=e;i++)r[i]=t[i].rotate;return r}function Un(t,e){return bt(t,e)}function vO(t,e,n){return bf(t,e,n)}function xO(t){if(typeof t=="string"){let r=t.trim();return r.length>0?r:void 0}if(!t||typeof t!="object")return;let e=t,n=[];return e.underline&&n.push("underline"),e.strikethrough&&n.push("line-through"),e.overline&&n.push("overline"),n.length>0?n.join(" "):void 0}function yn(t,e,n=[]){return D("data-shape-id",e)+fI(fo(Ii(t),{shapeId:e}),n)}function fI(t,e=[]){let n="",r=new Map,i=new Map;for(let o of t){if(o.channel==="style"){i.delete(o.name),o.value!==null&&o.value!==""&&i.set(o.name,o.value);continue}o.ifAbsent&&r.has(o.name)||(r.delete(o.name),!(o.value===null||o.value===""&&!o.allowEmpty)&&r.set(o.name,o))}for(let o of r.values())n+=o.allowEmpty?Mo(o.name,String(o.value)):D(o.name,o.value);return(e.length>0||i.size>0)&&(n+=hO([...e,...[...i].map(([o,s])=>`${o}: ${s}`)])),n}var IO=new Set(["element-opacity","system-language","required-extensions","visibility","display","metadata","container-presentation","authored-attributes"]);function du(t){let e=t.metadata;return mo(e)}function wO(t,e){let n=du(e);if(!n)return t;let r=Pa(t);if(!r)return t;let i=t.slice(0,r.openStart),o=t.slice(r.openStart),s=r.openEnd-r.openStart;return r.selfClosing?i+`<${r.tagName}${r.attributes}>`+n+`</${r.tagName}>`+o.slice(s):i+o.slice(0,s)+n+o.slice(s)}function kO(t,e){if(e.length===0)return t;let n=e.join(""),r=Pa(t);if(!r)return t;let i=t.slice(0,r.openStart),o=t.slice(r.openStart),s=r.openEnd-r.openStart;if(r.selfClosing)return i+`<${r.tagName}${r.attributes}>`+n+`</${r.tagName}>`+o.slice(s);let a=o.match(/<\/([\w:-]+)>$/);if(!a)return i+o+n;let c=o.lastIndexOf(`</${a[1]}>`);return i+o.slice(0,c)+n+o.slice(c)}function Dg(t){let e="",n=t.startEndpoint,r=t.endEndpoint;return n&&n!=="none"&&!t.markerStart&&(e+=D("marker-start",`url(#line-marker-${n})`)),r&&r!=="none"&&!t.markerEnd&&(e+=D("marker-end",`url(#line-marker-${r})`)),e}function zg(t){let e=t.state,{cx:n,cy:r,r:i,defaultPivot:o}=Dt(t,"circle"),s=Un(e,o??void 0);return`<circle${D("cx",n)}${D("cy",r)}${D("r",i)}${yn(e,t.id)}${s?D("transform",s):""}/>`}function _g(t){let e=t.state,{cx:n,cy:r,rx:i,ry:o,pathLength:s,defaultPivot:a}=Dt(t,"ellipse"),c=Un(e,a??void 0);return`<ellipse${D("cx",n)}${D("cy",r)}${D("rx",i)}${D("ry",o)}${s!==void 0?D("pathLength",s):""}${yn(e,t.id)}${c?D("transform",c):""}/>`}function Fg(t){let e=t.state,{x:n,y:r,width:i,height:o,rx:s,ry:a,pathData:c,defaultPivot:l}=Dt(t,"rectangle"),d=Un(e,l??void 0);return c?`<path${D("d",c)}${yn(e,t.id)}${d?D("transform",d):""}/>`:`<rect${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${s>0||a>0?`${D("rx",s)}${D("ry",a)}`:""}${yn(e,t.id)}${d?D("transform",d):""}/>`}function Lg(t){let e=t.state,{x1:n,y1:r,x2:i,y2:o,defaultPivot:s}=Dt(t,"line"),a=Un(e,s??void 0),c={...e,fillType:"none"};return`<line${D("x1",n)}${D("y1",r)}${D("x2",i)}${D("y2",o)}${yn(c,t.id)}${Dg(e)}${a?D("transform",a):""}/>`.replace(' fill="none"',"")}function Bg(t,e){let n=t.state,{x:r,y:i,defaultPivot:o}=Dt(t,"text"),s=n.text??"",a=jr(s,n.textTransform),c=n.fontSize??16,l=n.fontFamily??"sans-serif",d=n.fontWeight??"normal",u=n.fontStyle??"normal",p=n.textAnchor??"start",f=xO(n.textDecoration),m=n.letterSpacing,g=n.wordSpacing,h=n.lineHeight??1.25,y=Un(n,o??void 0),b=n.isTextPath&&n.textPathPoints,v=n.authoredTextPosition,I=v?.x?.resolved===r?v.x.raw:r,x=v?.y?.resolved===i?v.y.raw:i,k=b?"":D("x",I)+D("y",x);k+=D("font-size",c),k+=D("font-family",l),d!=="normal"&&d!=="400"&&(k+=D("font-weight",d)),u!=="normal"&&(k+=D("font-style",u)),p!=="start"&&(k+=D("text-anchor",p)),f&&(k+=D("text-decoration",f)),m&&(k+=D("letter-spacing",m)),g&&(k+=D("word-spacing",g));let T=n.baselineShift;T&&T!=="baseline"&&(k+=D("baseline-shift",T));let w=n.dominantBaseline;w&&w!=="auto"&&(k+=D("dominant-baseline",w));let P=n.writingMode;P&&P!=="horizontal-tb"&&(k+=D("writing-mode",P));let N=n.textLength;N!==void 0&&N>0&&(k+=D("textLength",N),n.lengthAdjust==="spacingAndGlyphs"&&(k+=D("lengthAdjust","spacingAndGlyphs")));let R=n.textDirection;R&&R!=="ltr"&&(k+=D("direction",R));let $=n.unicodeBidi;$&&$!=="normal"&&(k+=D("unicode-bidi",$));let A=n.shapeInsideRef,O="",G="";if(A){O=`shape-inside: url(#${e?.shapeInsideTargetElementId?.(A)??A})`;let H=n.shapePadding;H!==void 0&&H>0&&(G=`shape-padding: ${H}`)}let M=Ao(n),V=n.fontVariationSettings,X="";V&&Object.keys(V).length>0&&(X=`font-variation-settings: ${Object.entries(V).map(([H,oe])=>`'${H}' ${oe}`).join(", ")}`);let Y=n.inlineSize!==void 0||A!==void 0||typeof n.overflowWrap=="string",U=typeof n.lineHeight=="number"&&n.lineHeight!==1.2,te=[M,X,yO("inline-size",n.inlineSize),O,G,typeof n.overflowWrap=="string"?`overflow-wrap: ${n.overflowWrap}`:"",typeof n.whiteSpace=="string"?`white-space: ${n.whiteSpace}`:"",Y&&U?`line-height: ${n.lineHeight}`:""];if(k+=yn(n,t.id,te),y&&(k+=D("transform",y)),n.isTextPath&&n.textPathPoints){let j=n.textPathPoints,H=n.textPathStartOffset??0,oe=n.textPathSide,re=`text-path-${t.id}`,xe=n.textPathMethod,Ze=n.textPathSpacing,rt=n.textPathLengthAdjust,Rt=n.textPathLength,lt="";if(j.length>=2)if(oe==="right"){let Ve=j[j.length-1];lt=`M ${Ve.x} ${Ve.y}`;for(let E=j.length-1;E>0;E--){let z=j[E],B=j[E-1],se=z.handleIn??z,me=B.handleOut??B;lt+=` C ${se.x} ${se.y} ${me.x} ${me.y} ${B.x} ${B.y}`}}else{lt=`M ${j[0].x} ${j[0].y}`;for(let Ve=0;Ve<j.length-1;Ve++){let E=j[Ve],z=j[Ve+1],B=E.handleOut??E,se=z.handleIn??z;lt+=` C ${B.x} ${B.y} ${se.x} ${se.y} ${z.x} ${z.y}`}}return`<defs><path id="${fe(re)}"${D("d",lt)} fill="none"/></defs><text${k}><textPath href="#${fe(re)}"${D("startOffset",`${H}%`)}${D("method",xe)}${D("spacing",Ze)}${D("lengthAdjust",rt)}${D("textLength",Rt)}>${fe(a)}</textPath></text>`}if(n.charOffsets&&Array.isArray(n.charOffsets)&&n.charOffsets.length>0){let j=n.charOffsets.map(SO),H=a.split(`
38
+ `),oe=n.linePositions??[],re=c*h,xe="",Ze=0;return H.forEach((rt,Rt)=>{let lt=Array.from(rt).length,Ve=j.slice(Ze,Ze+lt),E=oe[Rt],z=E?r+E.x:Rt>0?r:NaN,B=E?E.dy:Rt>0?re:NaN,se="",me=dI(Ve,"x");if(Number.isFinite(z)||me.length>0){let je=me.length>0?me.slice():[];Number.isFinite(z)&&(je[0]=je[0]??z),se+=D("x",je.join(" "))}let L=dI(Ve,"y");L.length>0&&(se+=D("y",L.join(" ")));let be=uI(Ve,"dx");be.length>0&&(se+=D("dx",be.join(" ")));let ce=uI(Ve,"dy"),Re=ce.length>0||Number.isFinite(B)?ce.slice():[];for(Number.isFinite(B)&&(Re[0]=(Re[0]??0)+B);Re.length>0&&Re[Re.length-1]===0;)Re.pop();Re.length>0&&(se+=D("dy",Re.join(" ")));let Ye=bO(Ve);Ye.length>0&&(se+=D("rotate",Ye.join(" "))),xe+=`<tspan${se}>${fe(rt)}</tspan>`,Ze+=lt+1}),`<text${k}>${xe}</text>`}let ne=ti(n);if(ne){let j=bc(ne),H=e?.textShapeInsideGeometry?.(t)??null,re=!!e?.textMeasurementHost&&(typeof n.inlineSize=="number"||H!==null||n.whiteSpace==="normal"||n.whiteSpace==="nowrap"||n.whiteSpace==="pre-line")?new ka(e.textMeasurementHost).layout({lines:j.lines,baseStyle:j.baseStyle,lineHeight:j.lineHeight,inlineSize:typeof n.inlineSize=="number"?n.inlineSize:0,overflowWrap:n.overflowWrap==="break-word"||n.overflowWrap==="anywhere"?n.overflowWrap:"normal",whiteSpace:n.whiteSpace==="normal"||n.whiteSpace==="nowrap"||n.whiteSpace==="pre"||n.whiteSpace==="pre-line"||n.whiteSpace==="break-spaces"?n.whiteSpace:"pre-wrap",shapeInsideGeometry:H,shapePadding:typeof n.shapePadding=="number"?n.shapePadding:0}):null,xe=re?.lines??j.lines,Ze=n.linePositions,rt=c*j.lineHeight,Rt="";return xe.forEach((lt,Ve)=>{lt.segments.forEach((E,z)=>{let B="";if(z===0){let se=re?.shapeInsideLineXOffsets[Ve];if(H&&se!==void 0)B+=D("x",se),B+=D("y",H.bounds.minY+c+Ve*rt);else if(Ze?.[Ve]){let me=Ze[Ve];(Math.abs(me.x)>.001||Ve>0)&&(B+=D("x",r+me.x)),(Math.abs(me.dy)>.001||Ve>0)&&(B+=D("dy",me.dy))}else Ve>0&&(B+=D("x",r),B+=D("dy",`${rt}px`))}for(let{name:se,value:me}of au(E.style,j.baseStyle))B+=D(se,me);B+=' xml:space="preserve"',Rt+=`<tspan${B}>${fe(jr(E.text||(re?"\u200B":""),E.style.textTransform))}</tspan>`})}),`<text${k}>${Rt}</text>`}let F=n.authoredTextStructure;if(F?.text===s&&F.spans.length>0){let j=0,H="",oe=!0;for(let re of F.spans){if(!Number.isInteger(re.start)||!Number.isInteger(re.end)||re.start<j||re.end<=re.start||re.end>s.length||!re.id){oe=!1;break}H+=fe(jr(s.slice(j,re.start),n.textTransform)),H+=`<tspan${D("id",re.id)}>${fe(jr(s.slice(re.start,re.end),n.textTransform))}</tspan>`,j=re.end}if(oe)return H+=fe(jr(s.slice(j),n.textTransform)),`<text${k}>${H}</text>`}return`<text${k}>${fe(a)}</text>`}function Gg(t){let e=t.state,n=Dt(t,"path"),r=n.defaultPivot?Un(e,n.defaultPivot):null;return`<path${D("d",n.d)}${yn(e,t.id)}${Dg(e)}${r?D("transform",r):""}/>`}function Vg(t){let e=t.state,{points:n,closed:r,defaultPivot:i}=Dt(t,"polyline"),o=n.map(c=>`${c.x},${c.y}`).join(" "),s=i?Un(e,i):null;return`<${r?"polygon":"polyline"}${D("points",o)}${yn(e,t.id)}${Dg(e)}${s?D("transform",s):""}/>`}function jg(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=Dt(t,"positioning-rect"),a=e.href??"",c=e.imageOpacity,l=e.specPreserveAspectRatio||(e.preserveAspectRatio?"xMidYMid meet":"none"),d=Un(e,s??void 0);return`<image${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${D("href",a)}${D("preserveAspectRatio",l)}${c!==void 0&&c<1?D("opacity",c):""}${yn(e,t.id)}${d?D("transform",d):""}/>`}function Ug(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=Dt(t,"positioning-rect"),a=e.rawContent??"",c=Un(e,s??void 0);return`<foreignObject${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${yn(e,t.id)}${c?D("transform",c):""}>${a}</foreignObject>`}function uu(t,e){return!t||t.length===0?"":t.map(n=>on(n,e)).join("")}function mI(t){let e=t.state,n="",r=Ii(e),i=na.filter(o=>IO.has(o.id)).flatMap(o=>Id(o,r,{shapeId:t.id,includeAuthoredAttributes:!0,includeContainerPresentation:!0}));return n+=fI(i),n}function gI(t){let e=pI(t);return(e?D("transform",e):"")+mI(t)}function PO(t,e){let n=t.state,r=n.href,i=n.hrefXlink,o="<a";return r!==void 0&&(o+=D("href",r)),i!==void 0&&(o+=D("xlink:href",i)),o+=D("target",n.linkTarget),o+=D("rel",n.linkRel),n.linkDownload===""?o+=' download=""':o+=D("download",n.linkDownload),o+=D("ping",n.linkPing),o+=D("hreflang",n.linkHreflang),o+=D("type",n.linkType),o+=D("referrerpolicy",n.linkReferrerPolicy),o+=gI(t),o+=D("data-shape-id",t.id),o+=">",o+=du(n),o+=uu(n.children,e),o+="</a>",o}function TO(t,e){let n=t.state,r="<switch";return r+=Mo("systemLanguage",n.switchSystemLanguage),r+=Mo("requiredExtensions",n.switchRequiredExtensions),r+=gI(t),r+=D("data-shape-id",t.id),r+=">",r+=du(n),r+=uu(n.children,e),r+="</switch>",r}function RO(t,e){let n=t.state,r=pI(t),i="<g";i+=D("data-shape-id",t.id),r&&(i+=D("transform",r)),n.opacity!==void 0&&n.opacity<1&&(i+=D("opacity",n.opacity)),n.visibility&&(i+=D("visibility",n.visibility));let o=n.groupData,s=[];if(n.blendMode&&s.push(`mix-blend-mode:${n.blendMode}`),o){let a=o;if(a.clipPath&&(i+=D("clip-path",a.clipPath)),a.mask&&(i+=D("mask",a.mask)),a.filter&&(i+=D("filter",a.filter)),a.fill&&(i+=D("fill",a.fill)),a.fillOpacity&&(i+=D("fill-opacity",a.fillOpacity)),a.strokeOpacity&&(i+=D("stroke-opacity",a.strokeOpacity)),a.opacity&&n.opacity===void 0&&(i+=D("opacity",a.opacity)),Array.isArray(a.classes)&&a.classes.length>0&&(i+=D("class",a.classes.join(" "))),a.attributes)for(let[c,l]of Object.entries(a.attributes))/^[A-Za-z_][\w:.-]*$/.test(c)&&(new RegExp(`\\s${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=`).test(i)||(i+=D(c,l)));a.cssFilter&&s.push(`filter:${a.cssFilter}`),a.mixBlendMode&&!n.blendMode&&s.push(`mix-blend-mode:${a.mixBlendMode}`),a.isolation&&s.push(`isolation:${a.isolation}`),a.transformOrigin&&s.push(`transform-origin:${a.transformOrigin}`)}return s.length>0&&(i+=D("style",s.join(";"))),i+=">",i+=uu(n.children,e),i+="</g>",i}function CO(t){let e=t.state,n=Dt(t,"view"),r=n.viewBoxX,i=n.viewBoxY,o=n.viewBoxWidth,s=n.viewBoxHeight,a=r!==void 0&&i!==void 0&&o!==void 0&&s!==void 0?`${r} ${i} ${o} ${s}`:void 0,c="<view";return c+=D("id",t.id),c+=D("viewBox",a),c+=D("preserveAspectRatio",n.preserveAspectRatio),c+=D("zoomAndPan",e.viewZoomAndPan),c+=D("viewTarget",e.viewTarget),e.viewName&&(c+=D("data-view-name",e.viewName)),c+="/>",c}function $O(t,e){let n=t.state,r=Dt(t,"embedded-svg"),i=Gr(t);i.pivotRequired&&!i.pivotResolved&&Bt({severity:"warning",code:"unresolved-svg-viewport",shapeId:t.id,message:`Embedded SVG ${t.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`});let o=r.x,s=r.y,a=r.width,c=r.height,l=r.viewBoxX,d=r.viewBoxY,u=r.viewBoxWidth,p=r.viewBoxHeight,f=l!==void 0&&d!==void 0&&u!==void 0&&p!==void 0?`${l} ${d} ${u} ${p}`:void 0,m="<svg";return m+=D("xmlns","http://www.w3.org/2000/svg"),m+=D("x",o),m+=D("y",s),m+=D("width",a),m+=D("height",c),m+=D("viewBox",f),r.preserveAspectRatio!==void 0&&(m+=Mo("preserveAspectRatio",r.preserveAspectRatio)),i.attribute&&(m+=D("transform",i.attribute)),m+=mI(t),m+=D("data-shape-id",t.id),m+=">",m+=du(n),m+=uu(n.children,e),m+="</svg>",m}function NO(t,e){let n=t.state,r=Dt(t,"shape-reference"),i=r.targetShapeId;if(!i?.trim())return Bt({severity:"warning",code:"unresolved-reference",shapeId:t.id,message:`Shape reference ${t.id} has no targetShapeId and was not rendered.`}),`<!-- shape-reference ${fe(t.id)} has no targetShapeId -->`;let o=r.offsetX,s=r.offsetY,a=e?.shapeReferenceTargetElementId?.(i);if(a===null)return Bt({severity:"error",code:"duplicate-shape-id",shapeId:t.id,message:`Shape reference ${t.id} targets ambiguous duplicate id ${i}.`}),`<!-- shape-reference ${fe(t.id)} has ambiguous target ${fe(i)} -->`;let c=a??i,l=e?.shapeReferenceBounds?.(t),d=l?.diagnostics.find(h=>h.code==="reference-cycle");if(d&&Bt({severity:"warning",code:"reference-cycle",shapeId:t.id,message:d.message}),l?.status==="cycle"&&l.bounds===null)return`<!-- cyclic shape-reference ${fe(t.id)} was not rendered -->`;let u=e?.shapeReferenceTransform?.(t),p=u?.pivotRequired??Lt(t.state),f=u?.pivotResolved??!p;p&&!f&&Bt({severity:"warning",code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`});let m=u?.attribute??bt(t.state),g="<use";return g+=D("href",`#${c}`),g+=D("x",o),g+=D("y",s),r.width!==void 0&&(g+=D("width",r.width)),r.height!==void 0&&(g+=D("height",r.height)),g+=D("data-shape-id",t.id),m&&(g+=D("transform",m)),n.opacity!==void 0&&n.opacity<1&&(g+=D("opacity",n.opacity)),g+="/>",g}function Hg(t,e){let n=t.state,r=Dt(t,"symbol-instance"),i=e?.symbolInstanceTargetElementId?.(t),o=i===void 0?r.targetId:i;if(o===null)return`<!-- Invalid symbol instance: ${fe(t.id)} -->`;let s=e?.symbolDefKind?.(r.symbolId),a=`<use href="#${fe(o)}"`,c=n.authoredUseGeometry;c&&typeof c=="object"&&(c.x!==void 0&&(a+=D("x",c.x)),c.y!==void 0&&(a+=D("y",c.y)),(s===void 0||s==="symbol")&&(c.width!==void 0&&(a+=D("width",c.width)),c.height!==void 0&&(a+=D("height",c.height)))),a+=D("data-shape-id",t.id);let l=n.instancePresentation;if(l)for(let[g,h]of Object.entries(l))g!=="transform"&&(h==null||h===""||/^[A-Za-z_][\w:.-]*$/.test(g)&&(a+=D(g,h)));let d=e?.symbolInstanceTransform?.(t),u=bt(n),p=l?.transform?.trim(),f=p?u?`${p} ${u}`:p:u,m=d?.attribute??f;return m&&(a+=D("transform",m)),`${a}/>`}function AO(t){let e=t.state,n=Dt(t,"positioning-rect"),r=e.mediaKind??t.type,i=e.href??"",o=e.mediaMimeType,s=e.posterHref,a=e.mediaOpacity,c=`<${r} xmlns="http://www.w3.org/1999/xhtml"`;c+=D("src",i),o&&(c+=D("type",o)),s&&r==="video"&&(c+=D("poster",s)),e.muted&&(c+=' muted=""'),e.loop&&(c+=' loop=""'),e.playbackRate!==void 0&&(c+=D("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(c+=D("data-volume",e.volume)),c+=' preload="auto" playsinline=""',c+=r==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let l="<foreignObject";return l+=D("x",n.x),l+=D("y",n.y),l+=D("width",n.width),l+=D("height",n.height),l+=D("data-shape-id",t.id),l+=D("data-media-kind",r),e.naturalDuration!==void 0&&(l+=D("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(l+=D("data-begin",e.begin)),e.trimStart!==void 0&&(l+=D("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(l+=D("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(l+=D("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(l+=D("data-fade-out",e.fadeOutDuration)),l+=Mo("systemLanguage",e.systemLanguage),l+=Mo("requiredExtensions",e.requiredExtensions),a!==void 0&&a<1&&(l+=D("opacity",a)),l+=">",l+=c,l+="</foreignObject>",l}function Wg(t){let e=t.state,n=Dt(t,"path"),r=n.defaultPivot?Un(e,n.defaultPivot):null;return`<path${D("d",n.d)}${yn(e,t.id)}${r?D("transform",r):""}/>`}function Kg(t){let e=t.state;if(Xi(t.type)?.renderer!=="polygon")return Bt({severity:"warning",code:"unsupported-polygon-type",message:`Unsupported polygon shape type "${t.type}" on shape "${t.id}"; the shape was dropped from the rendered output`,shapeId:t.id}),`<!-- unsupported polygon shape: ${fe(t.type)} -->`;let r=Dt(t,"path"),i=r.placement??{x:0,y:0},o=vO(e,i.x,i.y),s=r.fillRule?D("fill-rule",r.fillRule):"";return`<path${D("d",r.d)}${s}${yn(e,t.id)}${D("transform",o)}/>`}var EO={circle:zg,ellipse:_g,rectangle:Fg,line:Lg,text:Bg,path:Gg,polyline:Vg,image:jg,polygon:Kg,flowchart:Wg,hyperlink:PO,switch:TO,container:RO,view:CO,svg:$O,"shape-reference":NO,"symbol-instance":Hg,media:AO,"foreign-object":Ug};function on(t,e){let n=Xi(t.type);if(!n)return Bt({severity:"warning",code:"unsupported-shape-type",message:`Unsupported shape type "${t.type}" on shape "${t.id}"; the shape was dropped from the rendered output`,shapeId:t.id}),`<!-- unsupported shape type: ${fe(t.type)} -->`;let r=EO[n.renderer](t,e);r=OO(r,t),r=wO(r,t.state),e?.forcedElementIds?.has(t.id)&&(r=hI(r,t.id));let i=e?.elementIdForShape?.(t);i&&(r=MO(r,i));let o=e?.animationElementsForShape?.(t);o&&o.length>0&&(r=kO(r,o));let s=t.state?.leadingComments;return Array.isArray(s)&&s.length>0&&(r=s.map(c=>`<!--${c.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")+r),r}function hI(t,e){let n=Pa(t);if(!n)return t;let r=t.slice(n.openStart,n.openEnd);if(/\sid=/.test(r))return t;let i=n.openStart+1+n.tagName.length;return`${t.slice(0,i)}${D("id",e)}${t.slice(i)}`}function MO(t,e){let n=Pa(t);if(!n)return t;let r=t.slice(n.openStart,n.openEnd),i=/\sid=("[^"]*"|'[^']*')/.exec(r);if(!i)return hI(t,e);let o=n.openStart+i.index;return`${t.slice(0,o)}${D("id",e)}${t.slice(o+i[0].length)}`}function OO(t,e){let n=e.state?.authoredAttributes;if(!n)return t;let r=/^<([A-Za-z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(t);if(!r)return t;let[i,o,s,a]=r,c="";for(let[l,d]of Object.entries(n))d===null||!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)||new RegExp(`\\s${l}\\s*=`).test(s)||(c+=` ${l}="${fe(d)}"`);return c?`<${o}${s}${c}${a}>`+t.slice(i.length):t}function yI(t){let e="",n=new Set,r=i=>{if(i&&typeof i=="object"&&"id"in i){let o=i.id;return typeof o=="string"?o:void 0}};for(let i of t){let o=i.state,s=zm(o),a=Qv(o),c=o.strokeType??"solid",l=o.strokeGradient;if(s==="linear-gradient"&&a){let d=r(a);d&&!n.has(d)&&(e+=Oo(d,a),n.add(d))}if(s==="radial-gradient"&&a){let d=r(a);d&&!n.has(d)&&(e+=Do(d,a),n.add(d))}if(s==="pattern"&&a){let d=r(a);d&&!n.has(d)&&(e+=lu(d,a),n.add(d))}if(c==="linear-gradient"&&l){let d=r(l);d&&!n.has(d)&&(e+=Oo(d,l),n.add(d))}if(c==="radial-gradient"&&l){let d=r(l);d&&!n.has(d)&&(e+=Do(d,l),n.add(d))}if(c==="pattern"&&l){let d=r(l);d&&!n.has(d)&&(e+=lu(d,l),n.add(d))}}return e}function Oo(t,e,n){return SI(fd(t,e),n)}function Do(t,e,n){return SI(md(t,e),n)}function SI(t,e){let n=t.attributes.map(([o,s])=>D(o,s)).join(""),r=String(t.attributes.find(([o])=>o==="id")?.[1]??""),i=t.stops.map((o,s)=>{let a=o.attributes.map(([l,d])=>D(l,d)).join(""),c=e?.gradientStopAnimationElements?.(r,s)??[];return c.length>0?`<stop${a}>${c.join("")}</stop>`:`<stop${a}/>`}).join("");return`<${t.element}${n}>${i}</${t.element}>`}function lu(t,e){let n=pd(t,e);return`<pattern${n.attributes.map(([i,o])=>D(i,o)).join("")}>${n.content}</pattern>`}function pu(t,e=[]){let n=Array.isArray(t)?yi(t,e):t;if(n.ids.size===0&&n.legacyEndpoints.size===0)return"";let r="",i=$i();for(let o of i){let s=o.id,a=s.replace("line-marker-",""),c=`mkr-builtin-${a}`,l=n.legacyEndpoints.has(a)||n.ids.has(s),d=n.ids.has(c);if(!l&&!d)continue;let u=o.element,p=Object.entries(u.attrs).map(([g,h])=>D(g,h)).join(""),f=`<${u.tag}${p}/>`,m=g=>{r+=`<marker${D("id",g)}${D("viewBox",Ia)}${D("refX",o.refX)}${D("refY",o.refY)}${D("markerWidth",6)}${D("markerHeight",6)}${D("orient","auto-start-reverse")}>${f}</marker>`};l&&m(s),d&&m(c)}return r}var kt=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Xg(t){let e=tn(`<svg xmlns="${K}" xmlns:xlink="http://www.w3.org/1999/xlink">${t}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value;return e?new Set(e.index.localReferences.map(n=>n.targetAuthoredId)):new Set}function fu(t){let e=new Set,n=r=>{for(let i of _n(r))e.add(i.targetAuthoredId)};for(let r of t.documentStyles??[])n(r.css);for(let r of t.animationTimeline?.tracks??[])for(let i of r.keyframes)typeof i.value=="string"&&n(i.value);for(let r of t.clipMaskGroups??[])if(r.rawDefinition)for(let i of Xg(r.rawDefinition))e.add(i);return e}var Yg=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Hn(t){let e=new Map;for(let n of t)n.kind==="symbol"&&e.set(n.id,n.defKind??"symbol");return{symbolDefKind:n=>e.get(n)}}function Ta(t,e){switch(t.kind){case"symbol":return Ra(t,e);case"marker":return qg(t,e);case"linear-gradient":return Zg(t,e);case"radial-gradient":return Jg(t,e);case"pattern":return Qg(t);case"filter":return eh(t)}}function Ra(t,e){return zo(t,t.id,t.shapes,e)}var bI=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function vI(t,e){let n=t.rootAttributes??{},r="";if(e)for(let i of bI){let o=t[i];o!==void 0&&(r+=` ${i}="${kt(o)}"`)}for(let[i,o]of Object.entries(n))i==="id"||bI.includes(i)||/^[A-Za-z_][\w:.-]*$/.test(i)&&(r+=` ${i}="${kt(o)}"`);return r}function zo(t,e,n,r){if((t.defKind??"symbol")==="shape"){let[o]=n;if(!o||n.length!==1)return`<!-- invalid native-shape definition: ${kt(e)} -->`;let s={...o,state:{...o.state,authoredAttributes:{...o.state.authoredAttributes??{},...t.rootAttributes??{}},...t.metadata?{metadata:{...o.state.metadata??{},...t.metadata}}:{}}};return on(s,{...r,elementIdForShape:a=>a.id===s.id?e:r?.elementIdForShape?.(a)})}let i=mo(t.metadata)+n.map(o=>on(o,r)).join("");return(t.defKind??"symbol")==="group"?`<g id="${kt(e)}"${vI(t,!1)}>${i}</g>`:`<symbol id="${kt(e)}"${vI(t,!0)}>${i}</symbol>`}function qg(t,e){let n;if(t.builtIn){let a=$i().find(c=>t.id.includes(c.id)||t.id===c.id);if(a){let c=Object.entries(a.element.attrs).map(([l,d])=>` ${l}="${kt(String(d))}"`).join("");n=`<${a.element.tag}${c}/>`}else n=""}else n=t.shapes.map(a=>on(a,e)).join("");let r=t.authoredGeometry??{},i={refX:r.refX??String(t.refX),refY:r.refY??String(t.refY),markerWidth:r.markerWidth??String(t.markerWidth),markerHeight:r.markerHeight??String(t.markerHeight),markerUnits:r.markerUnits??t.markerUnits,orient:r.orient??(typeof t.orient=="number"?String(t.orient):t.orient)},o="";t.viewBox!==void 0&&(o+=` viewBox="${kt(t.viewBox)}"`),t.preserveAspectRatio!==void 0&&(o+=` preserveAspectRatio="${kt(t.preserveAspectRatio)}"`);let s=new Set(["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"]);for(let[a,c]of Object.entries(t.rootAttributes??{}))s.has(a)||!/^[A-Za-z_][\w:.-]*$/.test(a)||(o+=` ${a}="${kt(c)}"`);return t.overflow!==void 0&&t.rootAttributes?.overflow===void 0&&(o+=` overflow="${kt(t.overflow)}"`),n=mo(t.metadata)+n,`<marker id="${kt(t.id)}"${o} refX="${kt(i.refX)}" refY="${kt(i.refY)}" markerWidth="${kt(i.markerWidth)}" markerHeight="${kt(i.markerHeight)}" markerUnits="${kt(i.markerUnits)}" orient="${kt(i.orient)}">${n}</marker>`}function Zg(t,e){let n={...t.gradient,type:"linear-gradient",id:t.id};return mu(Oo(t.id,n,e),t.metadata)}function Jg(t,e){let n={...t.gradient,type:"radial-gradient",id:t.id};return mu(Do(t.id,n,e),t.metadata)}function Qg(t){let e={...t.pattern,type:"pattern",id:t.id};return mu(lu(t.id,e),t.metadata)}function eh(t){return mu(ea(t.id,t.filters,{colorInterpolation:t.colorInterpolation,filterUnits:t.filterUnits,primitiveUnits:t.primitiveUnits,x:t.x,y:t.y,width:t.width,height:t.height}),t.metadata)}function mu(t,e){let n=mo(e);if(!n)return t;let r=t.match(/^<([\w:-]+)([^>]*)\/>$/u);if(r)return`<${r[1]}${r[2]}>${n}</${r[1]}>`;let i=t.indexOf(">");return i<0?t:t.slice(0,i+1)+n+t.slice(i+1)}function Ca(t,e){let n=new Map;for(let o of t){let s=n.get(o.kind);s?s.push(o):n.set(o.kind,[o])}let r=e??Hn(t),i="";for(let o of Yg){let s=n.get(o);if(s)for(let a of s)i+=Ta(a,r)}return i}function xI(t,e){let n=$a(t,e);return n.length===0?"":Ca(n,Hn(e))}function $a(t,e,n=[]){let r=new Map;for(let d of e)r.set(d.id,d);let i=new Map,o=d=>{if(!d)return;let u=r.get(d);u&&i.set(d,u)},s=(d,u)=>{if(!d||typeof d!="object")return;let p=d;if(!p.id||i.has(p.id))return;let f=u==="linear-gradient"?"linear-gradient":u==="radial-gradient"?"radial-gradient":u==="pattern"?"pattern":null;if(!f)return;let{id:m,sourceId:g,...h}=d,y;if(f==="linear-gradient")y={kind:"linear-gradient",id:p.id,name:g??p.id,sourceId:g,gradient:h};else if(f==="radial-gradient")y={kind:"radial-gradient",id:p.id,name:g??p.id,sourceId:g,gradient:h};else{let{customPatternId:b,...v}=h;y={kind:"pattern",id:p.id,name:g??p.id,sourceId:g,pattern:v}}i.set(p.id,y)},a=(d,u)=>{let p=d.filters;if(!Array.isArray(p)||p.length===0)return;let f=`filter-${u}`;i.has(f)||i.set(f,{kind:"filter",id:f,name:f,filters:p,...d.filterColorInterpolation&&d.filterColorInterpolation!=="auto"?{colorInterpolation:d.filterColorInterpolation}:{},...d.filterUnits?{filterUnits:d.filterUnits}:{},...d.primitiveUnits?{primitiveUnits:d.primitiveUnits}:{},...typeof d.filterX=="string"?{x:d.filterX}:{},...typeof d.filterY=="string"?{y:d.filterY}:{},...typeof d.filterWidth=="string"?{width:d.filterWidth}:{},...typeof d.filterHeight=="string"?{height:d.filterHeight}:{}})},c=d=>{let u=d.state;if(!u)return;if(o(u.fillLibraryId),o(u.strokeLibraryId),o(u.markerStart),o(u.markerMid),o(u.markerEnd),d.type==="symbol-instance"){let f=u.symbolId;f&&Wi(d)===f&&o(f)}else o(u.symbolId);let p=u.filterLibraryIds;if(Array.isArray(p))for(let f of p)typeof f=="string"&&o(f);u.fillLibraryId||s(u.fillGradient,u.fillType),u.strokeLibraryId||s(u.strokeGradient,u.strokeType),(!Array.isArray(p)||p.length===0)&&a(u,d.id)};for(let d of t)c(d);let l=Array.from(n);for(let d of l)o(d);return Bs(t,e,c),vl(l,e,c),Array.from(i.values())}function II(t){let e=new Map,n=(s,a)=>{let c=s.type??a;return c==="linear-gradient"||c==="radial-gradient"||c==="pattern"?c:null},r=(s,a,c)=>{if(typeof s!="string"||s.length===0||!a||typeof a!="object"||e.has(s))return;let l=a,d=n(l,c);if(!d)return;let{id:u,sourceId:p,type:f,...m}=l,g=typeof p=="string"?p:s;if(d==="linear-gradient")e.set(s,{kind:d,id:s,name:g,...typeof p=="string"?{sourceId:p}:{},gradient:m});else if(d==="radial-gradient")e.set(s,{kind:d,id:s,name:g,...typeof p=="string"?{sourceId:p}:{},gradient:m});else{let{customPatternId:h,...y}=m;e.set(s,{kind:"pattern",id:s,name:g,...typeof p=="string"?{sourceId:p}:{},pattern:y})}},i=s=>{let a=s.filterLibraryIds;if(!Array.isArray(a)||a.length!==1||typeof a[0]!="string")return;let c=a[0],l=s.filters;!Array.isArray(l)||l.length===0||e.has(c)||e.set(c,{kind:"filter",id:c,name:c,filters:l,...s.filterColorInterpolation&&s.filterColorInterpolation!=="auto"?{colorInterpolation:s.filterColorInterpolation}:{},...s.filterUnits?{filterUnits:s.filterUnits}:{},...s.primitiveUnits?{primitiveUnits:s.primitiveUnits}:{},...typeof s.filterX=="string"?{x:s.filterX}:{},...typeof s.filterY=="string"?{y:s.filterY}:{},...typeof s.filterWidth=="string"?{width:s.filterWidth}:{},...typeof s.filterHeight=="string"?{height:s.filterHeight}:{}})},o=s=>{let a=s.state;if(!a)return;r(a.fillLibraryId,a.fillGradient,a.fillType),r(a.strokeLibraryId,a.strokeGradient,a.strokeType),i(a);let c=a.children;if(Array.isArray(c))for(let l of c)o(l)};for(let s of t)o(s);return Array.from(e.values())}var DO=new Set(["id","href","xlink:href","fill","stroke","stop-color","flood-color","lighting-color","color","solid-color","text-decoration-color","caret-color","class","font-family","lang","xml:lang","style","keyTimes","keyPoints","keySplines","gradientTransform"]),CI=/([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function th(t,e){return t.length===0?t:t.replace(CI,(n,r,i)=>{if(DO.has(r)||r==="xmlns"||r.startsWith("xmlns:")||r.startsWith("data-")||!/\d/.test(i)||i.includes("url(")||i.charCodeAt(0)===35)return n;let o=va(i,e);return o===i?n:`${r}="${o}"`})}var _o=/<\/?([A-Za-z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g;function Bo(t){let e=[],n=0,r=0,i="";_o.lastIndex=0;let o;for(;(o=_o.exec(t))!==null;){let s=o[0].startsWith("</"),a=o[3]==="/";if(s){if(n=Math.max(0,n-1),n===0){let c=t.slice(r,_o.lastIndex);e.push({markup:c,tag:i,id:wI(c)}),r=_o.lastIndex,i=""}continue}if(n===0&&(i=o[1].toLowerCase()),!a)n++;else if(n===0){let c=t.slice(r,_o.lastIndex);e.push({markup:c,tag:i,id:wI(c)}),r=_o.lastIndex,i=""}}if(r<t.length){let s=t.slice(r);s.trim().length>0&&e.push({markup:s,tag:"",id:null})}return e}function zO(t,e){let n=(e.paintServerDefs??[]).filter(u=>Array.isArray(u.definitionChildIds)&&u.definitionChildIds.length>0);if(n.length===0)return t;let r=new Map,i=new Map;for(let u of ur){let p=Bo(t.defs[u]);r.set(u,p),p.forEach((f,m)=>{!f.id||i.has(f.id)||i.set(f.id,{channel:u,index:m,segment:f,key:`${u}:${m}`})})}let o=new Map(n.map(u=>[u.id,u])),s=new Set,a=new Map,c=new Map,l=(u,p)=>{let f=c.get(u);if(f)return f;if(p.has(u))return null;let m=o.get(u),g=i.get(u);if(!m||!g)return null;let h=g.segment.markup,y=h.indexOf(">"),b=h.lastIndexOf("</");if(y<0||b<=y)return h;let v=h.slice(y+1,b),I=m.sourceDefinitionChildIds??m.definitionChildIds,x=m.definitionChildIds,k=new Map(I.map((N,R)=>[N,R])),T=new Set(p);T.add(u);let w=Bo(v).map(N=>{if(!N.id)return N.markup;let R=k.get(N.id);if(R===void 0)return N.markup;let $=x[R],A=i.get($);if(!A||A.key===g.key)return N.markup;let O=o.has($)?l($,T):A.segment.markup;return O?(s.add(A.key),N.markup.slice(0,N.markup.indexOf("<"))+O.trimStart()):N.markup}).join(""),P=h.slice(0,y+1)+w+h.slice(b);return c.set(u,P),P};for(let u of n){let p=i.get(u.id);if(!p)continue;let f=l(u.id,new Set);f&&a.set(p.key,f)}let d={...t.defs};for(let u of ur)d[u]=(r.get(u)??[]).map((p,f)=>{let m=`${u}:${f}`;return s.has(m)?"":a.get(m)??p.markup}).join("");return{...t,defs:d}}function wI(t){let e=/^[^>]*>/.exec(t.trimStart()),n=e?e[0]:t,r=/\sid\s*=\s*"([^"]*)"/.exec(n);return r?r[1]:null}function hu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Na(t,e){if(e.size===0||t.length===0)return t;let n=t;for(let[r,i]of e){let o=hu(r);n=n.replace(new RegExp(`url\\(\\s*(['"]?)#${o}\\1\\s*\\)`,"g"),(s,a)=>`url(${a}#${i}${a})`),n=n.replace(new RegExp(`((?:xlink:)?href\\s*=\\s*)(["'])#${o}\\2`,"g"),(s,a,c)=>`${a}${c}#${i}${c}`)}return n}function _O(t,e,n){return t.replace(new RegExp(`(\\sid\\s*=\\s*")${hu(e)}(")`),`$1${n}$2`)}var ur=["library","builtinMarkers","symbols","motionPaths","paintServers","clipMask","inlineHoisted"];function gu(t,e){let n={...t.defs};for(let r of ur)n[r]=e(n[r]);return{...t,defs:n,backgroundRect:e(t.backgroundRect),body:t.body.map(r=>r.kind==="shape"?{...r,markup:e(r.markup)}:{...r,open:e(r.open),close:e(r.close),members:r.members.map(i=>({...i,markup:e(i.markup)}))}),envelope:{...t.envelope}}}function $I(t,e){let n=gu(t,e);return{...n,envelope:{...n.envelope,styles:e(n.envelope.styles)}}}function FO(t){let e=new Set,n=/\sid\s*=\s*"([^"]*)"/g,r=i=>{n.lastIndex=0;let o;for(;(o=n.exec(i))!==null;)e.add(o[1])};for(let i of ur)r(t.defs[i]);for(let i of t.body)if(i.kind==="shape")r(i.markup);else{r(i.open);for(let o of i.members)r(o.markup)}return r(t.envelope.descriptive),e}function LO(t,e){let n=e.library??[];if(n.length===0)return t;let r=FO(t),i=new Map,o=new Set;for(let c of n){let l=c.sourceId,d=c.id;!l||!d||l===d||o.has(l)||r.has(l)||r.has(d)&&(i.set(d,l),o.add(l))}if(i.size===0)return t;let s=$I(t,c=>Na(c,i)),a={...s.defs};for(let c of ur){let l=a[c];for(let[d,u]of i)l=_O(l,d,u);a[c]=l}return{...s,defs:a}}var NI=new Set(["circle","ellipse","g","image","line","lineargradient","path","polygon","polyline","radialgradient","rect","pattern","marker","symbol","text"]),BO=new Set(["circle","ellipse","image","line","path","polygon","polyline","rect","text"]),GO=new Set(["defs","g"]);function AI(t,e,n){let r=e;n&&(r=r.replace(new RegExp(`\\sid\\s*=\\s*"${hu(n)}"`),""));let i=[];if(NI.has(t)&&!["lineargradient","radialgradient","pattern","marker"].includes(t)){r=r.replace(/\sxmlns:svg="http:\/\/www\.w3\.org\/2000\/svg"/g,"").replace(/\sxmlns:xlink="http:\/\/www\.w3\.org\/1999\/xlink"/g,"");let o=/\sid\s*=\s*"([^"]*)"/g,s;for(;(s=o.exec(r))!==null;)s[1]!==""&&i.push(s[1]);let a=new Map;i.forEach((l,d)=>a.set(l,`__local_${d}`)),r=Na(r,a);for(let[l,d]of a)r=r.replace(new RegExp(`(\\sid\\s*=\\s*")${hu(l)}(")`,"g"),`$1${d}$2`);let c=0;r=r.replace(/\s(data-shape-id|data-svgsketch-inner-id)\s*=\s*"[^"]*"/g,(l,d)=>` ${d}="__shape_${c++}"`),r=Lo(r,[{}])}return{hash:r.replace(/\s+/g," ").trim(),localIds:i}}function yu(t,e=[t]){let n=Ra(t,Hn(e.includes(t)?e:[...e,t])),r=Bo(n).find(o=>o.id===t.id);if(!r)return`invalid|${n}`;let i=AI(r.tag,r.markup,r.id);return`${r.tag}|${i.hash}`}function EI(t){let e=new Map,n=new Map,r={...t.defs},i=!1,o=(l,d)=>{l.forEach((u,p)=>{let f=d[p];f!==void 0&&u!==f&&n.set(u,f)})},s=(l,d)=>{let u=[],p=Bo(l);for(let f of p){let m=f;if(GO.has(m.tag)){let b=m.markup.indexOf(">"),v=m.markup.toLowerCase().lastIndexOf(`</${m.tag}>`);if(b>=0&&v>b){let I=m.markup.slice(b+1,v),x=s(I,m.tag==="defs");if(x!==I&&(i=!0),m={...m,markup:m.markup.slice(0,b+1)+x+m.markup.slice(v)},m.tag==="defs"||!m.id){u.push(m.markup);continue}}}if(!NI.has(m.tag)||!m.id||!d&&BO.has(m.tag)){u.push(m.markup);continue}let g=AI(m.tag,m.markup,m.id),h=`${m.tag}|${g.hash}`,y=e.get(h);if(y===void 0){e.set(h,{id:m.id,localIds:g.localIds}),u.push(m.markup);continue}if(o(g.localIds,y.localIds),y.id===m.id){i=!0;continue}n.set(m.id,y.id),i=!0}return u.join("")};for(let l of ur)r[l]=s(r[l],!0);if(!i&&n.size===0)return t;let a={...t,defs:r},c=n.size===0?a:$I(a,l=>Na(l,n));return EI(c)}var VO=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","inherit","initial","unset","revert"]);function kI(t){return t.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").split(",")[0].trim().replace(/^['"]|['"]$/g,"").trim()}function nh(t){let e=new Set,n=r=>{if(!r.includes("font-family"))return;let i=/font-family\s*=\s*"([^"]*)"/g,o;for(;(o=i.exec(r))!==null;)e.add(kI(o[1]));let s=/font-family\s*:\s*([^;"}<]+)/g;for(;(o=s.exec(r))!==null;)e.add(kI(o[1]))};for(let r of ur)n(t.defs[r]);for(let r of t.body)if(r.kind==="shape")n(r.markup);else for(let i of r.members)n(i.markup);return n(t.envelope.styles),[...e].filter(r=>r&&!VO.has(r.toLowerCase()))}function jO(t,e){let n=nh(t);if(n.length===0)return t;let r=e(n);if(!r||r.trim().length===0)return t;let i=`<style type="text/css">
39
+ ${r.trim()}
40
+ </style>`;return{...t,envelope:{...t.envelope,styles:t.envelope.styles.length>0?`${i}
41
+ ${t.envelope.styles}`:i}}}var UO=new Set(["rect","image","svg","use","text"]),PI="Inter, sans-serif",HO=new Map([["stroke","stroke"],["stroke-width","strokeWidth"],["stroke-opacity","strokeOpacity"],["fill-opacity","fillOpacity"],["font-weight","fontWeight"],["font-style","fontStyle"],["text-anchor","textAnchor"],["font-family","fontFamily"]]);function Fo(t){let e=parseFloat(t);return Number.isFinite(e)&&Math.abs(e-1)<1e-6}function TI(t){let e=parseFloat(t);return Number.isFinite(e)&&e===0}function RI(t){return t===void 0||t==="normal"||t==="400"}var WO=/\s+([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function KO(t,e,n){let r=t.toLowerCase();if(r==="g")return e;let i=r==="image"||r==="foreignobject";return e.replace(WO,(o,s,a)=>{switch(s){case"stroke":return i||a==="none"&&(n.stroke===void 0||n.stroke==="none")?"":o;case"fill":return i?"":o;case"stroke-width":return i||Fo(a)&&(n.strokeWidth===void 0||Fo(n.strokeWidth))?"":o;case"stroke-opacity":return Fo(a)&&(n.strokeOpacity===void 0||Fo(n.strokeOpacity))?"":o;case"fill-opacity":return Fo(a)&&(n.fillOpacity===void 0||Fo(n.fillOpacity))?"":o;case"x":case"y":return UO.has(r)&&TI(a)?"":o;case"font-weight":return RI(a)&&RI(n.fontWeight)?"":o;case"font-style":return a==="normal"&&(n.fontStyle===void 0||n.fontStyle==="normal")?"":o;case"text-anchor":return a==="start"&&(n.textAnchor===void 0||n.textAnchor==="start")?"":o;case"font-family":return a===PI&&(n.fontFamily===void 0||n.fontFamily===PI)?"":o;case"orient":return r==="marker"&&TI(a)?"":o;case"markerUnits":return r==="marker"&&a==="strokeWidth"?"":o;default:return o}})}function Lo(t,e){if(t.length===0)return t;let n=/<(\/?)([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g,r="",i=0,o;for(;(o=n.exec(t))!==null;){let[s,a,c,l,d]=o;if(r+=t.slice(i,o.index),i=o.index+s.length,a==="/"){e.length>1&&e.pop(),r+=s;continue}let u=e[e.length-1],p=KO(c,l,u);if(r+=`<${c}${p}${d}>`,d!=="/"){let f={...u};l.replace(CI,(m,g,h)=>{let y=HO.get(g);return y&&(f[y]=h),m}),e.push(f)}}return r+=t.slice(i),r}function XO(t){let e={...t.defs};for(let i of ur)e[i]=Lo(e[i],[{}]);let n=[{}],r=t.body.map(i=>{if(i.kind==="shape")return{...i,markup:Lo(i.markup,n)};let o=Lo(i.open,n),s=i.members.map(c=>({...c,markup:Lo(c.markup,n)})),a=Lo(i.close,n);return{...i,open:o,members:s,close:a}});return{...t,defs:e,body:r}}function YO(t){let e="",n=i=>i.replace(/<defs>[\s\S]*?<\/defs>/g,o=>(e+=o.slice(6,-7),"")),r=t.body.map(i=>i.kind==="shape"?{...i,markup:n(i.markup)}:{...i,members:i.members.map(o=>({...o,markup:n(o.markup)}))});return e.length===0?t:{...t,body:r,defs:{...t.defs,inlineHoisted:t.defs.inlineHoisted+e}}}var qO=new Map([["xlink","http://www.w3.org/1999/xlink"],["dc","http://purl.org/dc/elements/1.1/"],["cc","http://creativecommons.org/ns#"],["rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["inkscape","http://www.inkscape.org/namespaces/inkscape"],["sodipodi","http://sodipodi.sourceforge.net/DTD/sodipodi-0.0.dtd"]]),ZO=new Set(["xml","xmlns"]);function JO(t){let e=new Set,n=new Map,r=/<(\/)?([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g,i=/(?:^|\s)([A-Za-z_][\w.-]*):([A-Za-z_][\w.-]*)\s*=/g,o=/(?:^|\s)xmlns:([A-Za-z_][\w.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,s=(u,p)=>{o.lastIndex=0;let f;for(;(f=o.exec(u))!==null;){let m=f[1],g=f[2]??f[3]??"";p.add(m);let h=n.get(m);h||(h=new Set,n.set(m,h)),h.add(g)}},a=(u,p)=>{i.lastIndex=0;let f;for(;(f=i.exec(u))!==null;)f[1]!=="xmlns"&&!p.has(f[1])&&e.add(f[1])},c=new Set(ZO);s(t.envelope.rootAttributes,c),a(t.envelope.rootAttributes,c);let l=u=>{if(u.length===0)return;let p=[new Set(c)];r.lastIndex=0;let f;for(;(f=r.exec(u))!==null;){if(f[1]){p.length>1&&p.pop();continue}let m=new Set(p[p.length-1]);s(f[3],m);let g=f[2].indexOf(":");if(g>0){let h=f[2].slice(0,g);m.has(h)||e.add(h)}a(f[3],m),f[4]||p.push(m)}};for(let u of ur)l(t.defs[u]);for(let u of t.body)u.kind==="shape"?l(u.markup):l(`${u.open}${u.members.map(p=>p.markup).join("")}</g>`);l(t.backgroundRect),l(t.envelope.descriptive),l(t.envelope.scripts),l(t.envelope.styles);let d=[];for(let u of e){let p=n.get(u),f=p?.size===1?[...p][0]:void 0,m=qO.get(u)??f;if(!m){Bt({severity:"warning",code:"undeclarable-namespace-prefix",message:`namespace prefix "${u}:" is used by emitted markup but is neither bound to one unambiguous preserved URI nor a well-known prefix; the output is not namespace-well-formed for this prefix`});continue}d.push(` xmlns:${u}="${m}"`)}return d.length===0?t:(d.sort(),{...t,envelope:{...t.envelope,rootAttributes:t.envelope.rootAttributes+d.join("")}})}function Su(t,e,n={}){let r=YO(t);if(r=zO(r,e),(n.restoreSourceIds??!0)&&(r=LO(r,e)),(n.deduplicateDefs??!0)&&(r=EI(r)),n.shapeIdAttributes===!1&&(r=gu(r,i=>i.replace(/\sdata-shape-id="[^"]*"/g,""))),r=gu(r,i=>i.replace(/\sdata-source-id="[^"]*"/g,"")),n.resolveFontEmbedCss&&(r=jO(r,n.resolveFontEmbedCss)),n.precision!==null){let i=nu(n.precision??e.documentMetadata?.coordinatePrecision??ba);r=gu(r,o=>th(o,i))}return(n.elideInitialValues??!0)&&(r=XO(r)),r=JO(r),r}var MI=new WeakMap;function QO(t){let e=MI.get(t);if(e)return e;let n=new Set(t.hierarchy.containers.map(r=>r.occurrenceId));return MI.set(t,n),n}function bu(t,e){for(let n of t){let r=n.state;typeof r.symbolId=="string"&&(r.symbolId=e.get(r.symbolId)??r.symbolId);let i=r.children;Array.isArray(i)&&bu(i,e)}}function eD(t,e){let n=[...t];for(;;){let r=new Map,i=new Map;for(let o of n){if(o.kind!=="symbol")continue;let s=yu(o,n),a=r.get(s);a?i.set(o.id,a):r.set(s,o.id)}if(i.size===0)return n;bu(e,i);for(let o of n)if(o.kind==="symbol"){bu(o.shapes,i);for(let s of Object.values(o.variants??{}))bu(s,i)}n=n.filter(o=>o.kind!=="symbol"||!i.has(o.id))}}var tD=new Set(["height","href","id","download","hreflang","ping","preserveaspectratio","referrerpolicy","rel","requiredextensions","systemlanguage","target","transform","type","viewbox","width","x","xlink:href","y"]),zI=new Set(["color","color-interpolation","color-rendering","display","fill","fill-opacity","fill-rule","filter","marker","marker-end","marker-mid","marker-start","mask","mix-blend-mode","opacity","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","image-rendering","transform-origin","isolation","vector-effect","visibility"]),nD=new Set([...zI,"mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","mix-blend-mode"]);function vu(t){if(t===null)return;let e=t.trim();if(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:px)?$/u.test(e))return;let n=Number(e.replace(/px$/iu,""));return Number.isFinite(n)?n:void 0}function rh(t){if(t===null)return;let e=t.trim(),n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/u.exec(e),r=n?Number(n[1])/100:vu(e);return r===void 0?void 0:Math.min(1,Math.max(0,r))}function Aa(t,e,n="auto"){if(t===null)return;let r=e.find(i=>i.toLowerCase()===t.trim().toLowerCase());return!r||r===n?void 0:r}function rD(t){if(t===null)return;let e=t.trim();if(!e||e.toLowerCase()==="none")return;if(/(?:^|[^-_a-z0-9])var\(/iu.test(e))return e;let n=ci(e),r=e.replace(/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:px|pt|pc|in|cm|mm|q|em|rem|%|ex|ch|vw|vh|vmin|vmax)?/giu,"").replace(/[\s,]+/gu,"");if(!(n.length===0||r||n.some(i=>i.value<0))&&!n.every(i=>i.value===0))return e}function iD(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=(t[r]??-1)-(e[r]??-1);if(i!==0)return i}return 0}function _I(t){let e=new Map(t.useOccurrences.occurrences.map(n=>[n.occurrenceId,n]));return[...new Set([...t.hierarchy.containers.map(n=>n.occurrenceId),...t.hierarchy.placements.map(n=>n.occurrenceId)])].map(n=>e.get(n)).filter(n=>n!==void 0).sort((n,r)=>iD(n.orderKey,r.orderKey)||n.productIndex-r.productIndex||n.occurrenceId.localeCompare(r.occurrenceId))}function oD(t){let e=new Set;for(let n of t.symbolUses.definitions){e.add(n.productRootOccurrenceId);for(let r of n.contentOccurrenceIds)e.add(r)}return e}function FI(t){let e=oD(t),n=new Set(["clippath","filter","lineargradient","marker","mask","pattern","radialgradient"]),r=new Map,i=new Map(t.useOccurrences.occurrences.map(a=>[a.occurrenceId,a]));for(let a of t.useOccurrences.occurrences){if(!a.parentOccurrenceId)continue;let c=r.get(a.parentOccurrenceId)??[];c.push(a),r.set(a.parentOccurrenceId,c)}let o=new Set;for(let a of t.symbolUses.uses){if(a.status!=="linked-reference")continue;let c=[...r.get(a.useOccurrenceId)??[]];for(;c.length>0;){let l=c.pop();o.has(l.occurrenceId)||(o.add(l.occurrenceId),c.push(...r.get(l.occurrenceId)??[]))}}let s=new Set;for(let a of t.useOccurrences.occurrences){let c=a,l=new Set;for(;c&&!l.has(c.occurrenceId);){l.add(c.occurrenceId);let d=t.sourceDocument.index.element(c.correspondingSourceNodeId);if(d&&n.has(d.localName.toLowerCase())){s.add(a.occurrenceId);break}c=c.parentOccurrenceId?i.get(c.parentOccurrenceId):void 0}}return _I(t).filter(a=>!e.has(a.occurrenceId)&&!o.has(a.occurrenceId)&&!s.has(a.occurrenceId))}function Wn(t,e){return e.replace(/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu,(n,r,i)=>{let o=t.identifiers.liveIdForSourceId(i);return o?`url(${r}#${o}${r})`:n})}function sD(t,e,n){let r=t.metadata.candidate(e.correspondingSourceNodeId)?.metadata;if(!r||Object.keys(r).length===0)return;let i=structuredClone(r),o=t.identifiers.liveIdForSourceNodeId(e.correspondingSourceNodeId);if(o&&typeof i.name=="string"&&(i.name=o),typeof i.name=="string"&&e.usePath.length>0){let s=(n.get(i.name)??0)+1;n.set(i.name,s),i.name=`${i.name}-use-${s}`}return i}function aD(t,e){let n=t.scripts.forParent(e).map(r=>({...r.script,customAttrs:r.script.customAttrs?{...r.script.customAttrs}:void 0}));return n.length>0?n:void 0}function cD(t,e,n=!1){let r={};for(let i of t.authoredAttributes.forElement(e)){let o=i.name.toLowerCase();if(i.classification==="style"){n&&(r[i.name]=Wn(t,i.value));continue}["namespace","metadata","aria","data","conditional","geometry","element-specific","foreign"].includes(i.classification)||i.classification==="presentation"&&nD.has(o)&&o!=="color"||tD.has(o)||(r[i.name]=Wn(t,i.value))}return r}function lD(t,e,n){let r=t.styles.style(e),i=v=>{let I=v.toLowerCase(),k=r?.specifiedValues[I]??r?.resolvedValues[I]??null;return k===null?null:n.rewriteValue(e,k)},o={},s=i("fill"),a=i("stroke"),c=t.useOccurrences.occurrence(e),l=c?.parentOccurrenceId?t.styles.style(c.parentOccurrenceId):null,d=r?.cascadedValues.fill!==void 0,u=r?.cascadedValues.stroke!==void 0;s!==null&&(o.fillColor=s==="black"&&r?.cascadedValues.fill===void 0?"#000000":Wn(t,s),s.trim().toLowerCase()==="none"&&(o.fillType="none")),a!==null&&a.trim().toLowerCase()!=="none"?o.borderColor=Wn(t,a):(o.borderColor="none",o.strokeType="none"),!d&&l&&l.resolvedValues.fill!==void 0&&l.resolvedValues.fill===r?.resolvedValues.fill&&(delete o.fillColor,delete o.fillType,o.inheritFill=!0),!u&&l&&l.resolvedValues.stroke!==void 0&&l.resolvedValues.stroke===r?.resolvedValues.stroke&&(o.borderColor="none",delete o.strokeType,o.inheritStroke=!0);let p=[["fillOpacity","fill-opacity",rh],["strokeOpacity","stroke-opacity",rh],["opacity","opacity",rh],["borderWidth","stroke-width",vu],["strokeMiterlimit","stroke-miterlimit",vu],["dashOffset","stroke-dashoffset",vu],["fillRule","fill-rule",v=>v??void 0],["strokeLinecap","stroke-linecap",v=>v??void 0],["strokeLinejoin","stroke-linejoin",v=>v??void 0],["strokeDasharray","stroke-dasharray",rD],["paintOrder","paint-order",v=>v??void 0],["vectorEffect","vector-effect",v=>v??void 0],["blendMode","mix-blend-mode",v=>v??void 0],["shapeRendering","shape-rendering",v=>Aa(v,["auto","optimizeSpeed","crispEdges","geometricPrecision"])],["textRendering","text-rendering",v=>Aa(v,["auto","optimizeSpeed","optimizeLegibility","geometricPrecision"])],["imageRendering","image-rendering",v=>Aa(v,["auto","optimizeSpeed","optimizeQuality","crisp-edges","pixelated","smooth","high-quality"])],["colorRendering","color-rendering",v=>Aa(v,["auto","optimizeSpeed","optimizeQuality"])],["colorInterpolation","color-interpolation",v=>Aa(v,["auto","sRGB","linearRGB"],"sRGB")]];for(let[v,I,x]of p){let k=r?.cascadedValues[I];if(!k&&["fill-opacity","stroke-opacity","opacity","stroke-miterlimit","stroke-dashoffset","fill-rule","stroke-linecap","stroke-linejoin","stroke-dasharray","paint-order","vector-effect","mix-blend-mode"].includes(I)||!k&&I==="stroke-width"&&(!a||a==="none"))continue;let T=x(i(I));T!==void 0&&(v==="paintOrder"&&T==="normal"||(o[v]=T))}if(o.opacity===1&&r?.cascadedValues.opacity!==void 0&&(o.preserveOpacity=!0),o.inheritFill===!0&&r?.cascadedValues["fill-opacity"]===void 0&&delete o.fillOpacity,o.inheritStroke===!0)for(let[v,I]of[["stroke-opacity","strokeOpacity"],["stroke-width","borderWidth"],["stroke-miterlimit","strokeMiterlimit"],["stroke-dashoffset","dashOffset"],["stroke-linecap","strokeLinecap"],["stroke-linejoin","strokeLinejoin"],["stroke-dasharray","strokeDasharray"]])r?.cascadedValues[v]===void 0&&delete o[I];i("display")?.trim().toLowerCase()==="none"&&(o.display="none");let f=i("visibility")?.trim(),m=r?.cascadedValues.visibility?.value?.trim().toLowerCase();!(l!==null&&c?.parentOccurrenceId!==null&&c?.parentOccurrenceId!==void 0&&QO(t).has(c.parentOccurrenceId)&&l.resolvedValues.visibility===r?.resolvedValues.visibility&&(m===void 0||m==="inherit"||m==="unset"))&&(f==="hidden"||f==="collapse")&&(o.visibility=f);let h=r?.cascadedValues["clip-path"]?.value??null;h&&!/^url\(/iu.test(h.trim())&&(o.cssClipPath=h);let y={};for(let v of["mask","mask-image","mask-mode","mask-repeat","mask-position","mask-clip","mask-origin","mask-size","mask-composite","mask-type"]){let I=r?.cascadedValues[v]?.value??null;I!==null&&(y[v]=Wn(t,I))}Object.keys(y).length>0&&(o.cssMaskProperties=y);let b=Object.fromEntries(Object.entries(r?.inlineDeclarations??{}).filter(([v])=>v.startsWith("--")||v.startsWith("-")).map(([v,I])=>[v,n.rewriteValue(e,I)]));Object.keys(b).length>0&&(o.inlineStyle=b);for(let[v,I]of[["marker-start","markerStart"],["marker-mid","markerMid"],["marker-end","markerEnd"]]){let x=i(v);if(!x)continue;let k=t.resourceDependencies.edges.filter(w=>w.kind==="marker"&&w.propertyName===v&&w.propertyValue===x&&(w.occurrenceId!==null&&w.occurrenceId===e||w.occurrenceId===null&&w.fromSourceNodeId===r?.correspondingSourceNodeId));if(k.length>0){let w=k[0];if(w.validity!=="valid"||!w.targetSourceNodeId)continue;let P=t.markers.candidate(w.targetSourceNodeId);if(!P||P.status!=="materialized")continue;o[I]=pr(t,P.sourceNodeId,P.sourceId)??void 0;continue}let T=/url\(\s*(['"]?)#([^'"\s)]+)\1\s*\)/u.exec(x)?.[2];T&&(o[I]=t.identifiers.liveIdForSourceId(T)??T)}return o}function LI(t,e,n){let r={},i=t.styles.style(e);if(!i)return r;for(let[o,s]of Object.entries(i.cascadedValues))zI.has(o)&&(r[o]=n.rewriteValue(e,Wn(t,s.value)));return r}function dD(t,e){let n=t.symbolUses.use(e.occurrenceId);if(e.role==="use-carrier"&&n){let c=n.transform.matrix??[1,0,0,1,0,0],l=ge(c,qe(n.geometry.x,n.geometry.y));return Et(l)?void 0:tt(l)}let r=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!r)return;let o=t.styles.style(e.occurrenceId)?.cascadedValues.transform,s=o?.value??C(r,"transform");if(!s||s.trim().toLowerCase()==="none"||o&&o.origin!=="presentation")return;let a=Zt(s);return a&&!Et(a)?tt(a):void 0}function BI(t,e,n,r){let i=n.get(e)?.parentOccurrenceId??null;for(;i;){let s=r.get(i);if(s?.type==="svg"){let a=s.state;if(typeof a.svgViewBoxWidth=="number"&&typeof a.svgViewBoxHeight=="number"&&a.svgViewBoxWidth>0&&a.svgViewBoxHeight>0)return{x:typeof a.svgViewBoxX=="number"?a.svgViewBoxX:0,y:typeof a.svgViewBoxY=="number"?a.svgViewBoxY:0,width:a.svgViewBoxWidth,height:a.svgViewBoxHeight};if(typeof a.svgWidth=="number"&&typeof a.svgHeight=="number"&&a.svgWidth>=0&&a.svgHeight>=0)return{x:0,y:0,width:a.svgWidth,height:a.svgHeight}}i=n.get(i)?.parentOccurrenceId??null}let o=t.rootFrame;return{x:o.viewBoxX??0,y:o.viewBoxY??0,width:o.viewBoxWidth??o.width??300,height:o.viewBoxHeight??o.height??150}}function GI(t,e,n,r){if(e==="view-box")return{boxX:n.x,boxY:n.y,boxWidth:n.width,boxHeight:n.height};if(e!=="fill-box"&&e!=="content-box"&&e!=="stroke-box"&&e!=="border-box")return null;let i=wo(r,t).bounds;if(!i)return null;let o=e==="stroke-box"||e==="border-box",s=Number(t.state.borderWidth??0),a=o&&Number.isFinite(s)&&s>0?s/2:0;return{boxX:i.minX-a,boxY:i.minY-a,boxWidth:i.maxX-i.minX+a*2,boxHeight:i.maxY-i.minY+a*2}}function uD(t,e,n,r,i){for(let o of[...e].reverse()){let s=r.get(o.occurrenceId);if(!s)continue;let a=t.styles.style(o.occurrenceId),c=a?.cascadedValues.transform;if(!c||c.origin==="presentation")continue;let l=c.value.trim();if(!l||l.toLowerCase()==="none"){delete s.state.transformMatrix;continue}let d=BI(t,o.occurrenceId,n,r),u=t.styles.value(o.occurrenceId,"transform-box")??"view-box",p=GI(s,u,d,i);if(!p)continue;let f=t.projectionContext.rootFontSize,m=Pe(t.styles.value(o.occurrenceId,"font-size"),{percentBasis:f,viewportWidth:d.width,viewportHeight:d.height,fontSize:f,rootFontSize:f})??f,h=a.cascadedValues["transform-origin"]?Ts(t.styles.value(o.occurrenceId,"transform-origin")??"0 0",{...p,viewportWidth:d.width,viewportHeight:d.height,fontSize:m,rootFontSize:f}):{x:0,y:0};if(!h)continue;let y=Rs([{offset:0,transform:l}],{...p,viewportWidth:d.width,viewportHeight:d.height,fontSize:m,rootFontSize:f,transformOrigin:h,retainPureRotationOrigin:!1});if(y.status!=="projected"||y.stops.length!==1)continue;let b=y.stops[0].matrix;Et(b)?delete s.state.transformMatrix:s.state.transformMatrix=tt(b)}}function Ur(t,e,n,r,i=!1){let o=lD(t,e.occurrenceId,r),s=sD(t,e,n),a=e.usePath.length===0?t.metadata.candidate(e.correspondingSourceNodeId)?.leadingComments:void 0,c=aD(t,e.correspondingSourceNodeId),l=cD(t,e.correspondingSourceNodeId,i),d=t.conditionalProcessing.condition(e.correspondingSourceNodeId),u=dD(t,e);return s&&(o.metadata=s),a&&a.length>0&&(o.leadingComments=[...a]),c&&(o.scripts=c),Object.keys(l).length>0&&(o.authoredAttributes=l),d&&d.systemLanguage!==null&&(o.systemLanguage=d.systemLanguage),d&&d.requiredExtensions!==null&&(o.requiredExtensions=d.requiredExtensions),u&&(o.transformMatrix=u),o}function ih(t,e,n,r,i){let o=Ur(t,e,r,i,!0),s=LI(t,e.occurrenceId,i);if(Object.keys(s).length>0)if(n==="group"){let c={},l={};for(let[d,u]of Object.entries(s))d==="fill"?c.fill=u:d==="fill-opacity"?c.fillOpacity=u:d==="stroke-opacity"?c.strokeOpacity=u:d==="opacity"?c.opacity=u:d==="mix-blend-mode"?c.mixBlendMode=u:d==="transform-origin"?c.transformOrigin=u:d==="isolation"?c.isolation=u:d==="filter"?c.filter=u:d==="clip-path"?c.clipPath=u:d==="mask"?c.mask=u:l[d]=u;Object.keys(l).length>0&&(c.attributes=l),o.groupData=c}else o.containerPresentation=s;let a=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!a)return o;if(n==="hyperlink"){let c=C(a,"href"),l=a.attributes.find(u=>u.name==="xlink:href")?.value,d=u=>{if(!u.startsWith("#"))return u;let p=t.identifiers.liveIdForSourceId(u.slice(1));return p?`#${p}`:u};c!==null?o.href=d(c):l!==void 0&&(o.href=d(l)),l!==void 0&&(o.hrefXlink=d(l));for(let[u,p]of[["target","linkTarget"],["download","linkDownload"],["ping","linkPing"],["rel","linkRel"],["hreflang","linkHreflang"],["type","linkType"],["referrerpolicy","linkReferrerPolicy"]]){let f=C(a,u);f!==null&&(o[p]=f)}}else if(n==="switch"){let c=t.conditionalProcessing.condition(a.sourceNodeId);c&&(o.switchSystemLanguage=c.systemLanguage,o.switchRequiredExtensions=c.requiredExtensions)}else if(n==="embedded-svg"){let c=t.embeddedFrames.find(l=>l.sourceNodeId===a.sourceNodeId);c&&Object.assign(o,c.state)}return o}function oh(t){return t==="embedded-svg"?"svg":t}function pD(t){let e=t.styles.stylesheets.map((n,r)=>({id:`svg-style-${r+1}`,...n.id?{svgId:n.id}:{},css:n.authoredText,...n.type?{type:n.type}:{},...n.media?{media:n.media}:{},preserved:!0}));return e.length>0?e:void 0}function fD(t){return{severity:"error",code:"application-rolled-back",source:"svg",entrypoint:"svg-document-import",capability:"geometry",message:t}}function pr(t,e,n){return t.identifiers.resourceIds.find(r=>r.sourceNodeId===e)?.liveId??n}function VI(t,e){return t.identifiers.liveIdForSourceNodeId(e)??t.identifiers.generatedIds.find(n=>n.sourceNodeId===e)?.liveId??null}function xu(t,e){let n=structuredClone(e.state),r=e.authoredTextStructure;if(!r)return n;let i=r.spans.flatMap(o=>{let s=VI(t,o.sourceNodeId);return s?[{start:o.start,end:o.end,id:s}]:[]});return i.length===r.spans.length&&(n.authoredTextStructure={text:r.text,spans:i}),n}function mD(t,e){let n=e;for(;n;){let r=t.clipMasks.definition(n.sourceNodeId);if(r)return r.representation==="raw";n=t.sourceDocument.index.parent(n.sourceNodeId)}return!1}function gD(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll(`
42
+ `,"\\a ")}function hD(t){let e=t?.rawXml??"",n=e.indexOf(">"),r=e.lastIndexOf("</");return n>=0&&r>n?e.slice(n+1,r):""}function jI(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function OI(t){return jI(t).replaceAll('"',"&quot;")}function yD(t,e){let n=new Map(e.map(a=>[a.occurrenceId,a])),r=new Map;for(let a of e){if(!a.parentOccurrenceId||!n.has(a.parentOccurrenceId))continue;let c=r.get(a.parentOccurrenceId)??[];c.push(a),r.set(a.parentOccurrenceId,c)}let i=(a,c,l=new Set)=>{let d=[];for(let u of a.attributes){let p=u.name.toLowerCase();if(p.startsWith("xmlns")||/^on[a-z]/u.test(p)||l.has(p)||p==="id"&&c.shadow)continue;let f=p==="id"?pr(t,a.sourceNodeId,u.value)??u.value:Wn(t,u.value);d.push(`${u.name}="${OI(f)}"`)}return d.length>0?` ${d.join(" ")}`:""},o=a=>a.children.filter(c=>c.kind!=="element").map(c=>c.kind==="comment"?`<!--${c.value}-->`:c.kind==="cdata"?`<![CDATA[${c.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`:c.kind==="processing-instruction"?`<?${c.value}?>`:c.kind==="doctype"?`<!DOCTYPE ${c.value}>`:jI(c.value)).join(""),s=a=>{let c=t.sourceDocument.index.element(a.correspondingSourceNodeId);if(!c)return"";let d=(r.get(a.occurrenceId)??[]).map(s).join("");if(c.localName.toLowerCase()==="use"){let p=new Set(["href","xlink:href","x","y","width","height","transform","id"]),f=t.symbolUses.use(a.sourceOccurrenceId),m=[];f?.transform.authored&&m.push(f.transform.authored);let g=f?.geometry.x??0,h=f?.geometry.y??0;(g!==0||h!==0)&&m.push(`translate(${g} ${h})`);let y=m.length>0?` transform="${OI(m.join(" "))}"`:"";return`<g${i(c,a,p)}${y}>${d}</g>`}let u=d||o(c);return`<${c.name}${i(c,a)}>${u}</${c.name}>`};return e.filter(a=>a.parentOccurrenceId===null||!n.has(a.parentOccurrenceId)).map(s).join("")}function Go(t,e){let n=o=>{let s=t.useOccurrences.direct(o.sourceNodeId);return s?t.styles.value(s.occurrenceId,"display"):C(o,"display")},r=t.sourceDocument.index.element(e);if(!r)return!1;if(n(r)?.trim().toLowerCase()==="none")return!0;let i=t.sourceDocument.index.parent(e);for(;i;){if(i.localName.toLowerCase()==="defs"&&n(i)?.trim().toLowerCase()==="none")return!0;i=t.sourceDocument.index.parent(i.sourceNodeId)}return!1}function SD(t){let e=t.indexOf(">");if(e<0)return t;let n=t.slice(0,e);return/\bdisplay\s*=/iu.test(n)?t:t.replace(/^(\s*<[\w:.-]+)/u,'$1 display="none"')}function Ea(t,e,n){let r=n.kind==="color"?n.value??"none":"none";e==="fill"?(t.fillType=n.kind==="color"?"solid":"none",t.fillColor=r):(t.strokeType=n.kind==="color"?"solid":"none",t.borderColor=r)}function sh(t,e){e==="fill"?(t.fillType="none",t.fillColor="none",delete t.fillGradient,delete t.fillLibraryId):(t.strokeType="none",t.borderColor="none",delete t.strokeGradient,delete t.strokeLibraryId)}function bD(t,e,n){let r=[...e.library??[]],i=new Set,o=new Map,s=new Map,a={width:t.rootFrame.viewBoxWidth??t.rootFrame.width??300,height:t.rootFrame.viewBoxHeight??t.rootFrame.height??150},c=jn(e);for(let d of t.gradients.bindings){let u=n.get(d.occurrenceId);if(!u)continue;let p=u.state,f=d.propertyName==="fill"?"fill":"stroke";if(f==="fill"&&p.inheritFill===!0||f==="stroke"&&p.inheritStroke===!0)continue;if(d.status!=="materialized"||!d.gradientSourceNodeId||Go(t,d.gradientSourceNodeId)){d.status==="empty"?sh(p,d.propertyName):(d.status==="invalid"||d.status==="invalid-reference"||d.gradientSourceNodeId&&Go(t,d.gradientSourceNodeId))&&Ea(p,d.propertyName,d.fallback);continue}let m=t.gradients.candidate(d.gradientSourceNodeId),g=m?pr(t,m.sourceNodeId,m.sourceId):null;if(!m||m.status!=="materialized"||!g)continue;let h=t.gradients.resolveGeometry(d,{viewport:a,fontSize:16,rootFontSize:16});if(!h)continue;let y=Object.fromEntries(Object.entries(m.geometryValues).filter(([,x])=>x.validity==="valid").map(([x,k])=>[x,k.raw])),b={id:g,stops:m.stops.map(x=>({offset:x.offset,color:x.color,opacity:x.opacity})),spreadMethod:m.spreadMethod,opacity:1,...m.gradientUnits==="userSpaceOnUse"?{gradientUnits:"userSpaceOnUse"}:{},...m.colorInterpolation!=="sRGB"?{colorInterpolation:m.colorInterpolation}:{},...Object.keys(y).length>0?{authoredGeometry:y}:{},...m.transform.authored?.validity==="valid"?{gradientTransform:[...m.transform.matrix]}:{},...m.sourceId?{sourceId:m.sourceId}:{}},v=m.type==="linear-gradient"?{type:"linear-gradient",x1:h.x1,y1:h.y1,x2:h.x2,y2:h.y2,...b}:{type:"radial-gradient",cx:h.cx,cy:h.cy,fx:h.fx,fy:h.fy,r:h.r,ry:h.r,rotation:0,...h.fr!==0||m.authoredGeometry.fr!==void 0?{fr:h.fr}:{},...b};if(!o.has(g)){let{id:x,sourceId:k,...T}=v,w={kind:m.type,id:g,name:m.sourceId??g,...k?{sourceId:k}:{},gradient:T};o.set(g,w),i.add(g)}let I=v.stops[0]?.color??"#000000";f==="fill"?(p.fillType=v.type,p.fillGradient=v,p.fillLibraryId=g,p.fillColor=I):(p.strokeType=v.type,p.strokeGradient=v,p.strokeLibraryId=g,p.borderColor=I)}for(let d of t.patterns.bindings){let u=n.get(d.occurrenceId);if(!u)continue;let p=u.state,f=d.propertyName==="fill"?"fill":"stroke";if(f==="fill"&&p.inheritFill===!0||f==="stroke"&&p.inheritStroke===!0)continue;if(d.status!=="materialized"||!d.patternSourceNodeId||Go(t,d.patternSourceNodeId)){d.status==="empty"?sh(p,d.propertyName):(d.status==="invalid"||d.status==="invalid-reference"||d.patternSourceNodeId&&Go(t,d.patternSourceNodeId))&&Ea(p,d.propertyName,d.fallback);continue}let m=t.patterns.candidate(d.patternSourceNodeId),g=m?pr(t,m.sourceNodeId,m.sourceId):null;if(!m||m.status!=="materialized"||!g){Ea(p,d.propertyName,d.fallback);continue}let h=wo(c,u).bounds,y=t.patterns.resolveTile(d,{viewport:a,objectBounds:h?{x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY}:{x:0,y:0,width:0,height:0},fontSize:16,rootFontSize:16});if(!y){sh(p,d.propertyName);continue}let b=m.contentProviderSourceNodeId?t.sourceDocument.index.element(m.contentProviderSourceNodeId):null,v=m.contentOccurrences.length>0?yD(t,m.contentOccurrences):hD(b);if(!v)continue;let I=Object.fromEntries(Object.entries(m.values).filter(([,k])=>k.validity==="valid").map(([k,T])=>[k,T.raw])),x={type:"pattern",id:g,patternType:"custom",color:"#000000",backgroundColor:"#ffffff",scale:1,rotation:0,opacity:1,svgContent:Wn(t,v),width:y.width,height:y.height,patternUnits:m.patternUnits,patternContentUnits:m.patternContentUnits,...m.values.x?{x:y.x}:{},...m.values.y?{y:y.y}:{},...Object.keys(I).length>0?{authoredGeometry:I}:{},...m.transform.raw&&m.transform.validity==="valid"?{patternTransform:m.transform.raw}:{},...m.viewBoxAuthored?.validity==="valid"?{viewBox:m.viewBoxAuthored.raw}:{},...m.preserveAspectRatioAuthored?.validity==="valid"?{preserveAspectRatio:m.preserveAspectRatioAuthored.raw}:{},...m.sourceId?{sourceId:m.sourceId}:{}};if(!s.has(g)){let{id:k,sourceId:T,customPatternId:w,...P}=x;s.set(g,{kind:"pattern",id:g,name:m.sourceId??g,...T?{sourceId:T}:{},pattern:P}),i.add(g)}f==="fill"?(p.fillType="pattern",p.fillGradient=x,p.fillLibraryId=g,p.fillColor=x.color):(p.strokeType="pattern",p.strokeGradient=x,p.strokeLibraryId=g,p.borderColor=x.color)}let l=[...o.values(),...s.values()];return l.length>0&&(e.library=[...r,...l]),i}function vD(t,e,n){let r=[...e.library??[]],i=new Map,o=new Set;for(let s of t.filters.bindings){let a=n.get(s.consumerOccurrenceId);if(!a)continue;let c=a.state;if(s.status!=="materialized"){delete c.filterLibraryIds,delete c.filters;continue}let l=[],d=[],u=[],p=!1;for(let f of s.operations){if(f.status!=="materialized")continue;if(f.kind==="function"){p=!0,f.filter&&d.push(structuredClone(f.filter));continue}if(!f.filterSourceNodeId)continue;let m=t.filters.candidate(f.filterSourceNodeId),g=m?pr(t,m.sourceNodeId,m.sourceId):null;!m||m.status!=="materialized"||!g||(l.push(g),o.add(g),u.push({id:g,candidate:m}),d.push(...structuredClone(m.filters)))}if(p&&l.length>0){let f=`filter-${a.id}`,m=1,g=new Set([...r.map(y=>y.id),...i.keys()]);for(;g.has(f);)f=`filter-${a.id}-${m++}`;let h=u[0]?.candidate;i.set(f,{kind:"filter",id:f,name:f,filters:structuredClone(d),...h?{colorInterpolation:h.colorInterpolation,filterUnits:h.filterUnits,primitiveUnits:h.primitiveUnits,x:h.region.x,y:h.region.y,width:h.region.width,height:h.region.height}:{}}),c.filterLibraryIds=[f]}else if(l.length>0){c.filterLibraryIds=l;for(let{id:f,candidate:m}of u)i.has(f)||i.set(f,{kind:"filter",id:f,name:m.sourceId??f,...m.sourceId?{sourceId:m.sourceId}:{},filters:[...structuredClone(m.filters)],colorInterpolation:m.colorInterpolation,filterUnits:m.filterUnits,primitiveUnits:m.primitiveUnits,x:m.region.x,y:m.region.y,width:m.region.width,height:m.region.height})}d.length>0&&(c.filters=d)}return i.size>0&&(e.library=[...r,...i.values()]),o}function xD(t,e,n,r,i,o,s){let a=[],c=new Set,l=new Map(e.sceneTree?.map(u=>[u.id,{parentId:u.parentId,index:u.index}])??[]),d=0;for(let u of t.clipMasks.bindings){let p=n.get(u.consumerOccurrenceId);if(!p||!r.has(p.id))continue;let f=p.state,m=u.definitionSourceNodeId?t.clipMasks.definition(u.definitionSourceNodeId):null,g=Wn(t,u.authoredValue);if(u.status!=="materialized"||!m||m.status!=="materialized"||Go(t,m.sourceNodeId)){u.propertyName==="clip-path"?f.cssClipPath=g:f.cssMaskProperties={...f.cssMaskProperties??{},[u.propertyName]:g};continue}let h=pr(t,m.sourceNodeId,m.sourceId)??`${m.type}-definition-${d+1}`,y=t.sourceDocument.index.element(m.sourceNodeId),b=!c.has(h);c.add(h);let v=b&&m.representation==="raw"?t.paintServerDefinitions.candidate(m.sourceNodeId)?.definition.markup??Wn(t,y?.rawXml??m.rawDefinition??""):"",I=e.sceneTree?.find(P=>P.id===p.id),x=l.get(p.id);if(delete f.cssClipPath,f.cssMaskProperties&&typeof f.cssMaskProperties=="object"){let P={...f.cssMaskProperties};delete P[u.propertyName],f.cssMaskProperties=Object.keys(P).length>0?P:void 0}let k=f.authoredAttributes;if(k&&typeof k=="object"){let P={...k};delete P[u.propertyName],f.authoredAttributes=Object.keys(P).length>0?P:void 0}let T=[],w=wo(jn(e),p).bounds;if(w){let P=t.clipMasks.resolve(u,{consumerObjectBounds:{x:w.minX,y:w.minY,width:w.maxX-w.minX,height:w.maxY-w.minY}});for(let N of P.geometryPlacements){let R=i.get(N.occurrenceId),$=t.leafGeometry.candidate(N.occurrenceId);if(!R||!$?.canonicalType||$.status!=="materialized")continue;let A=`clip-mask-${d+1}-shape-${T.length+1}`,O={...xu(t,$),...Ur(t,R,o,s)},G=O.transformMatrix,M=G?ge(N.matrix,G):N.matrix;Et(M)?delete O.transformMatrix:O.transformMatrix=tt(M),m.type==="clip"&&(O.fillColor="#000000",O.fillType="solid",delete O.inheritFill,delete O.inheritStroke,delete O.borderColor,delete O.borderWidth,O.strokeType="none",N.clipRule==="evenodd"?O.fillRule="evenodd":$.canonicalType==="path"?O.fillRule="nonzero":delete O.fillRule);let V={id:A,type:$.canonicalType,state:O};e.shapes.push(V),T.push(A),n.has(N.occurrenceId)||n.set(N.occurrenceId,V)}}a.push({id:`clip-mask-${++d}`,type:m.type,definitionId:h,clipShapeIds:T,contentShapeIds:[p.id],parentId:x?.parentId??I?.parentId??null,...x?{siblingIndex:x.index}:{},...m.type==="clip"?{...m.clipPathUnits?{clipPathUnits:m.clipPathUnits}:{},...m.clipRule?{clipRule:m.clipRule}:{}}:{...m.maskUnits?{maskUnits:m.maskUnits}:{},...m.maskContentUnits?{maskContentUnits:m.maskContentUnits}:{},...m.maskType?{maskType:m.maskType}:{},...m.region?{maskBounds:{...m.region}}:{}},...v?{rawDefinition:v}:{}})}return a.length>0&&(e.clipMaskGroups=a,er(e)),c}function Iu(t,e={}){let n=Vl(t.styles),r=new Map(t.useOccurrences.occurrences.map(E=>[E.occurrenceId,E])),i=new Map(t.hierarchy.containers.map(E=>[E.occurrenceId,E])),o=new Map(t.leafGeometry.candidates.filter(E=>E.status==="materialized").map(E=>[E.occurrenceId,E])),s=_I(t),a=FI(t),c=new Map,l=new Map;for(let E of t.symbolUses.definitions){let z=pr(t,E.sourceNodeId,E.sourceId)??`symbol-${c.size+1}`,B=(l.get(z)??0)+1;l.set(z,B),c.set(E.productKey,B===1?z:`${z}-use-${B}`)}let d=new Map;a.forEach((E,z)=>{d.set(E.occurrenceId,`svg-node-${z+1}`)});let u=new Map,p=[];for(let E of a){let z=d.get(E.occurrenceId),B=t.symbolUses.use(E.occurrenceId);if(B?.status==="symbol-instance"&&B.definitionProductKey){let L=t.symbolUses.definition(B.definitionProductKey),be=c.get(B.definitionProductKey);if(!L||!be)continue;let ce=Ur(t,E,u,n);delete ce.transformMatrix,ce.symbolId=be,ce.x=B.geometry.x,ce.y=B.geometry.y,ce.width=B.geometry.width??L.parsedViewBox?.width??100,ce.height=B.geometry.height??L.parsedViewBox?.height??100,B.geometry.authored&&(ce.authoredUseGeometry={...B.geometry.authored});let Re={...B.presentation};B.transform.authored&&B.transform.authored.trim()&&(Re.transform=B.transform.authored),Object.keys(Re).length>0&&(ce.instancePresentation=Re),L.parsedViewBox?(ce.viewBoxWidth=L.parsedViewBox.width,ce.viewBoxHeight=L.parsedViewBox.height,ce.scaleContentToViewport=!0):ce.scaleContentToViewport=!1,p.push({id:z,type:"symbol-instance",state:ce});continue}if(B?.status==="linked-reference"&&B.targetSourceNodeId){let L=t.useOccurrences.direct(B.targetSourceNodeId),be=L?d.get(L.occurrenceId):void 0;if(!be)continue;let ce=Ur(t,E,u,n),Re=B.transform.matrix;ce.targetShapeId=be,ce.offsetX=B.geometry.x,ce.offsetY=B.geometry.y,Re&&!Et(Re)?ce.transformMatrix=tt(Re):delete ce.transformMatrix,p.push({id:z,type:"shape-reference",state:ce});continue}let se=i.get(E.occurrenceId);if(se){p.push({id:z,type:oh(se.kind),state:ih(t,E,se.kind,u,n)});continue}let me=o.get(E.occurrenceId);me?.canonicalType&&p.push({id:z,type:me.canonicalType,state:{...xu(t,me),...Ur(t,E,u,n)}})}let f=new Map,m=[];for(let[E,z]of t.symbolUses.definitions.entries()){let B=c.get(z.productKey);if(!B)continue;let se=new Set;for(let ie of z.contentOccurrenceIds){let we=t.symbolUses.use(ie);if(we?.status!=="symbol-instance"||!we.definitionProductKey)continue;let $e=t.symbolUses.definition(we.definitionProductKey);if($e){se.add($e.productRootOccurrenceId);for(let Ue of $e.contentOccurrenceIds)se.add(Ue)}}let me=t.sourceDocument.index.element(z.sourceNodeId),L=new Set(z.contentOccurrenceIds);me&&!["g","symbol"].includes(me.localName.toLowerCase())&&L.add(z.productRootOccurrenceId);let be=s.filter(ie=>L.has(ie.occurrenceId)&&!se.has(ie.occurrenceId)),ce=new Map;be.forEach((ie,we)=>{ce.set(ie.occurrenceId,`symbol-node-${E+1}-${we+1}`)});let Re=new Map;for(let ie of be){let we=ce.get(ie.occurrenceId),$e=t.symbolUses.use(ie.occurrenceId),Ue=null;if($e?.status==="symbol-instance"&&$e.definitionProductKey){let Ie=t.symbolUses.definition($e.definitionProductKey),He=c.get($e.definitionProductKey);if(Ie&&He){let Se=Ur(t,ie,u,n);delete Se.transformMatrix,Se.symbolId=He,Se.x=$e.geometry.x,Se.y=$e.geometry.y,Se.width=$e.geometry.width??Ie.parsedViewBox?.width??100,Se.height=$e.geometry.height??Ie.parsedViewBox?.height??100,$e.geometry.authored&&(Se.authoredUseGeometry={...$e.geometry.authored});let dt={...$e.presentation};$e.transform.authored&&$e.transform.authored.trim()&&(dt.transform=$e.transform.authored),Object.keys(dt).length>0&&(Se.instancePresentation=dt),Ie.parsedViewBox?(Se.viewBoxWidth=Ie.parsedViewBox.width,Se.viewBoxHeight=Ie.parsedViewBox.height,Se.scaleContentToViewport=!0):Se.scaleContentToViewport=!1,Ue={id:we,type:"symbol-instance",state:Se}}}else{let Ie=i.get(ie.occurrenceId);if(Ie)Ue={id:we,type:oh(Ie.kind),state:ih(t,ie,Ie.kind,u,n)};else{let He=o.get(ie.occurrenceId);He?.canonicalType&&(Ue={id:we,type:He.canonicalType,state:{...xu(t,He),...Ur(t,ie,u,n)}})}}if(!Ue)continue;ie.occurrenceId===z.productRootOccurrenceId&&me&&!["g","symbol"].includes(me.localName.toLowerCase())&&delete Ue.state.transformMatrix;let it=t.useOccurrences.direct(ie.correspondingSourceNodeId),cn=it?t.styles.style(it.occurrenceId):null,W=Ue.state;cn?.cascadedValues.fill||(delete W.fillColor,delete W.fillType,delete W.fillGradient,delete W.fillLibraryId,W.inheritFill=!0),cn?.cascadedValues.stroke||(delete W.borderColor,delete W.strokeType,delete W.strokeGradient,delete W.strokeLibraryId,W.inheritStroke=!0),Re.set(ie.occurrenceId,Ue),f.set(ie.occurrenceId,Ue)}let Ye=[];for(let ie of be){let we=Re.get(ie.occurrenceId);if(!we)continue;let $e=i.get(ie.occurrenceId),Ue=t.hierarchy.placements.find(W=>W.occurrenceId===ie.occurrenceId),it=$e?.parentContainerOccurrenceId??Ue?.parentContainerOccurrenceId??null,cn=it?Re.get(it):void 0;if(cn){let W=cn.state,Ie=W.children??[];W.children=[...Ie,we]}else Ye.push(we)}let je=t.metadata.candidate(z.sourceNodeId)?.metadata,jt=me!==null&&["g","symbol"].includes(me.localName.toLowerCase()),Xt={...z.rootAttributes,...jt?LI(t,z.productRootOccurrenceId,n):{}};m.push({kind:"symbol",id:B,name:z.sourceId??B,...z.sourceId?{sourceId:z.sourceId}:{},defKind:z.defKind,...z.viewBox!==null?{viewBox:z.viewBox}:{},...z.preserveAspectRatio!==null?{preserveAspectRatio:z.preserveAspectRatio}:{},...z.x!==null?{x:z.x}:{},...z.y!==null?{y:z.y}:{},...z.width!==null?{width:z.width}:{},...z.height!==null?{height:z.height}:{},...z.refX!==null?{refX:z.refX}:{},...z.refY!==null?{refY:z.refY}:{},...Object.keys(Xt).length>0?{rootAttributes:Xt}:{},...je&&Object.keys(je).length>0?{metadata:structuredClone(je)}:{},shapes:Ye})}for(let[E,z]of t.markers.candidates.entries()){if(z.status!=="materialized")continue;let B=pr(t,z.sourceNodeId,z.sourceId);if(!B)continue;let se=new Map;for(let ie of z.content){let we=r.get(ie.occurrenceId);if(!we)continue;let $e=`marker-node-${E+1}-${se.size+1}`,Ue=i.get(we.occurrenceId),it=ie.elementName==="g"?"group":ie.elementName==="a"?"hyperlink":ie.elementName==="switch"?"switch":ie.elementName==="svg"?"embedded-svg":null,cn=Ue?.kind??it,W=null;if(cn)W={id:$e,type:oh(cn),state:ih(t,we,cn,u,n)};else{let Ie=o.get(we.occurrenceId);Ie?.canonicalType&&(W={id:$e,type:Ie.canonicalType,state:{...xu(t,Ie),...Ur(t,we,u,n)}})}W&&se.set(we.occurrenceId,W)}let me=[];for(let ie of z.content){let we=se.get(ie.occurrenceId);if(!we)continue;let $e=ie.parentOccurrenceId?se.get(ie.parentOccurrenceId):void 0;if($e){let Ue=$e.state;Ue.children=[...Ue.children??[],we]}else me.push(we)}let L=new Map(z.content.map(ie=>[ie.occurrenceId,ie])),be=new Map;for(let ie of z.content){let we=se.get(ie.occurrenceId);we&&!be.has(ie.sourceNodeId)&&be.set(ie.sourceNodeId,we)}let ce=ie=>({shapeId:ie.id,shapeType:ie.type,state:ie.state}),Re=ie=>{let we=[];for(let[$e,Ue]of se){let it=L.get($e)?.parentOccurrenceId??null;for(;it;){if(it===ie){we.push(Ue);break}it=L.get(it)?.parentOccurrenceId??null}}return we},Ye=z.viewBox?.trim().split(/[\s,]+/u).map(Number),je=Ye?.length===4&&Ye.every(Number.isFinite)?{x:Ye[0],y:Ye[1],width:Ye[2],height:Ye[3]}:{x:0,y:0,width:z.markerWidth,height:z.markerHeight},jt=Ms(t,{shapeIdForOccurrence:ie=>se.get(ie)?.id??null,shapeStateForOccurrence:ie=>se.get(ie)?.state??null,shapeIdForSourceNode:ie=>be.get(ie)?.id??null,shapeBindingsForOccurrence:ie=>{let we=se.get(ie);return we?[ce(we)]:[]},descendantShapeBindingsForOccurrence:ie=>Re(ie).map(ce),cssTransformContextForOccurrence:()=>({viewportWidth:je.width,viewportHeight:je.height,boxX:je.x,boxY:je.y,boxWidth:je.width,boxHeight:je.height})}),Xt=t.metadata.candidate(z.sourceNodeId)?.metadata;m.push({kind:"marker",id:B,name:z.name,...z.sourceId?{sourceId:z.sourceId}:{},...Xt&&Object.keys(Xt).length>0?{metadata:structuredClone(Xt)}:{},...z.viewBox?{viewBox:z.viewBox}:{},...z.preserveAspectRatio?{preserveAspectRatio:z.preserveAspectRatio}:{},...Object.keys(z.authoredGeometry).length>0?{authoredGeometry:{...z.authoredGeometry}}:{},...Object.keys(z.rootAttributes).length>0?{rootAttributes:{...z.rootAttributes}}:{},refX:z.refX,refY:z.refY,markerWidth:z.markerWidth,markerHeight:z.markerHeight,markerUnits:z.markerUnits,orient:z.orient,...z.overflow?{overflow:z.overflow}:{},shapes:me,...jt?{animations:jt.tracks}:{}})}for(let[E,z]of t.views.entries()){let B=t.sourceDocument.index.element(z.sourceNodeId),se=B?C(B,"id"):null,me=pr(t,z.sourceNodeId,se);p.push({id:`svg-view-${E+1}`,type:"view",state:{...z.state,...me?{viewName:me}:{}}})}let g=new Map,h=[];for(let E of a){let z=d.get(E.occurrenceId);if(!z||!p.some(ce=>ce.id===z))continue;let B=i.get(E.occurrenceId),se=t.hierarchy.placements.find(ce=>ce.occurrenceId===E.occurrenceId),me=B?.parentContainerOccurrenceId??se?.parentContainerOccurrenceId??null,L=me?d.get(me)??null:null,be=g.get(L)??0;g.set(L,be+1),h.push({id:z,parentId:L,index:be})}for(let E of p.filter(z=>z.type==="view")){let z=g.get(null)??0;g.set(null,z+1),h.push({id:E.id,parentId:null,index:z})}let y=t.rootFrame,b=e.entrypoint==="external-svg-paste",v=y.systemLanguage!==void 0||y.requiredExtensions!==void 0,I=b&&(y.targetedPasteWrapper||v)?"svg-import-root-wrapper":null;if(I){let E={...y.systemLanguage!==void 0?{systemLanguage:y.systemLanguage}:{},...y.requiredExtensions!==void 0?{requiredExtensions:y.requiredExtensions}:{}},z=y.targetedPasteWrapper?"svg":"group";z==="svg"&&(y.width!==void 0&&(E.svgWidth=y.width),y.height!==void 0&&(E.svgHeight=y.height),y.sizingMode==="explicit"&&(E.svgViewBoxX=y.viewBoxX,E.svgViewBoxY=y.viewBoxY,E.svgViewBoxWidth=y.viewBoxWidth,E.svgViewBoxHeight=y.viewBoxHeight),y.preserveAspectRatio!==void 0&&(E.svgPreserveAspectRatio=y.preserveAspectRatio)),p.unshift({id:I,type:z,state:E});for(let B of h)B.parentId===null&&(B.parentId=I);h.unshift({id:I,parentId:null,index:0})}let x=y.viewBoxWidth??y.width??300,k=y.viewBoxHeight??y.height??150;p.unshift({id:"svg-document-root",type:"svg",state:{isRootSvg:!0,svgWidth:y.width??x,svgHeight:y.height??k,svgViewBoxX:y.viewBoxX??0,svgViewBoxY:y.viewBoxY??0,svgViewBoxWidth:x,svgViewBoxHeight:k,...y.preserveAspectRatio!==void 0?{svgPreserveAspectRatio:y.preserveAspectRatio}:{},...y.systemLanguage!==void 0?{systemLanguage:y.systemLanguage}:{},...y.requiredExtensions!==void 0?{requiredExtensions:y.requiredExtensions}:{}}});let T=eD(m,p),w=ho({shapes:p,viewboxes:[Pi(y.viewBoxX??0,y.viewBoxY??0,Math.max(x,1),Math.max(k,1),"svg-viewbox-1")],metadata:t.metadata.document.metadata});w.sceneTree=[{id:"svg-document-root",parentId:null,index:0},...h.map(E=>E.parentId===null?{...E,index:E.index+1}:E)],T.length>0&&(w.library=T);let P=jn(w),N=new Map,R=new Map;for(let E of a){let z=d.get(E.occurrenceId),B=z?p.find(se=>se.id===z):void 0;B&&(N.set(E.occurrenceId,B),R.has(E.correspondingSourceNodeId)||R.set(E.correspondingSourceNodeId,B.id))}uD(t,a,r,N,P);let $=new Map(N),A=new Map;for(let E of t.symbolUses.uses){if(E.status!=="symbol-instance"||!E.definitionProductKey)continue;let z=$.get(E.useOccurrenceId),B=t.symbolUses.definition(E.definitionProductKey);if(!z||!B)continue;let se=A.get(B.productRootOccurrenceId)??[];se.push(z),A.set(B.productRootOccurrenceId,se),R.has(B.sourceNodeId)||R.set(B.sourceNodeId,z.id)}for(let[E,z]of f){N.set(E,z);let B=r.get(E);B&&!R.has(B.correspondingSourceNodeId)&&R.set(B.correspondingSourceNodeId,z.id)}if(I){let E=p.find(B=>B.id===I),z=t.useOccurrences.direct(t.sourceDocument.root.sourceNodeId);E&&(R.set(t.sourceDocument.root.sourceNodeId,E.id),z&&(N.set(z.occurrenceId,E),$.set(z.occurrenceId,E)))}let O=new Set(w.shapes.map(E=>E.id));xD(t,w,N,O,r,u,n),bD(t,w,N),vD(t,w,N);let G=E=>{let z=[];for(let[B,se]of N){let me=r.get(B)?.parentOccurrenceId??null;for(;me;){if(me===E){z.push(se);break}me=r.get(me)?.parentOccurrenceId??null}}return z},M=E=>BI(t,E,r,N),V=E=>({shapeId:E.id,shapeType:E.type,state:E.state}),X=E=>{let z=$.get(E);return z?[z]:A.get(E)??[]},Y=Ms(t,{shapeIdForOccurrence:E=>X(E)[0]?.id??null,shapeStateForOccurrence:E=>X(E)[0]?.state??null,shapeIdForSourceNode:E=>R.get(E)??null,shapeBindingsForOccurrence:E=>X(E).map(V),descendantShapeBindingsForOccurrence:E=>G(E).filter(z=>O.has(z.id)).map(V),domTargetForOccurrence:E=>{let z=r.get(E);if(!z)return null;let B=t.sourceDocument.index.element(z.correspondingSourceNodeId);if(!B||!mD(t,B))return null;let se=VI(t,B.sourceNodeId);if(!se)return null;let me=Object.fromEntries(B.attributes.map(L=>[L.name,L.value]));return me.id=se,{shapeId:`__dom__${se}`,selector:`[id="${gD(se)}"]`,baseTransform:t.styles.value(E,"transform")??me.transform??"",baseAttributes:Object.freeze(me)}},cssTransformContextForOccurrence:(E,z)=>{let B=X(E)[0],se=M(E),me=B?GI(B,z,se,P):null;return{viewportWidth:se.width,viewportHeight:se.height,...me??{}}}});Y&&(w.animationTimeline=Y);let U=Object.entries(n.variables).map(([E,z])=>({name:E,type:/^(?:[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)$/u.test(z.trim())?"number":/^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\()/iu.test(z.trim())?"color":"string",defaultValue:z}));U.length>0&&(w.templateVariables=U);let te=pD(t);te&&(w.documentStyles=te);let Z=new Set([...N.keys()].map(E=>t.useOccurrences.occurrence(E)?.correspondingSourceNodeId).filter(E=>E!==void 0)),ne=[...t.scripts.documentScripts,...t.scripts.elementScripts.filter(E=>E.parentSourceNodeId!==null&&!Z.has(E.parentSourceNodeId))].map(E=>({...E.script,customAttrs:E.script.customAttrs?{...E.script.customAttrs}:void 0}));ne.length>0&&(w.documentScripts=ne);let F=new Set((w.library??[]).map(E=>E.id)),j=new Set((w.clipMaskGroups??[]).map(E=>E.definitionId)),H=new Set;for(let E of t.paintServerDefinitions.candidates)(F.has(E.destinationId)||j.has(E.destinationId))&&H.add(E.sourceNodeId);for(let E of t.gradients.candidates)if(H.has(E.sourceNodeId))for(let z of E.templateSourceNodeIds)H.add(z);for(let E of t.patterns.candidates)if(H.has(E.sourceNodeId))for(let z of E.templateSourceNodeIds)H.add(z);let oe=new Set(t.symbolUses.definitions.map(E=>E.sourceNodeId));for(let E of oe)H.add(E);for(let E of t.markers.candidates)E.status==="materialized"&&H.add(E.sourceNodeId);let re=[...t.paintServerDefinitions.definitions(H)],xe=new Set(t.paintServerDefinitions.candidates.filter(E=>!H.has(E.sourceNodeId)).map(E=>E.sourceNodeId)),Ze=new Map,rt=E=>{if(H.has(E)||oe.has(E))return;let z=t.paintServerDefinitions.definitionForSourceNode(E);z&&!re.some(B=>B.id===z.id)&&Ze.set(z.id,z)};for(let E of t.filters.bindings){if(E.status!=="materialized")continue;let z=t.resourceDependencies.edges.filter(B=>B.kind==="filter"&&B.propertyName==="filter"&&B.propertyValue===E.authoredValue&&(B.occurrenceId!==null&&B.occurrenceId===E.consumerOccurrenceId||B.occurrenceId===null&&B.fromSourceNodeId===E.consumerSourceNodeId));for(let B of t.resourceDependencies.closureFromEdges(z).materializations)B.role==="referenced-fragment"&&rt(B.sourceNodeId)}let Rt=(E,z)=>{let B=t.sourceDocument.index.parent(E);for(;B;){if(B.sourceNodeId===z)return!0;B=t.sourceDocument.index.parent(B.sourceNodeId)}return!1};for(let E of t.useOccurrences.sourceResolutions)E.status!=="resolved"||!E.targetSourceNodeId||[...xe].some(z=>Rt(E.useSourceNodeId,z))&&rt(E.targetSourceNodeId);let lt=[...re,...Ze.values()];lt.length>0&&(w.paintServerDefs=lt.map(E=>{let z=t.paintServerDefinitions.candidates.find(se=>se.definition.id===E.id)?.sourceNodeId,B=structuredClone(E);return z&&Go(t,z)&&(B.markup=SD(B.markup)),B}));let Ve=Br(w);return Ve.errors.length>0?{value:null,diagnostics:Ve.errors.map(E=>fD(`${E.path}: ${E.message}`))}:{value:w,diagnostics:[]}}function ID(t,e){let n=t.sourceDocument.index.element(e.correspondingSourceNodeId),r=n?C(n,"id"):null;return{elementName:n?.name??"unknown",sourceNodeId:e.correspondingSourceNodeId,occurrenceId:e.occurrenceId,orderKey:[...e.orderKey],productIndex:e.productIndex,...r!==null?{authoredId:r}:{},...n?{elementOrder:n.elementOrder}:{},sourceOrder:n?.elementOrder??e.orderKey[0]??0}}function wD(t,e){let n={},r=(i,o)=>{o!==void 0&&(n[i]=structuredClone(o))};return t.documentMetadata&&Object.keys(t.documentMetadata).length>0&&r("documentMetadata",t.documentMetadata),((t.documentScripts?.length??0)>0||e==="svg-document-import")&&r("documentScripts",t.documentScripts??[]),((t.documentStyles?.length??0)>0||e==="svg-document-import")&&r("documentStyles",t.documentStyles??[]),(t.templateVariables?.length??0)>0&&r("templateVariables",t.templateVariables),(t.library?.length??0)>0&&r("library",t.library),(t.paintServerDefs?.length??0)>0&&r("paintServerDefs",t.paintServerDefs),t.animationTimeline&&r("animationTimeline",t.animationTimeline),t.colorGlyphLibrary&&Object.keys(t.colorGlyphLibrary).length>0&&r("colorGlyphLibrary",t.colorGlyphLibrary),n}function kD(t,e){let n=FI(t),r=new Map(n.map((d,u)=>[`svg-node-${u+1}`,d])),i=new Map(t.views.map((d,u)=>[`svg-view-${u+1}`,d])),o=new Map(e.sceneTree?.map(d=>[d.id,d])),s=e.shapes.filter(d=>d.state.isRootSvg!==!0),a=new Map(s.map(d=>[d.id,d])),c=d=>{let u=new Set,p=o.get(d)?.parentId??null;for(;p&&!a.has(p)&&!u.has(p);)u.add(p),p=o.get(p)?.parentId??null;return p&&a.has(p)?p:null},l=d=>{let u=[],p=new Set,f=c(d);for(;f&&a.has(f)&&!p.has(f);)p.add(f),u.unshift(f),f=c(f);return u};return s.map((d,u)=>{let p=r.get(d.id),f=i.get(d.id),m=f?t.sourceDocument.index.element(f.sourceNodeId):null,g=m?C(m,"id"):null,h=m?{elementName:m.name,sourceNodeId:m.sourceNodeId,...g!==null?{authoredId:g}:{},elementOrder:m.elementOrder,sourceOrder:m.elementOrder}:void 0;return{planNodeId:d.id,serialized:structuredClone(d),parentPlanNodeId:c(d.id),sourceOrder:u,groupPath:l(d.id),...p?{sourceElement:ID(t,p)}:h?{sourceElement:h}:{}}})}function PD(t,e){let n=new Map;for(let r of e){let i=r.sourceElement?.sourceNodeId;i&&!n.has(i)&&n.set(i,r.planNodeId)}return e.flatMap(r=>{let i=r.sourceElement?.sourceNodeId;return i?t.sourceDocument.index.referencesFrom(i).map(o=>({kind:o.attributeName?`${o.channel}:${o.attributeName}`:o.channel,fromPlanNodeId:r.planNodeId,...o.targetSourceNodeId?{targetSourceNodeId:o.targetSourceNodeId,toPlanNodeId:n.get(o.targetSourceNodeId)}:{},fromSourceNodeId:i,sourceId:r.sourceElement?.authoredId,targetSourceId:o.targetAuthoredId})):[]}).sort((r,i)=>r.fromPlanNodeId.localeCompare(i.fromPlanNodeId)||r.kind.localeCompare(i.kind)||(r.targetSourceId??"").localeCompare(i.targetSourceId??""))}function DI(t,e,n){return Fs({planVersion:1,identityMode:"allocate",source:{kind:e.source??"svg",fingerprint:_s(t)},intent:e.entrypoint??"svg-document-import",nodes:[],documentFields:{},referenceEdges:[],clipMaskGroups:[],diagnostics:[...n],externalEffects:[]})}function TD(t,e){let n=e.entrypoint??"svg-document-import";if(n!=="plugin-svg-fragment"&&n!=="pattern-fragment")return[];let r=e.source??"svg",i=[],o=new Set,s=(a,c,l)=>{o.has(a)||(o.add(a),i.push({severity:"warning",code:"unsupported-ingest-capability",source:r,entrypoint:n,capability:a,message:c,...l?{elementName:l}:{}}))};n==="plugin-svg-fragment"?((t.metadata.document.metadata.rawMetadata||t.metadata.candidates.some(c=>c.metadata.rawMetadata))&&s("metadata","Plugin SVG fragments preserve host document metadata.","metadata"),t.views.length>0&&s("views","Plugin SVG fragments do not alter document navigation views.","view")):(t.scripts.candidates.length>0&&s("scripts","Pattern fragments keep scripts inert and do not adopt them.","script"),t.animations.smil.length>0&&s("smil-animation","Pattern editing materializes static tile geometry and omits SMIL animation tracks.","animate"),t.animations.css.length>0&&s("css-animation","Pattern editing materializes static tile geometry and omits CSS animation tracks."),t.clipMasks.bindings.length>0&&s("clip-mask-membership","Pattern editing does not adopt document clip or mask membership.","clipPath"),t.embeddedFrames.length>0&&s("embedded-svg","Pattern editing flattens nested SVG content into the tile coordinate frame.","svg"));for(let a of t.externalEffects.effects)a.kind==="font-consent"?s("fonts",`${n} does not start an implicit external font consent flow.`):s("external-assets",`${n} does not fetch or convert external image assets.`,"image");return i}function ah(t,e={},n=[]){let r=Iu(t,{entrypoint:e.entrypoint??"svg-document-import"});if(!r.value)return{value:null,diagnostics:Object.freeze([...n,...r.diagnostics])};let i=kD(t,r.value),o=TD(t,e),s={planVersion:1,identityMode:"allocate",source:{kind:e.source??"svg",fingerprint:_s(t.sourceDocument.rawSource)},intent:e.entrypoint??"svg-document-import",nodes:i,documentFields:wD(r.value,e.entrypoint??"svg-document-import"),referenceEdges:PD(t,i),clipMaskGroups:structuredClone(r.value.clipMaskGroups??[]),rootFrame:structuredClone(t.rootFrame),diagnostics:[...n,...r.diagnostics,...o],externalEffects:[...structuredClone(t.externalEffects.effects)]};return{value:Fs(s),diagnostics:s.diagnostics}}function UI(t,e={}){let n=ca(t,e);if(!n.value)return DI(t,e,n.diagnostics);let r=ah(n.value,e,n.diagnostics);return r.value??DI(t,e,r.diagnostics)}var Ma=class extends Error{diagnostics;constructor(e){let n=e.filter(r=>r.severity==="error").map(r=>r.message).join("; ");super(`SVG import failed${n?`: ${n}`:"."}`),this.name="SvgImportError",this.diagnostics=e}};function ch(t,e={}){let n=ca(t,e);if(!n.value)return{value:null,diagnostics:n.diagnostics};let r=Iu(n.value,e);return{value:r.value,diagnostics:Object.freeze([...n.diagnostics,...r.diagnostics])}}function wu(t,e={}){let n=ch(t,e);if(!n.value||n.diagnostics.some(r=>r.severity==="error"))throw new Ma(n.diagnostics);return n.value}var _=(t,e)=>({action:t,by:e});var Pt=t=>t,Xe="DocumentSerializer canonical snapshot restore",ze="policy-driven SVG plan materializer",Gt="policy-driven clipboard plan materializer",Ce="policy-driven fragment plan materializer",zt="SceneGraph hierarchy and source-order projection",xa={schemaVersion:Pt({"native-document-open":_("derived","parseDocument migration and schema stamping"),"full-snapshot-restore":_("derived","snapshot migration and schema stamping"),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),shapes:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("append","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("append","path-only vectorized materializer")}),viewboxes:Pt({"native-document-open":_("derived",zt),"full-snapshot-restore":_("derived",zt),"svg-document-import":_("derived",zt),"external-svg-paste":_("derived",zt),"internal-clipboard-paste":_("derived",zt),"plugin-svg-fragment":_("derived",zt),"pattern-fragment":_("derived",zt),"vectorized-svg-fragment":_("derived",zt)}),guides:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),measurements:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),sceneTree:Pt({"native-document-open":_("derived",zt),"full-snapshot-restore":_("derived",zt),"svg-document-import":_("derived",zt),"external-svg-paste":_("derived",zt),"internal-clipboard-paste":_("derived",zt),"plugin-svg-fragment":_("derived",zt),"pattern-fragment":_("derived",zt),"vectorized-svg-fragment":_("derived",zt)}),clipMaskGroups:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),documentMetadata:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),documentScripts:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("replace",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),documentStyles:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),templateVariables:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),animationTimeline:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),library:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),paintServerDefs:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",Gt),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),colorGlyphLibrary:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),exportItems:Pt({"native-document-open":_("replace",Xe),"full-snapshot-restore":_("replace",Xe),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),unknownFields:Pt({"native-document-open":_("replace","forward-compatible quarantine restore"),"full-snapshot-restore":_("replace","forward-compatible quarantine restore"),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",Gt),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)})};function Vs(t,e){return xa[t][e]}function Ng(t=qi,e=xa){let n=Object.keys(wt);if(n.length===0)throw new Error("Document field roster must not be empty.");if(t.length===0)throw new Error("Ingress intent roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("Ingress intent roster contains duplicate entries.");let r=Object.keys(e);for(let i of n)if(!e[i])throw new Error(`Document field ${i} lacks an ingress matrix.`);for(let i of r)if(!Object.hasOwn(wt,i))throw new Error(`Unknown document field ${i} has an ingress matrix.`);for(let i of n){let o=e[i];for(let s of t){let a=o[s];if(!a)throw new Error(`Document field ${i} lacks intent ${s}.`);if((a.action==="exempt"?a.reason:a.by).trim().length<12)throw new Error(`Ingress policy ${s} lacks a substantive owner or reason.`)}for(let s of Object.keys(o))if(!t.includes(s))throw new Error(`Document field ${i} has unknown intent ${s}.`)}}var iI=["renderToSvg","codegen","dxf","mermaid","pdf","editor-dom"],wt={schemaVersion:{serialization:{kind:"verbatim"},precision:"opaque",required:!1,collab:{exempt:"Format version of the document envelope, not content. The reducer never rewrites it; it is stamped by the serializer and consumed by migrateSnapshot."},rendered:{renderToSvg:{exempt:"Format-envelope version consumed by migrateSnapshot before renderToSvg sees the snapshot; it has no output representation."},codegen:{exempt:"Format-envelope version consumed while normalizing codegen input; it is not content in an embeddable component."},dxf:{exempt:"Format-envelope version is consumed before the editor constructs DXF shape inputs and has no DXF entity representation."},mermaid:{exempt:"Format-envelope version is consumed before Mermaid receives shapes and has no graph-syntax representation."},pdf:{exempt:"Format-envelope version is consumed during document migration before the PDF export surface receives its SVG page input."},"editor-dom":{exempt:"Format-envelope version is consumed during document migration before the live editor DOM is projected."}}},shapes:{serialization:{kind:"shape-array"},precision:"shape-trees",required:!0,collab:{ops:["shape:add","shape:update","shape:remove","text:format"]},rendered:{renderToSvg:{by:"svg-renderer main loop via renderShape; motionOnly shapes become origin-normalized <path> defs for <mpath>"},codegen:{by:"buildRenderPlan supplies the normalized visible-shape entries and defs consumed by every component backend"},dxf:{by:"apps/editor/src/export/dxf-exporter.ts converts supported geometry and accounts for unsupported shape inputs"},mermaid:{by:"apps/editor/src/export/mermaid-exporter.ts maps flowchart nodes and connectors into graph syntax with skip accounting"},pdf:{by:"ExportPanel.generatePdfBlob converts rendered SVG shape markup through svg2pdf and warns before unsupported textPath expansion"},"editor-dom":{by:"SceneGraph and scene-graph-dom-projector drive registered Shape renderers for the live canvas projection"}}},viewboxes:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!0,collab:{exempt:"DERIVED, not stored. `DocumentRootManager.getViewboxes()` projects it from the `<view>` shapes on every read, and the editor host installs no-op setters after View unification. Editing a view is a `shape:update`, which is on the wire; the array regenerates from the shapes on the next serialize."},rendered:{renderToSvg:{by:"viewboxes[0] drives the root width, height, and viewBox in svg-renderer sizing"},codegen:{by:"buildRenderPlan.frame supplies the shared width, height, and viewBox used by every component backend"},dxf:{exempt:"DXF writes model-space geometry and unit metadata, not an SVG viewport or page framing rectangle."},mermaid:{exempt:"Mermaid computes graph layout from topology and has no authored viewport or viewBox capability."},pdf:{by:"ExportPanel PDF page generation uses the selected source bounds and page settings to establish the PDF frame and placement"},"editor-dom":{by:"DocumentRootManager projects view shapes and the active view onto the live root SVG viewport"}}},guides:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,collab:{ops:["guides:set","guide:upsert","guide:remove","guide:move"]},rendered:{renderToSvg:{exempt:"Editor authoring chrome (alignment guides); SVG document output has no representation for them by design."},codegen:{exempt:"Alignment guides are editor authoring chrome and do not belong in an embeddable generated component."},dxf:{exempt:"Alignment guides are editor authoring chrome rather than drawing geometry and do not become DXF entities."},mermaid:{exempt:"Alignment guides are editor authoring chrome rather than graph nodes or edges and do not enter Mermaid syntax."},pdf:{exempt:"Alignment guides are editor authoring chrome and are excluded from the rendered SVG page supplied to PDF conversion."},"editor-dom":{by:"GuideManager projects persisted guides into the editor authoring overlay"}}},measurements:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,collab:{ops:["measurements:set","measurement:upsert","measurement:remove","measurement:move"]},rendered:{renderToSvg:{exempt:"Editor measurement chrome has no SVG document representation; the editor SVG export omits it by design."},codegen:{exempt:"Measurements are editor authoring chrome and do not belong in an embeddable generated component."},dxf:{exempt:"Editor measurement annotations are not drawing geometry and do not become DXF entities in this exporter."},mermaid:{exempt:"Editor measurement annotations are not graph nodes or edges and do not enter Mermaid syntax."},pdf:{exempt:"Editor measurement annotations are authoring chrome and are excluded from the rendered SVG page supplied to PDF conversion."},"editor-dom":{by:"MeasureManager projects persisted measurements into the editor authoring overlay"}}},sceneTree:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["scene:move","scene:place"]},rendered:{renderToSvg:{exempt:"Structure authority whose render projection is inline state.children; renderToSvg consumes that projection instead of the tree."},codegen:{exempt:"Component backends consume buildRenderPlan over inline state.children, the canonical render projection of sceneTree."},dxf:{exempt:"DXF receives shape trees whose inline children are the render projection; it does not replay sceneTree independently."},mermaid:{exempt:"Mermaid receives serialized shapes and connector references rather than replaying the editor sceneTree."},pdf:{exempt:"PDF receives the rendered SVG hierarchy produced from inline children and does not independently replay sceneTree placements."},"editor-dom":{by:"SceneGraph structure and scene-graph-dom-projector reconcile sceneTree placements into the live DOM hierarchy"}}},clipMaskGroups:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["clipMask:upsert","clipMask:remove"]},rendered:{renderToSvg:{by:"renderer/clip-mask-defs.ts emits clipPath and mask defs plus content wrapping while suppressing clip shapes from the visible tree"},codegen:{by:"buildRenderPlan clip-mask runs and defs are consumed by every component backend without re-deriving membership"},dxf:{exempt:"DXF is a geometry exchange target with no SVG clipPath or mask model; shape conversion operates on authored geometry."},mermaid:{exempt:"Mermaid graph syntax has no clipping or masking vocabulary; export is defined over flowchart topology and labels."},pdf:{by:"The rendered SVG page carries reachable clipPath and mask definitions into the svg2pdf conversion boundary"},"editor-dom":{by:"ClipMaskManager and ClipMaskHandler project definitions and content wrappers into the live canvas DOM"}}},documentMetadata:{serialization:{kind:"deep-sorted-object"},precision:"opaque",required:!1,collab:{ops:["metadata:set","metadata:patch"]},rendered:{renderToSvg:{by:"renderer/document-metadata.ts emits xml:lang on the root plus title, description, metadata, and raw HTML metadata as first children"},codegen:{exempt:"Embeddable component backends omit document-artifact identity because the host application owns title, description, and RDF metadata."},dxf:{exempt:"The DXF exporter writes drawing entities and units only; SVG document identity metadata is outside its interchange contract."},mermaid:{exempt:"Mermaid export represents graph topology and labels; SVG document identity metadata has no graph-syntax equivalent."},pdf:{exempt:"SVG title, description, and RDF blocks are not mapped to PDF document information by the current export workflow."},"editor-dom":{by:"DocumentMetadataManager owns metadata and projects language and descriptive elements onto the live document DOM"}}},documentScripts:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["documentScripts:set","documentScript:upsert","documentScript:remove"]},rendered:{renderToSvg:{by:"renderer/document-scripts.ts emits script elements at the end of the SVG when RenderOptions.includeScripts is enabled"},codegen:{exempt:"Embeddable component backends never inject authored executable scripts; behavior in the host application belongs to consumer code."},dxf:{exempt:"DXF drawing output cannot carry executable SVG document scripts and the exporter never evaluates them."},mermaid:{exempt:"Mermaid graph output cannot carry executable SVG document scripts and the exporter never evaluates them."},pdf:{exempt:"PDF conversion never executes or embeds authored SVG scripts; executable document behavior is outside the static export contract."},"editor-dom":{exempt:"DocumentScriptManager keeps scripts inert and never inserts them into the live SVG because dynamically appended script elements execute."}}},documentStyles:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["documentStyles:set","documentStyle:upsert","documentStyle:remove"]},rendered:{renderToSvg:{by:"renderer/document-styles.ts emits style elements as last children with animation declarations stripped because SMIL owns playback"},codegen:{by:"buildRenderPlan.documentStyles supplies normalized style markup to every component backend"},dxf:{exempt:"CSS rules style SVG presentation rather than DXF geometry entities and are outside the DXF export contract."},mermaid:{exempt:"Authored SVG CSS cannot be represented in Mermaid graph syntax; Mermaid styling is generated from its own vocabulary."},pdf:{by:"The rendered SVG page carries authored style elements and computed presentation into the svg2pdf conversion boundary"},"editor-dom":{by:"DocumentStylesManager projects ordered authored styles into the live SVG and keeps the cascade synchronized"}}},templateVariables:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["templateVariables:set","templateVariable:upsert","templateVariable:remove"]},rendered:{renderToSvg:{exempt:"Template variables are substituted upstream by CLI, Action, and SDK entry points; in-renderer substitution would double-apply them."},codegen:{exempt:"Template variables are substituted while normalizing the codegen document input, before any component backend receives a plan."},dxf:{exempt:"Template variables are document-input preprocessing; the DXF exporter receives already-materialized live shape values."},mermaid:{exempt:"Template variables are document-input preprocessing; the Mermaid exporter receives already-materialized labels and references."},pdf:{exempt:"Template variables are resolved before the editor renders the SVG page that is supplied to PDF conversion."},"editor-dom":{by:"VariableManager resolves template variables and maintains their safe live style projection for shape renderers"}}},animationTimeline:{serialization:{kind:"deep-sorted-object"},precision:"animation-timeline",required:!1,collab:{ops:["animation:set","animation:config","animation:clear","animationTrack:upsert","animationTrack:remove","animationKeyframe:upsert","animationKeyframe:remove"]},rendered:{renderToSvg:{by:"renderAnimationElements injects SMIL children per target shape through smil-kernel"},codegen:{by:"buildRenderPlan attaches the same SMIL children to shape markup consumed by every component backend"},dxf:{exempt:"DXF output is a static geometry snapshot and has no SVG SMIL timeline representation in the supported file version."},mermaid:{exempt:"Mermaid export is a static graph description and has no SVG SMIL timeline representation."},pdf:{exempt:"PDF output is a static page snapshot and has no time-based SMIL timeline representation in the export contract."},"editor-dom":{by:"AnimationManager composes ephemeral overlays and the SMIL export kernel projects authored timelines for document output"}}},library:{serialization:{kind:"id-sorted-array"},precision:"shape-trees",required:!1,collab:{ops:["library:set","library:upsert","library:remove"]},rendered:{renderToSvg:{by:"renderLibraryDefs emits reference-filtered gradients, patterns, filters, markers, and symbols into defs"},codegen:{by:"buildRenderPlan library-def channels are emitted by every component backend with shared reference reachability"},dxf:{exempt:"The DXF exporter converts flattened shape geometry and text; SVG visual library definitions have no entity equivalent."},mermaid:{exempt:"Mermaid represents graph nodes and connectors, not reusable SVG paint, filter, marker, or symbol definitions."},pdf:{by:"The rendered SVG page carries reachable library definitions and their references into the svg2pdf conversion boundary"},"editor-dom":{by:"LibraryRegistry plus gradient, filter, marker, pattern, and symbol managers project reachable definitions into live defs"}}},paintServerDefs:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["paintServerDefs:set","paintServerDef:upsert","paintServerDef:remove"]},rendered:{renderToSvg:{by:"renderer/paint-server-defs.ts emits verbatim markup in defs when transitively referenced or marked passthrough"},codegen:{by:"buildRenderPlan paint-server channels carry reachable typed definitions to every component backend"},dxf:{exempt:"Typed SVG paint-server definitions have no DXF entity representation; the exporter operates on shape geometry."},mermaid:{exempt:"Typed SVG paint-server definitions have no Mermaid syntax representation; export operates on graph topology and labels."},pdf:{by:"The rendered SVG page carries reachable typed paint-server definitions into the svg2pdf conversion boundary"},"editor-dom":{by:"PaintServerDef state and definition managers project reachable typed definition markup into live defs"}}},colorGlyphLibrary:{serialization:{kind:"deep-sorted-object"},precision:"opaque",required:!1,collab:{ops:["colorGlyphLibrary:set"]},rendered:{renderToSvg:{exempt:"Font-foundry assets are consumed when emitting an OpenType font binary and have no SVG document representation."},codegen:{exempt:"Font-foundry assets do not belong in embeddable SVG components; generated code references ordinary text and font resources."},dxf:{exempt:"Font-foundry color-glyph assets have no DXF entity representation in the geometry and MTEXT exporter."},mermaid:{exempt:"Font-foundry color-glyph assets have no Mermaid graph-syntax representation and are not graph content."},pdf:{exempt:"Color-glyph source assets back font generation rather than PDF page conversion; rendered text uses the resolved font face."},"editor-dom":{exempt:"Color glyph assets back font-binary generation rather than the editor DOM; text rendering uses the resolved font face."}}},exportItems:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["exportItems:set","exportItem:upsert","exportItem:remove"]},rendered:{renderToSvg:{exempt:"Export profiles are instructions about filenames, formats, and settings, not renderable SVG document content."},codegen:{exempt:"Export profiles configure how code generation is invoked and are not content emitted into a generated component."},dxf:{exempt:"Export profiles configure the editor export workflow; the selected DXF profile is input to invocation, not a DXF entity."},mermaid:{exempt:"Export profiles configure the editor export workflow and are not nodes, connectors, or directives in Mermaid output."},pdf:{exempt:"The selected export profile configures PDF invocation and page settings; it is not content embedded in the PDF page."},"editor-dom":{exempt:"Export profiles configure the export workflow and are intentionally not projected into the live canvas SVG."}}},unknownFields:{serialization:{kind:"unknown-bag"},precision:"opaque",required:!1,collab:{exempt:"Forward-compat quarantine from newer writers; has no ops by definition \u2014 a current client cannot edit a field it does not understand, the DocumentRoom stores raw JSON so the bag rides the seed snapshot, and future clients (the only writers of these fields) carry real ops for them."},rendered:{renderToSvg:{exempt:"Contents are by definition not understood by this build; preservation is pass-through only and rendering them would be a guess."},codegen:{exempt:"Contents are by definition not understood by this build; component generation preserves rather than interprets unknown fields."},dxf:{exempt:"Contents are by definition not understood by this build; DXF conversion cannot safely infer geometry from unknown fields."},mermaid:{exempt:"Contents are by definition not understood by this build; Mermaid export cannot safely infer graph semantics from them."},pdf:{exempt:"Contents are by definition not understood by this build; PDF conversion cannot safely invent a page representation for them."},"editor-dom":{exempt:"Contents are by definition not understood by this build; the editor preserves them without inventing a DOM projection."}}}},Zd=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","exportItems","viewboxes","guides","measurements","sceneTree","clipMaskGroups","library","colorGlyphLibrary","paintServerDefs","animationTimeline","unknownFields","shapes"],oI=["id","type","state"];function lh(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Co(t){let e=t,n=e.unknownFields;if(!lh(n))return delete e.unknownFields,t;for(let[r,i]of Object.entries(n))r!=="unknownFields"&&(r in e||(e[r]=i));return delete e.unknownFields,t}function $o(t){let e=t,n=lh(e.unknownFields)?e.unknownFields:void 0;for(let r of Object.keys(e)){if(r==="unknownFields"||r in wt)continue;let i=e[r];delete e[r],i!==void 0&&((n??={})[r]=i)}return n&&Object.keys(n).length>0?e.unknownFields=n:delete e.unknownFields,t}function Jd(t){let e=t,n,r=e.unknownFields;if(lh(r))for(let[i,o]of Object.entries(r))i==="unknownFields"||i in wt||o===void 0||((n??={})[i]=o);for(let i of Object.keys(e)){if(i==="unknownFields"||i in wt)continue;let o=e[i];o!==void 0&&((n??={})[i]=o)}return n}var HI=["migration","validation","normalization","canonical-node-construction","document-section-staging"];function WI(t,e,n,r,i){e.set(t.id,t),n.push({id:t.id,parentId:r,index:i});let o=t.state.children;Array.isArray(o)&&o.forEach((s,a)=>WI(s,e,n,t.id,a))}function RD(t,e){let n=new Map,r=[];t.shapes.forEach((l,d)=>WI(l,n,r,null,d));let i=new Map(r.map(l=>[l.id,l])),o=new Set,s=[];for(let l of t.sceneTree??[])o.has(l.id)||(o.add(l.id),s.push(structuredClone(l)));for(let l of r)o.has(l.id)||(o.add(l.id),s.push(structuredClone(l)));let a=new Set(s.map(l=>l.id)),c=new Map;for(let l of s){let d=i.get(l.id),u=e||l.parentId===null||a.has(l.parentId)?l.parentId:d?.parentId??null,p=c.get(u)??[];p.push({...l,parentId:u}),c.set(u,p)}t.sceneTree=[...c.values()].flatMap(l=>ut(l).map((d,u)=>{let p={...d,index:u};return p.orderKey===void 0&&delete p.orderKey,p.updatedAt===void 0&&delete p.updatedAt,p.clientId===void 0&&delete p.clientId,p}))}function CD(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function $D(t,e){if(e===!1||t.shapes.find(u=>u.type==="svg"&&u.state.isRootSvg===!0))return;let r=new Set((t.sceneTree??[]).filter(u=>u.parentId===null).map(u=>u.id)),i=(t.sceneTree?.length??0)>0;if(t.shapes.some(u=>u.type==="svg"&&u.state.isRootSvg!==!0&&(!i||r.has(u.id))))return;let s=e?.width??800,a=e?.height??600,c=new Set,l=u=>{for(let p of u){c.add(p.id);let f=p.state.children;Array.isArray(f)&&l(f)}};l(t.shapes);let d=CD(e?.idBase??"document-root",c);t.shapes.unshift({id:d,type:"svg",state:{isRootSvg:!0,svgWidth:s,svgHeight:a,svgViewBoxX:0,svgViewBoxY:0,svgViewBoxWidth:s,svgViewBoxHeight:a,svgPreserveAspectRatio:"xMidYMid meet"}}),t.sceneTree&&t.sceneTree.length>0&&(t.sceneTree=[{id:d,parentId:null,index:0},...t.sceneTree.map(u=>u.parentId===null?{...u,index:u.index+1}:u)])}function ND(t){let e=new Set,n=r=>{let i=r.state.children;if(Array.isArray(i))for(let o of i)e.add(o.id),n(o)};t.shapes.forEach(n),t.shapes=t.shapes.filter(r=>!e.has(r.id))}function KI(t,e){RD(t,e.preserveUnresolvedParents),e.materializeClipMaskStructure&&er(t),ii(t),ND(t)}function XI(t){let e=structuredClone(t);return KI(e,{materializeClipMaskStructure:!1,preserveUnresolvedParents:!0}),e}function AD(t){let e=new Map,n=r=>{if(e.has(r.id))return;e.set(r.id,r);let i=r.state.children;Array.isArray(i)&&i.forEach(n)};return t.forEach(n),e}var ED=/^structural:(clip|mask):(.+):(group|path|content)$/;function MD(t,e,n,r){let i=new yr,o=AD(t.shapes);for(let s of o.values()){let a=e===null||e.has(s.type),c=structuredClone(s);a&&c.state.children&&delete c.state.children;let l=Yt.fromSerialized(c);a||(l.preserveSerializedState(s.state),r.push(s.id),n.push({severity:"warning",code:"unavailable-shape-descriptor",source:"native-document",entrypoint:"full-snapshot-restore",message:`No shape descriptor is available for ${s.type}.`,documentPath:`shapes.${s.id}`,shapeId:s.id})),i.addNode(l)}for(let s of t.sceneTree??[]){if(i.getNode(s.id))continue;let a=ED.exec(s.id);if(!a)continue;let[,c,l,d]=a,u=t.clipMaskGroups?.find(f=>f.type===c&&f.id===l),p={structural:!0};d==="group"&&u&&(p.clipMaskDefId=At(u)),i.addNode(Yt.fromSerialized({id:s.id,type:`${c}-${d}-structure`,state:p}))}for(let s of t.sceneTree??[])i.getNode(s.id)&&i.moveNodeToParentId(s.id,s.parentId,s.index);return i.clearAllDirty(),i}function YI(t,e={}){let n=null,r=null;try{let i=structuredClone(t);i=Co(i),i=To(i),e.injectFault?.("migration"),i=$o(i),ya(i,"full-snapshot-restore",{includeWarnings:!1}),Po(i),$D(i,e.rootFrame),KI(i,{materializeClipMaskStructure:!0,preserveUnresolvedParents:!1});let o=ya(i,"full-snapshot-restore").filter(l=>l.code!=="unavailable-shape-descriptor");e.injectFault?.("validation"),e.injectFault?.("normalization");let s=[],a=e.availableShapeTypes?new Set(e.availableShapeTypes):null;n=MD(i,a,o,s),e.injectFault?.("canonical-node-construction"),r=new vr(n),r.loadSections(i),e.injectFault?.("document-section-staging");let c=oi.own(r,e.identity);return c.assertCoherent(),{document:c,snapshot:structuredClone(i),diagnostics:Object.freeze(structuredClone(o)),unavailableNodeIds:Object.freeze([...s])}}catch(i){throw r?r.dispose():n?.dispose(),i}}function dh(t){return t.easing==="custom-bezier"&&t.customBezier?t.customBezier:Xr[t.easing]??null}function uh(t,e,n,r,i){if(t===e&&n===r)return i;let o=1e-6,s=8,a=f=>(((1-3*n+3*t)*f+(3*n-6*t))*f+3*t)*f,c=f=>(((1-3*r+3*e)*f+(3*r-6*e))*f+3*e)*f,l=f=>(3*(1-3*n+3*t)*f+2*(3*n-6*t))*f+3*t,d=i;for(let f=0;f<s;f++){let m=a(d)-i;if(Math.abs(m)<o)return c(d);let g=l(d);if(Math.abs(g)<o)break;d-=m/g}let u=0,p=1;for(d=i;u<p;){let f=a(d);if(Math.abs(f-i)<o)return c(d);i>f?u=d:p=d;let m=(p-u)*.5+u;if(m===d)break;d=m}return c(d)}function Oa(t){let e=t.split(/\s+/).map(parseFloat);if(e.length!==4||e.some(s=>!Number.isFinite(s)))return t;let[n,r,i,o]=e;return`${1-i} ${1-o} ${1-n} ${1-r}`}function Tt(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?"0":Math.abs(t-1)<1e-9?"1":parseFloat(t.toFixed(6)).toString()}function Pu([t,e,n,r]){let i=o=>Number.isFinite(o)?parseFloat(o.toFixed(6)).toString():"0";return`${i(t)} ${i(e)} ${i(n)} ${i(r)}`}function ph(t){return t.length>0&&t.every(e=>e==="0 0 1 1")}function Da(t){if(t.length<2)return!1;let e=t.length-1,n=1e-4;for(let r=0;r<t.length;r++){let i=r/e,o=parseFloat(t[r]);if(!Number.isFinite(o)||Math.abs(o-i)>n)return!1}return!0}function Tu(t){if(t.length<2)return!1;let e=t.length-1,n=1e-4;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-r/e)>n)return!1;return!0}function fr(t){let e=t.cycleDuration??(t.keyframes.length>0?t.keyframes[t.keyframes.length-1].time:0);return t.cycleBehavior==="alternate"||t.cycleBehavior==="alternate-reverse"?e*2:e}function Ni(t){let e=t.beginTrigger;if(e)switch(e.type){case"time":{let r=parseFloat(e.value);return Number.isNaN(r)?"":Number.isFinite(r)?r!==0?`${r}s`:"":"indefinite"}case"event":return e.value;case"expression":return"";default:break}let n=t.keyframes[0]?.time??0;return n!==0?`${n}s`:""}function za(t){return t.keyframes.length===1&&t.cycleDuration===void 0}function _a(t){return t.calcMode!=="discrete"?!1:t.sourceSmilElement==="set"?!0:!t.sourceSmilElement&&!t.cycleInfinite&&t.keyframes.every(e=>e.easing!=="steps")}function Ru(t,e){if(e<=0)return Ni(t);if(Ni(t)==="indefinite")return"indefinite";let n=t.keyframes[e]?.time??0;return n!==0?`${n}s`:""}function Cu(t){if(t.cycleInfinite)return"indefinite";let e=t.cycleRepeats??1,n=t.cycleBehavior==="alternate"||t.cycleBehavior==="alternate-reverse"?e/2:e;return n===1?null:String(n)}function Wr(t){return t.cycleInfinite||t.fill==="remove"?null:"freeze"}function Fa(t){return t.additive==="sum"?"sum":null}function $u(t){return t.keyframes.map(e=>{let n=typeof e.value=="number"?e.value:parseFloat(String(e.value));return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0})}function OD(t){let e=n=>Math.max(0,Math.min(1,n));return[t[0],e(t[1]),t[2],e(t[3])]}function DD(t){let[e,n,r,i]=t,o=new Set,s=8;for(let u=1;u<=s;u++)o.add(u/s);let a=n-2*i+1,c=2*(i-2*n),l=n,d=u=>{if(!Number.isFinite(u)||u<=0||u>=1)return;let p=3*(1-u)**2*u*e+3*(1-u)*u**2*r+u**3;p>0&&p<1&&o.add(Number(p.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(c)>=1e-9&&d(-l/c);else{let u=c*c-4*a*l;if(u>=0){let p=Math.sqrt(u);d((-c+p)/(2*a)),d((-c-p)/(2*a))}}return[...o].sort((u,p)=>u-p)}function zD(t,e,n,r,i,o){let s=typeof t.value=="number"&&typeof e.value=="number",a=Hr(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(s){let h=e.linearPoints;for(let y=1;y<h.length;y++){let b=h[y],v=t.time+(e.time-t.time)*b.position,I=t.value+(e.value-t.value)*b.value;r.push(I),i.push(Tt(n(v))),o.push("0 0 1 1")}return}r.push(a),i.push(Tt(n(e.time))),o.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(Tt(n(e.time))),o.push("0 0 1 1");return}let c=dh(e);if(!c){r.push(a),i.push(Tt(n(e.time))),o.push("0 0 1 1");return}let[,l,,d]=c;if(!(l<0||l>1||d<0||d>1)){r.push(a),i.push(Tt(n(e.time))),o.push(Pu(c));return}if(!s){r.push(a),i.push(Tt(n(e.time))),o.push(Pu(OD(c)));return}let p=DD(c),f=t.value,m=e.value,g=e.time-t.time;for(let h of p){let y=uh(c[0],c[1],c[2],c[3],h),b=t.time+g*h,v=f+(m-f)*y;r.push(v),i.push(Tt(n(b))),o.push("0 0 1 1")}}function Hr(t){return Array.isArray(t)?t.join(" "):t}function _D(t,e,n){let r=[],{count:i,position:o}=n,s=e.time-t.time,a=Hr(t.value),c=Hr(e.value),l=typeof a=="number"&&typeof c=="number",d=typeof a=="string"&&typeof c=="string",u=m=>d?m<.5?a:c:l?a+(c-a)*m:m>=1?c:a,p=m=>{let g=Math.floor(m*i);(o==="jump-start"||o==="jump-both")&&(g+=1);let h;switch(o){case"jump-start":case"jump-end":h=i;break;case"jump-none":h=i-1;break;case"jump-both":h=i+1;break}return g>h&&(g=h),g<0&&(g=0),g/h},f=p(0);for(let m=1;m<=i;m++){let g=m/i,h=p(g);if(h===f)continue;let y=t.time+g*s;r.push({value:u(h),time:y}),f=h}return r.length===0||r[r.length-1].time<e.time?r.push({value:c,time:e.time}):r[r.length-1]={value:c,time:e.time},r}function FD(t,e){let n=[],r=[],i=(o,s)=>{n.push(o),r.push(Tt(e(s)))};i(Hr(t[0].value),t[0].time);for(let o=1;o<t.length;o++){let s=t[o-1],a=t[o];if(a.easing==="steps"&&a.stepsParams){let c=_D(s,a,a.stepsParams);for(let l of c)i(l.value,l.time)}else i(Hr(a.value),a.time)}return{values:n,keyTimes:r}}function LD(t,e,n){return{values:t.slice().reverse(),keyTimes:e.slice().reverse().map(r=>Tt(1-parseFloat(r))),keySplines:n.slice().reverse().map(Oa)}}function ku(t,e,n,r,i){let o=i.cycleBehavior??"restart";if(o==="restart"||t.length<2)return{values:t,keyTimes:e,keySplines:n,calcMode:r};if(o==="reverse")return{...LD(t,e,n),calcMode:r};if(o==="alternate-reverse"){let l=t.slice().reverse(),d=e.slice().reverse().map(p=>Tt(.5-parseFloat(p))),u=n.slice().reverse().map(Oa);return{values:[...l,...t.slice(1)],keyTimes:[...d,...e.slice(1).map(p=>Tt(.5+parseFloat(p)))],keySplines:[...u,...n],calcMode:r}}let s=t.slice(0,-1).reverse(),a=e.slice(0,-1).reverse().map(l=>Tt(1-parseFloat(l))),c=n.slice().reverse().map(Oa);return{values:[...t,...s],keyTimes:[...e,...a],keySplines:[...n,...c],calcMode:r}}function mr(t){let e=t.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let n=fr(t),r=e[0]?.time??0,i=l=>n>0?(l-r)/n:0;if(e.some(l=>l.easing==="steps")){let{values:l,keyTimes:d}=FD(e,i);return ku(l,d,[],"discrete",t)}if(t.calcMode==="discrete"){let l=e.map(u=>Hr(u.value)),d=e.map(u=>Tt(i(u.time)));return ku(l,d,[],"discrete",t)}if(t.calcMode==="paced"){let l=e.map(u=>Hr(u.value)),d=e.map(u=>Tt(i(u.time)));return ku(l,d,[],"paced",t)}let s=[Hr(e[0].value)],a=[Tt(i(e[0].time))],c=[];for(let l=1;l<e.length;l++)zD(e[l-1],e[l],i,s,a,c);return ku(s,a,c,"spline",t)}function La(t,e={}){let n=e.defaultCalcMode??"linear",r={};if(t.calcMode==="paced")return n!=="paced"&&(r.calcMode="paced"),r;if(t.calcMode==="discrete")return r.keyTimes=t.keyTimes.join(";"),r.calcMode="discrete",r;let i=t.keySplines.length>0&&!ph(t.keySplines);return Da(t.keyTimes)||(r.keyTimes=t.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=t.keySplines.join(";")),r}function fh(t,e){if(t.shapeId!==e.shapeId||t.keyframes.length!==e.keyframes.length||(t.cycleDuration??-1)!==(e.cycleDuration??-1)||(t.cycleRepeats??1)!==(e.cycleRepeats??1)||!!t.cycleInfinite!=!!e.cycleInfinite||(t.cycleBehavior??"restart")!==(e.cycleBehavior??"restart")||(t.additive??"replace")!==(e.additive??"replace")||(t.calcMode??"linear")!==(e.calcMode??"linear")||!!t.locked!=!!e.locked)return!1;let n=(r,i)=>!r&&!i||!!r&&!!i&&r.type===i.type&&r.value===i.value;if(!n(t.beginTrigger,e.beginTrigger)||!n(t.endTrigger,e.endTrigger))return!1;for(let r=0;r<t.keyframes.length;r++){let i=t.keyframes[r],o=e.keyframes[r];if(i.time!==o.time||i.easing!==o.easing)return!1;let s=i.customBezier,a=o.customBezier;if(!!s!=!!a)return!1;if(s&&a){for(let c=0;c<4;c++)if(s[c]!==a[c])return!1}if(JSON.stringify(i.linearPoints??null)!==JSON.stringify(o.linearPoints??null)||JSON.stringify(i.stepsParams??null)!==JSON.stringify(o.stepsParams??null))return!1}return!0}function Nu(t){let e=new Map,n=new Set,r=new Map;for(let i of t){if(!i.enabled||i.keyframes.length<2||i.property!=="translateX"&&i.property!=="translateY"&&i.property!=="scaleX"&&i.property!=="scaleY")continue;let o=r.get(i.shapeId)??[];o.push(i),r.set(i.shapeId,o)}for(let i of r.values()){let o=new Set;for(let s=0;s<i.length;s++){let a=i[s];if(o.has(a.id))continue;let c=a.property==="translateX"||a.property==="translateY",l=c?"translateX":"scaleX",d=c?"translateY":"scaleY";if(!(a.property!==l&&a.property!==d))for(let u=s+1;u<i.length;u++){let p=i[u];if(o.has(p.id)||!(a.property===l&&p.property===d||a.property===d&&p.property===l)||!fh(a,p))continue;let f=a.property===l?a:p,m=a.property===d?a:p;e.set(f.id,m),n.add(m.id),o.add(f.id),o.add(m.id);break}}}return{partner:e,skip:n}}function Au(t,e,n,r){if(r){let o=e?r.values:t.values,s=e?t.values:r.values,a=Math.min(o.length,s.length),c=[];for(let l=0;l<a;l++)c.push(`${o[l]} ${s[l]}`);return c}let i=n?"1":"0";return t.values.map(o=>e?`${i} ${o}`:`${o} ${i}`)}var qI={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",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",display:"display",visibility:"visibility",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",pathMorph:"d",polylinePoints:"points"},ZI=new Set(["transformMatrix","rotation","skewX","skewY"]),JI=new Set(["translateX","translateY","scaleX","scaleY"]);function Mu(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Oe(t,e){return e==null?"":` ${t}="${Mu(e)}"`}function Ou(t,e){let n=La(t,e);return Oe("keyTimes",n.keyTimes)+Oe("calcMode",n.calcMode)+Oe("keySplines",n.keySplines)}function Ga(t,e){return Oe("dur",`${e}s`)+Oe("begin",Ni(t)||null)+Oe("repeatCount",Cu(t))}function Ba(t,e){let n=e??qI[t.property];if(!n)return"";let r=fr(t);if(r<=0)return"";let i=mr(t);return i.values.length<2?"":"<animate"+Oe("attributeName",n)+Oe("values",i.values.join(";"))+Ou(i)+Ga(t,r)+Oe("fill",Wr(t))+"/>"}function BD(t,e){let n;switch(t.property){case"transformMatrix":n="matrix";break;case"rotation":n="rotate";break;case"skewX":n="skewX";break;case"skewY":n="skewY";break;default:return""}let r=fr(t);if(r<=0)return"";let i=mr(t),o=n==="matrix"?i.values.map(c=>VD(c)):i.values.map(c=>String(c));if(o.length<2||o.some(c=>c.length===0))return"";let s=n==="rotate"&&t.transformOrigin?o.map(c=>`${c} ${t.transformOrigin.x} ${t.transformOrigin.y}`):o,a=t.replacesCarrierBase&&e?"sum":Fa(t);return'<animateTransform attributeName="transform"'+Oe("type",n)+Oe("values",s.join(";"))+Ou(i)+Ga(t,r)+Oe("additive",a)+Oe("fill",Wr(t))+"/>"}function GD(t,e,n){let r=t.property==="scaleX"||t.property==="scaleY",i=t.property==="translateY"||t.property==="scaleY",o=r?"scale":"translate",s=fr(t);if(s<=0)return"";let a=mr(t);if(a.values.length<2)return"";let c=e?mr(e):void 0,l=Au(a,i,r,c);if(l.length<2)return"";let d=!t.replacesCarrierBase||n?"sum":null;return'<animateTransform attributeName="transform"'+Oe("type",o)+Oe("values",l.join(";"))+Ou(a)+Ga(t,s)+Oe("additive",d)+Oe("fill",Wr(t))+"/>"}function VD(t){if(Array.isArray(t)&&t.length>=6){let e=t.slice(0,6);if(e.every(n=>typeof n=="number"&&Number.isFinite(n)))return e.join(" ")}if(typeof t=="string"){let e=t.trim(),n=/^matrix\(([^)]+)\)$/i.exec(e),i=(n?n[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 jD(t){if(!t.motionPath)return"";let e=fr(t);if(e<=0)return"";let n=mr(t),r=$u(t),i=!!t.motionPathRef&&(t.motionPathRef.mode??"trackShape")==="curveTemplate",o=La(n,{defaultCalcMode:"paced"}),s=Tu(r)&&Da(n.keyTimes)&&n.calcMode!=="discrete"&&o.calcMode===void 0,a="<animateMotion";return i||(a+=Oe("path",t.motionPath)),a+=Oe("keyTimes",o.keyTimes),s||(a+=Oe("keyPoints",r.join(";"))),a+=Oe("calcMode",o.calcMode)+Oe("keySplines",o.keySplines),a+=Ga(t,e),a+=Oe("fill",Wr(t)),t.motionRotate!==void 0&&(a+=Oe("rotate",typeof t.motionRotate=="number"?String(t.motionRotate):t.motionRotate)),i?a+=`><mpath href="#${Mu(t.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function Eu(t,e,n){if(ZI.has(t.property)||JI.has(t.property)||t.property==="pathMotion")return"";let r=n??(t.property==="domAttribute"?t.domAttribute:qI[t.property]);if(!r)return"";let i=t.keyframes[e];return i?"<set"+Oe("attributeName",r)+Oe("to",Array.isArray(i.value)?i.value.join(" "):String(i.value))+Oe("begin",Ru(t,e)||null)+"/>":""}function QI(t,e){let n={...t,locked:t.locked??!1,keyframes:[...t.keyframes].sort((r,i)=>r.time-i.time).map(r=>({...r,easing:r.easing}))};return!n.enabled||n.keyframes.length===0?"":za(n)?Eu(n,0,e):_a(n)?n.keyframes.map((r,i)=>Eu(n,i,e)).join(""):n.keyframes.length<2?"":Ba(n,e)}function UD(t){let e=Ni(t);return e?`<discard begin="${Mu(e)}"/>`:"<discard/>"}function HD(t){if(!t.transformFunction)return"";let e=fr(t);if(e<=0)return"";let n=mr(t);return n.values.length<2?"":'<animateTransform attributeName="transform"'+Oe("type",t.transformFunction)+Oe("values",n.values.join(";"))+Ou(n)+Ga(t,e)+Oe("additive",Fa(t))+Oe("fill",Wr(t))+"/>"}function Va(t){let e=new Map,n=t.tracks.map(l=>({...l,locked:l.locked??!1,keyframes:[...l.keyframes].sort((d,u)=>d.time-u.time).map(d=>({...d,time:d.time,value:d.value,easing:d.easing}))})),r=[...n.flatMap(l=>{let d=uf(l);return d?[d]:[]}),...n],i=Nu(r),o=new Set,s=new Set,a=new Set,c=(l,d,u)=>{if(!d)return;let p=d;u.sourceSmilId&&!o.has(u.sourceSmilId)&&(o.add(u.sourceSmilId),p=d.replace(/^(<[a-zA-Z]+)/,`$1 id="${Mu(u.sourceSmilId)}"`));let f=e.get(l)??[];f.push(p),e.set(l,f)};for(let l of r){if(!l.enabled||i.skip.has(l.id)||l.keyframes.length<1)continue;if(l.property==="discard"){c(l.shapeId,UD(l),l);continue}if(za(l)){c(l.shapeId,Eu(l,0),l);continue}if(_a(l)){for(let p=0;p<l.keyframes.length;p++)c(l.shapeId,Eu(l,p),l);continue}if(l.keyframes.length<2)continue;let d=l.id.endsWith(":backwards-fill")?s:a,u="";l.property==="domTransformStack"?u=HD(l):l.property==="domAttribute"&&l.domAttribute?u=Ba(l,l.domAttribute):l.property==="domDisplay"?u=Ba(l,"display"):l.property==="domVisibility"?u=Ba(l,"visibility"):l.property==="pathMotion"&&l.motionPath?u=jD(l):ZI.has(l.property)?(u=BD(l,d.has(l.shapeId)),u&&d.add(l.shapeId)):JI.has(l.property)?(u=GD(l,i.partner.get(l.id),d.has(l.shapeId)),u&&d.add(l.shapeId)):u=Ba(l),c(l.shapeId,u,l)}return e}function WD(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function KD(t){return!t.domTargetSelector||!t.shapeId.startsWith("__dom__")?null:t.shapeId.slice(7)||null}function Du(t,e,n){if(!t||!e)return t;let r=n??Va(e),i=new Map;for(let s of e.tracks){if(!s.enabled||!s.template||!s.domTargetSelector)continue;let a=KD(s);a&&!i.has(s.shapeId)&&i.set(s.shapeId,a)}let o=t;for(let[s,a]of i){let c=r.get(s)?.join("")??"";if(!c)continue;let l=WD(a),d=new RegExp(`<([A-Za-z_][\\w:.-]*)([^>]*\\bid=(['"])${l}\\3[^>]*?)(\\s*/?)>`,"u");o=o.replace(d,(u,p,f,m,g)=>g.includes("/")?`<${p}${f}>${c}</${p}>`:`<${p}${f}>${c}`)}return o}function _u(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(_u).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${_u(n)}`).join(",")}}`}function zu(t,e,n){for(let r of t){r.type==="symbol-instance"&&n(r,e);let i=r.state.children;if(!Array.isArray(i))continue;let o=e;r.type==="svg"&&(o=Gr(r,e).viewport.childPercentBasis??e),zu(i,o,n)}}function Fu(t,e,n={}){let r=n.reservedIds??new Set,i=yo(t),o=new Map,s=[],a=new WeakMap,c=new Map,l=[],d=(R,$)=>{a.set(R,$);let A=c.get(R.id);A?A.push($):c.set(R.id,[$]),l.push(...$.diagnostics)},u=(R,$,A)=>{if(a.has(R))return;let O=String(R.state.symbolId??"").trim(),G=O!==""&&i.duplicateIds.has(O),M=O?i.symbol(O):void 0;if(G||!M){d(R,{targetId:null,definition:null,materializationKey:null,materialization:null,parentViewport:A,viewport:null,diagnostics:[{code:G?"duplicate-library-id":"unresolved-symbol-definition",shapeId:R.id,message:G?`Symbol instance ${R.id} targets duplicate library id ${O}.`:`Symbol instance ${R.id} targets missing symbol definition ${O||"(blank)"}.`}]});return}let V=n.instancePolicy?.(R),X=V?.initialVariantKey===void 0?R:{...R,state:{...R.state,variantKey:V.initialVariantKey}},Y=fi(M,X),U=V?.dedicated===!0,te=bo(R,M,A,n.viewportHost);if($.includes(Y.materializationKey)){d(R,{targetId:null,definition:M,materializationKey:Y.materializationKey,materialization:null,parentViewport:A,viewport:te,diagnostics:[...Y.diagnostics,{code:"symbol-cycle",shapeId:R.id,message:`Symbol instance cycle detected through ${M.id}.`}]});return}let Z=A?`${A.width},${A.height}`:"none",ne=`${Y.materializationKey}\0path=${$.join("")}\0viewport=${Z}`+(U?`\0dedicated=${R.id}`:""),F=o.get(ne);if(!F){let oe=structuredClone(Y.shapes);F={occurrenceKey:ne,materializationKey:Y.materializationKey,candidateTargetId:U?`${M.id}--ovr-${R.id}`:Y.candidateTargetId,targetId:U?`${M.id}--ovr-${R.id}`:Y.candidateTargetId,definition:M,shapes:oe,materialized:Y.materialized||U,forcedDedicated:U,activeDepth:$.length,parentViewport:A,viewport:te},o.set(ne,F),s.push(F)}let j={targetId:F.targetId,definition:M,materializationKey:Y.materializationKey,materialization:null,diagnostics:Y.diagnostics,parentViewport:A,viewport:te,pending:F};d(R,j);let H=[...$,Y.materializationKey];zu(F.shapes,F.viewport.childPercentBasis??A,(oe,re)=>u(oe,H,re))};zu(e,n.parentViewport,(R,$)=>{u(R,[],$)});let p=new Map,f=new Map,m=new Set,g=R=>{let $=p.get(R);if($)return $;if(m.has(R))throw new Error(`Materialization occurrence graph retained a cycle at ${R.occurrenceKey}.`);m.add(R);let A=[];zu(R.shapes,R.viewport.childPercentBasis??R.parentViewport,M=>{let V=a.get(M);if(V?.pending){A.push(`resolved:${g(V.pending)}`);return}A.push(_u({materializationKey:V?.materializationKey??null,diagnostics:V?.diagnostics.map(X=>X.code)??["missing-resolution"]}))}),m.delete(R);let O=_u({materializationKey:R.materializationKey,nested:A,forcedOccurrence:R.forcedDedicated?R.occurrenceKey:null}),G=f.get(O);return G||(G=`materialization-signature:${f.size+1}`,f.set(O,G)),p.set(R,G),G},h=(R,$)=>R.activeDepth-$.activeDepth||R.candidateTargetId.localeCompare($.candidateTargetId)||R.occurrenceKey.localeCompare($.occurrenceKey),y=new Map;for(let R of s){let $=g(R),A=y.get($);(!A||h(R,A)<0)&&y.set($,R)}let b=new Map;for(let R of s)b.set(R,y.get(g(R)));let v=s.filter(R=>b.get(R)===R),I=new Map;for(let R of v){let $=I.get(R.materializationKey);(!$||$.forcedDedicated&&!R.forcedDedicated||$.forcedDedicated===R.forcedDedicated&&h(R,$)<0)&&I.set(R.materializationKey,R)}let x=R=>R.forcedDedicated||R.materialized||I.get(R.materializationKey)!==R,k=new Set(v.filter(R=>!x(R)).map(R=>R.definition.id)),T=new Set([...r,...k,...v.filter(x).map(R=>R.candidateTargetId)]),w=new Set([...r,...k]);for(let R of v){if(!x(R)){R.targetId=R.definition.id;continue}let $=R.candidateTargetId,A=$;if(w.has(A)){let O=2;do A=`${$}-${O++}`;while(T.has(A)||w.has(A))}R.targetId=A,w.add(A)}let P=new Map,N=v.map(R=>{let $={materializationKey:R.materializationKey,targetId:R.targetId,candidateTargetId:R.candidateTargetId,definition:R.definition,shapes:R.shapes,parentViewport:R.parentViewport,viewport:R.viewport};return P.set(R,$),$});for(let R of s){let $=b.get(R),A=P.get($);R.targetId=A.targetId,R!==$&&P.set(R,{materializationKey:R.materializationKey,targetId:A.targetId,candidateTargetId:R.candidateTargetId,definition:R.definition,shapes:R.shapes,parentViewport:R.parentViewport,viewport:R.viewport})}for(let R of c.values())for(let $ of R)$.pending&&($.targetId=$.pending.targetId,$.materialization=P.get($.pending)??null,delete $.pending);return{materializations:N,diagnostics:l,resolve(R){let $=a.get(R);if($)return $;let A=c.get(R.id);return A?.length===1?A[0]:void 0}}}var XD="text/css";function ja(t){return t.includes("{")?t.replace(/([^{}]*)\{([^{}]*)\}/g,(e,n,r)=>{let i=ew(r);if(i===r)return e;let o=String(n).trim();return!/^(?:from|to|[\d.]+%)(?:\s*,\s*(?:from|to|[\d.]+%))*$/i.test(o)&&!/[^\s;]/.test(i)?"":`${n}{${i}}`}):ew(t)}var YD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?animation(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,qD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?transition(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,ZD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?(?:transform-origin|transform-box)\s*:[^;]*(?:;|$)/gi;function ew(t){let e=!1,n=t.replace(YD,r=>(e=!0,mh(r)));return n=n.replace(qD,r=>mh(r)),e&&(n=n.replace(ZD,r=>mh(r))),n}function mh(t){return t.startsWith(";")?";":""}function JD(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function tw(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;")}function Ua(t){let e=t.map(({name:n,defaultValue:r})=>` --${n}: ${r};`);return e.length?`:root, svg {
43
+ ${e.join(`
44
+ `)}
45
+ }
46
+ `:""}function Lu(t){if(!t||t.length===0)return"";let e=Ua(t);return e?`<style id="svgsketch-variables">${tw(e)}</style>`:""}function Bu(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=new Map;if(n.svgId&&r.set("id",n.svgId),n.type&&n.type!==XD&&r.set("type",n.type),n.media&&r.set("media",n.media),n.customAttrs)for(let[o,s]of Object.entries(n.customAttrs))r.has(o)||r.set(o,s);let i="<style";for(let[o,s]of r)i+=` ${o}="${JD(s)}"`;i+=`>${tw(ja(n.css))}</style>`,e.push(i)}return e.join("")}function QD(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function ez(t){return t?t.includes("]]>")?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):/[<&>]/.test(t)?`<![CDATA[${t}]]>`:t:""}function Gu(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=new Map;if(n.svgId&&r.set("id",n.svgId),n.type&&r.set("type",n.type),n.source==="external"&&n.href&&r.set("href",n.href),n.crossorigin&&r.set("crossorigin",n.crossorigin),n.async&&r.set("async",""),n.defer&&r.set("defer",""),n.customAttrs)for(let[o,s]of Object.entries(n.customAttrs))r.has(o)||r.set(o,s);let i="<script";for(let[o,s]of r)i+=` ${o}="${QD(s)}"`;n.source==="inline"&&n.content?i+=`>${ez(n.content)}</script>`:i+="/>",e.push(i)}return e.join("")}function tz(t){return t.replace(new RegExp(`\\s+${ps}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function gh(t,e){let n=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/g,r;for(;(r=n.exec(t))!==null;)e.add(r[1]);let i=/\b(?:xlink:)?href\s*=\s*(?:"#([^"]+)"|'#([^']+)')/g;for(;(r=i.exec(t))!==null;)e.add(r[1]??r[2])}function Vu(t,e,n=[],r=new Set){let i=new Map;for(let l of t.paintServerDefs??[]){if(!l||typeof l.markup!="string")continue;let d=l.id??fs(l.markup);!d||r.has(d)||i.set(d,{id:d,markup:tz(l.markup),passthrough:l.passthrough===!0})}if(i.size===0)return"";let o=new Set;gh(e,o);for(let l of n)gh(l,o);let s=new Map;for(let l of i.values())l.passthrough&&s.set(l.id,l);let a=!0;for(;a;){a=!1;for(let l of i.values())s.has(l.id)||!o.has(l.id)||(s.set(l.id,l),a=!0);for(let l of s.values()){let d=o.size;gh(l.markup,o),o.size>d&&(a=!0)}}if(s.size===0)return"";let c=[];for(let l of i.values())s.has(l.id)&&c.push(l.markup);return c.join("")}function ju(t){let e=new Set;for(let n of t??[])e.add(n.definitionId??`${n.type}-${n.id}`);return e}var nz={defsMarkup:"",suppressedShapeIds:new Set,memberToDirective:new Map};function sn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function Wa(t){return t.definitionId??`${t.type}-${t.id}`}function hh(t,e){let n=0;for(;n<t.length;){let l=/^\s+/.exec(t.slice(n));if(l){n+=l[0].length;continue}if(!t.startsWith("<!--",n))break;let d=t.indexOf("-->",n+4);if(d<0)return t;n=d+3}let r=t.slice(n),i=/^<([A-Za-z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(r);if(!i)return t;let[o,s,a,c]=i;return t.slice(0,n)+`<${s}${e(a)}${c}>`+r.slice(o.length)}function rz(t,e){return hh(t,n=>{let r=n.replace(/\s+id\s*=\s*(?:"[^"]*"|'[^']*')/,"");return` id="${sn(e)}"${r}`})}function Ha(t,e){return t.replace(new RegExp(`\\s+${e}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function iz(t,e,n){return hh(t,r=>{let i=Ha(r,"data-shape-id");if(e==="clip"){let o=/\bfill-rule\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(i);i=Ha(i,"fill-rule"),i=Ha(i,"clip-rule"),i=Ha(i,"fill"),i=i.replace(/\s+stroke(?:-[a-z-]+)?\s*=\s*(?:"[^"]*"|'[^']*')/g,""),i+=' fill="black"';let s=n??o?.[1]??o?.[2];s&&(i+=` clip-rule="${sn(s)}"`)}return i})}function Uu(t){let e=t.clipMaskGroups;if(!Array.isArray(e)||e.length===0)return nz;let n=new Map;for(let c of t.shapes??[])dn(c,{onShape:l=>n.set(l.id,l)});let r=Hn(Array.isArray(t.library)?t.library:[]),i=new Set,o=new Map,s=new Set,a=[];for(let c of e){if(!c||c.type!=="clip"&&c.type!=="mask")continue;let l=Wa(c),d=Array.isArray(c.clipShapeIds)?c.clipShapeIds:[];for(let p of d)i.add(p);if(!s.has(l)){if(typeof c.rawDefinition=="string"&&c.rawDefinition.length>0)s.add(l),a.push(rz(c.rawDefinition,l));else if(d.length>0){s.add(l);let p=c.type==="clip"?"clipPath":"mask",f=`<${p} id="${sn(l)}"`;c.type==="clip"?(c.clipPathUnits&&(f+=` clipPathUnits="${sn(c.clipPathUnits)}"`),c.clipRule&&(f+=` clip-rule="${sn(c.clipRule)}"`)):(c.maskUnits&&(f+=` maskUnits="${sn(c.maskUnits)}"`),c.maskContentUnits&&(f+=` maskContentUnits="${sn(c.maskContentUnits)}"`),c.maskBounds&&(f+=` x="${sn(c.maskBounds.x)}" y="${sn(c.maskBounds.y)}"`,f+=` width="${sn(c.maskBounds.width)}"`,f+=` height="${sn(c.maskBounds.height)}"`),c.maskType&&(f+=` mask-type="${sn(c.maskType)}"`)),f+=">";for(let m of d){let g=n.get(m);g&&(f+=iz(on(g,r),c.type,c.clipRule))}f+=`</${p}>`,a.push(f)}}let u=Array.isArray(c.contentShapeIds)?c.contentShapeIds:[];if(u.length>0){let p={attr:c.type==="clip"?"clip-path":"mask",defId:l,memberIds:u};for(let f of u)o.has(f)||o.set(f,p)}}return{defsMarkup:a.join(""),suppressedShapeIds:i,memberToDirective:o}}function Hu(t,e){return hh(t,n=>`${Ha(n,e.attr)} ${e.attr}="url(#${sn(e.defId)})"`)}function Ka(t,e){let n=t.state?.children;return!Array.isArray(n)||n.length===0?t:{...t,state:{...t.state,children:yh(n,e)}}}function yh(t,e){let n=t.filter(i=>!e.suppressedShapeIds.has(i?.id)).map(i=>Ka(i,e)),r=[];for(let i=0;i<n.length;){let o=n[i],s=e.memberToDirective.get(o.id);if(!s){r.push(o),i++;continue}let a=[o],c=i+1;for(;c<n.length&&e.memberToDirective.get(n[c].id)===s;)a.push(n[c]),c++;a.length===1?r.push(oz(o,s)):r.push(sz(a,s)),i=c}return r}function oz(t,e){let n=t.state,r={...n.authoredAttributes??{},[e.attr]:`url(#${e.defId})`};return{...t,state:{...n,authoredAttributes:r}}}function sz(t,e){return{id:`clipmask-wrapper:${e.defId}:${t[0].id}`,type:"group",state:{children:t,groupData:{[e.attr==="clip-path"?"clipPath":"mask"]:`url(#${e.defId})`}}}}function Vt(t){return t.library+t.builtinMarkers+t.symbols+t.motionPaths+t.paintServers+t.clipMask+t.inlineHoisted}function az(t){return ru.some(e=>e===t)}function cz(t,e){let n=nt(t);return n&&n.width>0&&n.height>0?{width:n.width,height:n.height}:e}function Sn(t,e={}){let{backgroundColor:n,includeScripts:r=!0}=e;if(t.sceneTree&&t.sceneTree.length>0){let L={...t,shapes:structuredClone(t.shapes??[])};ii(L),t=L}let i=t.shapes??[],o=i.find(L=>L.type==="svg"&&L.state?.isRootSvg===!0),s=o?.state,a=Number(s?.svgViewBoxWidth??0),c=Number(s?.svgViewBoxHeight??0),l=a>0&&c>0?{x:Number(s?.svgViewBoxX??0),y:Number(s?.svgViewBoxY??0),width:a,height:c,intrinsicWidth:Number(s?.svgWidth??0)>0?Number(s?.svgWidth):a,intrinsicHeight:Number(s?.svgHeight??0)>0?Number(s?.svgHeight):c,preserveAspectRatio:typeof s?.svgPreserveAspectRatio=="string"?s.svgPreserveAspectRatio.trim():""}:null,d=t.viewboxes?.[0],u=e.width??l?.intrinsicWidth??d?.width??800,p=e.height??l?.intrinsicHeight??d?.height??600,f=e.viewBox??(l?`${l.x} ${l.y} ${l.width} ${l.height}`:`0 0 ${u} ${p}`),m=e.preserveAspectRatio??l?.preserveAspectRatio??"",g=cz(f,l?{width:l.width,height:l.height}:{width:u,height:p}),h=new Set,y=L=>{for(let be of L??[])h.add(be.id),y(be.state?.children)};for(let L of i)y(L.state?.children);let b=i.filter(L=>L.state?.displayMode==="motionOnly"),v=i.filter(L=>L.state?.displayMode!=="motionOnly"&&L!==o&&!h.has(L.id)),I=new Set(b.filter(L=>Ya(L)!==null).map(L=>L.id)),x=t.animationTimeline?{...t.animationTimeline,tracks:t.animationTimeline.tracks.map(L=>{let be=L.motionPathRef;if(L.property!=="pathMotion"||!L.motionPath||!be||(be.mode??"trackShape")!=="curveTemplate"||I.has(be.shapeId))return L;let{motionPathRef:ce,...Re}=L;return Re})}:null,k=x?Va(x):null,T=Uu(t),w=Du(T.defsMarkup,x,k??void 0),P=uz(t),N=pz(t),R=Array.isArray(t.library)?t.library:[],$=fu({documentStyles:t.documentStyles,animationTimeline:x,clipMaskGroups:t.clipMaskGroups}),A=$a(v,R,$),O=A.filter(L=>L.kind!=="symbol"),G=yi(v,R);for(let L of $)G.ids.add(L);let M=Hn(R);M.textMeasurementHost=e.textMeasurementHost;let V;{let L=la(i),be=new Map,ce=new Set,Re=new Set,Ye=(W,Ie)=>{W&&Ie.add(W)};for(let W of L.ordered)W.type==="text"&&Ye(W.state?.shapeInsideRef,ce),W.type==="shape-reference"&&Ye(W.state?.targetShapeId,Re);let je=new Map;for(let W of L.ordered){let Ie=W.state?.metadata?.name,He=Ie?Gn(Ie):"",Se=ce.has(W.id)||Re.has(W.id);He?je.set(W,He):Se&&!L.duplicateIds.has(W.id)&&je.set(W,W.id)}let jt=new Set([...O.map(W=>W.id),...b.filter(W=>Ya(W)).map(W=>W.id),...(t.clipMaskGroups??[]).map(Wa)]);for(let[W,Ie]of Object.entries(wa)){let He=W.replace("line-marker-","");(G.legacyEndpoints.has(He)||G.ids.has(W))&&jt.add(W),G.ids.has(Ie)&&jt.add(Ie)}for(let W of L.ordered)W.type==="text"&&W.state.isTextPath&&W.state.textPathPoints&&jt.add(`text-path-${W.id}`);V=Fu(R,v,{reservedIds:new Set([...jt,...je.values()]),parentViewport:g,instancePolicy:(()=>{let W=e.symbolInstanceInitialVariants;if(!W||W.size===0)return;let Ie=new WeakMap;for(let[He,Se]of W){let dt=L.uniqueById.get(He);dt?.type==="symbol-instance"&&Ie.set(dt,Se)}return He=>{let Se=Ie.get(He);return Se===void 0?void 0:{initialVariantKey:Se,dedicated:!0}}})()});for(let W of V.materializations)jt.add(W.targetId);for(let W of V.diagnostics)Bt({severity:"warning",code:W.code,shapeId:W.shapeId,message:W.message});M.symbolInstanceTargetElementId=W=>V.resolve(W)?.targetId;let Xt=jn(t),ie=new WeakMap;M.symbolInstanceTransform=W=>{let Ie=ie.get(W);if(!Ie){let He=V.resolve(W);Ie=Ud(Xt,W,{},He?.parentViewport??g),ie.set(W,Ie);for(let Se of Ie.diagnostics)!["invalid-symbol-viewport","unresolved-symbol-viewport","unresolved-symbol-pivot"].includes(Se.code)||!az(Se.code)||Bt({severity:"warning",code:Se.code,shapeId:Se.shapeId,message:Se.message})}return Ie};let we=new Set([...je.values(),...jt]),$e=new Set(jt),Ue=new Map,it=new Map,cn=new Map;for(let[W,Ie]of je){let He=(Ue.get(Ie)??0)+1;Ue.set(Ie,He);let Se=Ie;if(He>1||$e.has(Se)){let dt=2;do Se=`${Ie}-${dt++}`;while(we.has(Se)||$e.has(Se))}it.set(W,Se),L.duplicateIds.has(W.id)||cn.set(W.id,Se),$e.add(Se)}for(let[W,Ie]of L.uniqueById){let He=it.get(Ie);He&&be.set(W,He)}if(it.size>0&&(M.elementIdForShape=W=>cn.get(W.id)??it.get(W)),ce.size>0&&(M.shapeInsideTargetElementId=W=>be.get(W)),Re.size>0){M.shapeReferenceTargetElementId=Se=>L.duplicateIds.has(Se)?null:be.get(Se);let W=jn(t),Ie=new WeakMap,He=new WeakMap;M.shapeReferenceBounds=Se=>{let dt=Ie.get(Se);return dt||(dt=Io(W,Se),Ie.set(Se,dt)),dt},M.shapeReferenceTransform=Se=>{let dt=He.get(Se);return dt||(dt=jd(W,Se),He.set(Se,dt)),dt}}}let X=new Map,Y=new Set,U=new Map(la(i).ordered.map(L=>[L.id,L]));for(let L of x?.tracks??[]){let be=/^(fill|stroke)GradientStop(\d+)(Color|Opacity|Offset)$/.exec(L.property);if(!be)continue;let ce=U.get(L.shapeId);if(!ce)continue;let Re=be[1],Ye=Number(be[2]),je=be[3],jt=ce.state?.[Re==="fill"?"fillGradient":"strokeGradient"],Xt=ce.state?.[Re==="fill"?"fillLibraryId":"strokeLibraryId"]??jt?.id;if(!Xt)continue;let ie=je==="Color"?"stop-color":je==="Opacity"?"stop-opacity":"offset",we=QI(L,ie);if(!we)continue;let $e=`${Xt}|${Ye}|${ie}|${we}`;if(Y.has($e))continue;Y.add($e);let Ue=X.get(Xt)??new Map,it=Ue.get(Ye)??[];it.push(we),Ue.set(Ye,it),X.set(Xt,Ue)}M.gradientStopAnimationElements=(L,be)=>X.get(L)?.get(be);let te=O.length>0?Ca(O,M):"",Z=V.materializations.filter(L=>L.targetId===L.definition.id).map(L=>zo(L.definition,L.targetId,L.shapes,M)).join(""),ne=new Set(V.materializations.filter(L=>L.targetId===L.definition.id).map(L=>L.definition.id)),F=A.filter(L=>L.kind==="symbol"&&!ne.has(L.id)).map(L=>Ta(L,M)).join(""),j=te+Z+F,H=pu(G,R),oe=V.materializations.filter(L=>L.targetId!==L.definition.id).map(L=>zo(L.definition,L.targetId,L.shapes,M)).join(""),re=fz(b),xe=n?`<rect width="${u}" height="${p}" fill="${n}"/>`:"",Ze={...M,animationElementsForShape:L=>k?.get(L.id)},rt=L=>{let be=on(L,Ze),ce=k?.get(L.id),Re=ce&&ce.length>0?ce:[];return{shape:L,markup:be,smil:Re}},Rt=v.filter(L=>!T.suppressedShapeIds.has(L.id)).map(L=>Ka(L,T)),lt=[];for(let L=0;L<Rt.length;){let be=Rt[L],ce=T.memberToDirective.get(be.id);if(!ce){lt.push({kind:"shape",...rt(be)}),L++;continue}let Re=[be],Ye=L+1;for(;Ye<Rt.length&&T.memberToDirective.get(Rt[Ye].id)===ce;)Re.push(Rt[Ye]),Ye++;if(Re.length===1){let je=rt(be);lt.push({kind:"shape",...je,markup:Hu(je.markup,ce)})}else lt.push({kind:"clip-mask-run",directive:ce,open:`<g ${ce.attr}="url(#${Sh(ce.defId)})">`,close:"</g>",members:Re.map(rt)});L=Ye}let Ve=iw(lt),E=(t.documentStyles??[]).map(L=>ja(L.css)),z=Ua(t.templateVariables??[]),B=Vu(t,Ve,[...E,z,w,j,oe,H,re],ju(t.clipMaskGroups)),se={rootAttributes:Cd(t.documentMetadata),descriptive:$d(t.documentMetadata),scripts:r?Gu(t.documentScripts):"",styles:Lu(t.templateVariables)+Bu(t.documentStyles),trailingComments:(t.documentMetadata?.trailingComments??[]).map(L=>`<!--${L.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")},me={frame:{width:u,height:p,viewBox:f,preserveAspectRatio:m,...e.omitFrameAttributes?{omit:e.omitFrameAttributes}:{}},defs:{library:j,builtinMarkers:H,symbols:oe,motionPaths:re,paintServers:B,clipMask:w,inlineHoisted:""},body:lt,motionOnlyShapes:b,backgroundRect:xe,envelope:se,strippedCssTexts:E,strippedDocumentCss:E.join(`
47
+ `).trim(),symbols:V};return dz(me),me}function iw(t){let e="";for(let n of t)if(n.kind==="shape")e+=n.markup;else{e+=n.open;for(let r of n.members)e+=r.markup;e+=n.close}return e}var nw=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/g,rw=/<(?:use|mpath|textPath)\b[^>]*?\s(?:xlink:)?href\s*=\s*"#([^"]+)"/g,lz=/\sid\s*=\s*"([^"]+)"/g;function Xa(t,e,n){for(let r of e.matchAll(t))n.add(r[1])}function dz(t){let e=new Set,n=[Vt(t.defs),iw(t.body),t.envelope.descriptive,t.envelope.styles];for(let s of n)Xa(lz,s,e);let r=(s,a)=>{for(let c of s)e.has(c)||Bt({severity:"warning",code:"unresolved-reference",message:a?`Unresolved reference "#${c}" on shape "${a}"; no definition with that id is emitted`:`Unresolved reference "#${c}"; no definition with that id is emitted`,...a?{shapeId:a}:{}})},i=s=>{let a=new Set;Xa(nw,s.markup,a),Xa(rw,s.markup,a),r(a,s.shape.id)};for(let s of t.body)if(s.kind==="shape")i(s);else for(let a of s.members)i(a);let o=new Set;Xa(nw,Vt(t.defs),o),Xa(rw,Vt(t.defs),o),r(o)}function uz(t){return(Array.isArray(t.library)?t.library:[]).filter(n=>n.kind==="symbol")}function pz(t){let n=(Array.isArray(t.library)?t.library:[]).filter(r=>r.kind==="marker");return n.length>0?n:void 0}function fz(t){if(t.length===0)return"";let e=[];for(let n of t){let r=Ya(n);r&&e.push(`<path id="${Sh(n.id)}" d="${Sh(r)}"/>`)}return e.join("")}function Sh(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Ya(t){return Ul(t)}function Vo(t,e={}){return qa(t,e).svg}function qa(t,e={}){let n=new No;return{svg:iu(n,()=>bh(Su(Sn(t,e),t,e),e)),diagnostics:n.diagnostics}}function bh(t,e={}){let{xmlDeclaration:n=!0,indent:r=!0,className:i}=e,o=r?`
48
+ `:"",s=r?" ":"",a=[];for(let m of t.body){if(m.kind==="shape"){a.push(`${s}${m.markup}`);continue}a.push(`${s}${m.open}`);for(let g of m.members)a.push(`${s}${s}${g.markup}`);a.push(`${s}${m.close}`)}let c=a.join(o),l=t.defs,d="";Vt(l).length>0&&(d=`${o}${s}<defs>${o}`,l.library.length>0&&(d+=`${s}${s}${l.library}${o}`),l.builtinMarkers.length>0&&(d+=`${s}${s}${l.builtinMarkers}${o}`),l.symbols.length>0&&(d+=`${s}${s}${l.symbols}${o}`),l.motionPaths.length>0&&(d+=`${s}${s}${l.motionPaths}${o}`),l.paintServers.length>0&&(d+=`${s}${s}${l.paintServers}${o}`),l.clipMask.length>0&&(d+=`${s}${s}${l.clipMask}${o}`),l.inlineHoisted.length>0&&(d+=`${s}${s}${l.inlineHoisted}${o}`),d+=`${s}</defs>`);let u=t.backgroundRect.length>0?`${o}${s}${t.backgroundRect}`:"",p="";n&&(p+=`<?xml version="1.0" encoding="UTF-8"?>${o}`);let f=t.frame.omit;return p+='<svg xmlns="http://www.w3.org/2000/svg"',f?.width||(p+=` width="${t.frame.width}"`),f?.height||(p+=` height="${t.frame.height}"`),f?.viewBox||(p+=` viewBox="${t.frame.viewBox}"`),t.frame.preserveAspectRatio&&(p+=` preserveAspectRatio="${t.frame.preserveAspectRatio}"`),i&&(p+=` class="${i}"`),p+=t.envelope.rootAttributes,p+=">",t.envelope.descriptive.length>0&&(p+=`${o}${s}${t.envelope.descriptive}`),p+=d,p+=u,c.length>0&&(p+=`${o}${c}`),t.envelope.scripts.length>0&&(p+=`${o}${s}${t.envelope.scripts}`),t.envelope.styles.length>0&&(p+=`${o}${s}${t.envelope.styles}`),t.envelope.trailingComments.length>0&&(p+=`${o}${s}${t.envelope.trailingComments}`),p+=`${o}</svg>${o}`,p}var mz=.25,gz=20;function vh(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function ow(t,e,n){let r=n.x-e.x,i=n.y-e.y,o=r*r+i*i;if(o===0)return vh(t,e);let s=Math.max(0,Math.min(1,((t.x-e.x)*r+(t.y-e.y)*i)/o));return Math.hypot(t.x-(e.x+s*r),t.y-(e.y+s*i))}function jo(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function Za(t,e,n,r,i,o,s=0){if(s>=gz||ow(e,t,r)<=i&&ow(n,t,r)<=i){o.push(r);return}let a=jo(t,e),c=jo(e,n),l=jo(n,r),d=jo(a,c),u=jo(c,l),p=jo(d,u);Za(t,a,d,p,i,o,s+1),Za(p,u,l,r,i,o,s+1)}function sw(t,e){return t?{x:e.x*2-t.x,y:e.y*2-t.y}:{...e}}function hz(t){return Object.freeze({x:t.x,y:t.y})}function aw(t,e={}){let n=kn(t);if(n.error||n.commands.length===0)return null;let r=e.transform??_e,i=Number.isFinite(e.tolerance)&&(e.tolerance??0)>0?e.tolerance:mz,o=I=>We(r,I),s=[],a=null,c={x:0,y:0},l={x:0,y:0},d=null,u=null,p="",f=(I,x,k)=>({x:I.params[x]+(I.type===I.type.toLowerCase()?k.x:0),y:I.params[x+1]+(I.type===I.type.toLowerCase()?k.y:0)}),m=I=>{a||(a=[o(c)],s.push(a)),a.push(o(I)),c=I};for(let I of n.commands){let x=I.type.toUpperCase(),k=I.type===I.type.toLowerCase(),T={...c},w=p==="C"||p==="S",P=p==="Q"||p==="T";switch(x){case"M":{c=f(I,0,T),l={...c},a=[o(c)],s.push(a);break}case"L":m(f(I,0,T));break;case"H":m({x:I.params[0]+(k?T.x:0),y:c.y});break;case"V":m({x:c.x,y:I.params[0]+(k?T.y:0)});break;case"C":{let N=f(I,0,T),R=f(I,2,T),$=f(I,4,T);a||(a=[o(c)],s.push(a)),Za(o(c),o(N),o(R),o($),i,a),c=$,d=R;break}case"S":{let N=sw(w?d:null,c),R=f(I,0,T),$=f(I,2,T);a||(a=[o(c)],s.push(a)),Za(o(c),o(N),o(R),o($),i,a),c=$,d=R;break}case"Q":case"T":{let N=x==="Q"?f(I,0,T):sw(P?u:null,c),R=f(I,x==="Q"?2:0,T),$={x:c.x+2/3*(N.x-c.x),y:c.y+2/3*(N.y-c.y)},A={x:R.x+2/3*(N.x-R.x),y:R.y+2/3*(N.y-R.y)};a||(a=[o(c)],s.push(a)),Za(o(c),o($),o(A),o(R),i,a),c=R,u=N;break}case"A":{let N=f(I,5,T),R=Ns(c.x,c.y,I.params[0],I.params[1],I.params[2],I.params[3]===1,I.params[4]===1,N.x,N.y);if(!R){m(N);break}a||(a=[o(c)],s.push(a));let $=Math.cos(R.phi),A=Math.sin(R.phi),O=Math.max(R.rx,R.ry),G=O<=i?Math.PI/4:Math.max(.01,2*Math.acos(Math.max(-1,1-i/O))),M=Math.max(1,Math.ceil(Math.abs(R.deltaTheta)/G));for(let V=1;V<=M;V++){let X=R.theta1+R.deltaTheta*V/M,Y=Math.cos(X),U=Math.sin(X);a.push(o({x:R.cx+R.rx*$*Y-R.ry*A*U,y:R.cy+R.rx*A*Y+R.ry*$*U}))}c=N;break}case"Z":a&&vh(a[a.length-1],o(l))>0&&a.push(o(l)),c={...l};break;default:return null}x!=="C"&&x!=="S"&&(d=null),x!=="Q"&&x!=="T"&&(u=null),p=x}let g=[],h=0;for(let I of s)for(let x=1;x<I.length;x++){let k=vh(I[x-1],I[x]);k!==0&&(g.push({start:I[x-1],end:I[x],offset:h,length:k}),h+=k)}let y=Object.freeze(s.map(I=>Object.freeze(I.map(hz)))),b=y[0]?.[0]??Object.freeze({x:0,y:0}),v=y[y.length-1]?.at(-1)??b;return Object.freeze({length:h,subpaths:y,pointAtLength(I){if(g.length===0||!Number.isFinite(I)||I<=0)return b;if(I>=h)return v;let x=g.find(T=>I<=T.offset+T.length);if(!x)return v;let k=(I-x.offset)/x.length;return Object.freeze({x:x.start.x+(x.end.x-x.start.x)*k,y:x.start.y+(x.end.y-x.start.y)*k})}})}function cw(t,e){return e?t.variants?.[e]??t.shapes:t.shapes}function lw(t,e){return!e||Object.keys(e).length===0?t:t.map(n=>{let r=e[n.id];return!r||Object.keys(r).length===0?n:{...n,state:{...n.state,...r}}})}function Ih(t){let e=[];for(let n of t.timeline.tracks){if(n.property!=="instanceVariant"||n.enabled===!1)continue;let r=t.instances.get(n.shapeId);if(!r)continue;let i=t.getSymbol(r.symbolId);if(!i)continue;let o=t.instanceSymbolIds.get(r.id);if(!o||!t.existingInnerIds.has(o))continue;let s=[...n.keyframes].sort((a,c)=>a.time-c.time);s.length<2||e.push({symbolId:o,def:i,overrides:r.symbolOverrides,keyframes:s})}return e}function wh(t){let e=new Map;for(let[n,r]of t.existingInnerIds)e.set(n,new Set(r));return e}function yz(t){return t.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Uo(t,e){let n=on(t),r=0;for(;n.startsWith("<!--",r);){let c=n.indexOf("-->",r);if(c===-1)return null;r=c+3}let i=n.indexOf("<",r);if(i===-1)return null;let o=n.indexOf(">",i);if(o===-1)return null;let s=n.slice(i,o+1),a=new RegExp(`\\s${e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")}="([^"]*)"`).exec(s);return a?yz(a[1]):null}var Ai=(t,e=0)=>typeof t=="number"&&Number.isFinite(t)?t:e;function Sz(t,e,n){let r=t.transformMatrix;if(r&&r.length>=6)return{x:r[0]*e.x+r[2]*e.y+r[4],y:r[1]*e.x+r[3]*e.y+r[5]};let i=Ai(t.translateX),o=Ai(t.translateY),s=t.rawTransform;if(s){let g=tt(Ht(s)),h=g[0]*e.x+g[2]*e.y+g[4],y=g[1]*e.x+g[3]*e.y+g[5];return{x:h+i,y:y+o}}let a=Ai(t.rotation),c=Ai(t.skewX),l=Ai(t.skewY),d=Ai(t.scaleX,1),u=Ai(t.scaleY,1),p=d!==1||u!==1;if(a===0&&c===0&&l===0&&!p)return{x:e.x+i,y:e.y+o};let f=e.x-n.x,m=e.y-n.y;if(l!==0&&(m=m+f*Math.tan(l*Math.PI/180)),c!==0&&(f=f+m*Math.tan(c*Math.PI/180)),p&&(f*=d,m*=u),a!==0){let g=a*Math.PI/180,h=Math.cos(g),y=Math.sin(g),b=f*h-m*y,v=f*y+m*h;f=b,m=v}return{x:f+n.x+i,y:m+n.y+o}}function dw(t,e){let n=pl(e);if(!n)return t.resolveShapeCenterFallback?.(e)??null;let r=e.state,i=r.customPivot??n;return Sz(r,n,i)}var bz=[{key:"fillColor",attr:"fill"},{key:"borderColor",attr:"stroke"},{key:"borderWidth",attr:"stroke-width"},{key:"opacity",attr:"opacity"},{key:"fillOpacity",attr:"fill-opacity"},{key:"strokeOpacity",attr:"stroke-opacity"},{key:"fontSize",attr:"font-size"}],vz={circle:{x:"cx",y:"cy",radius:"r"},ellipse:{x:"cx",y:"cy",rx:"rx",ry:"ry"},rectangle:{x:"x",y:"y",width:"width",height:"height"},square:{x:"x",y:"y",width:"width",height:"height"},line:{x1:"x1",y1:"y1",x2:"x2",y2:"y2"},image:{x:"x",y:"y",width:"width",height:"height"},text:{x:"x",y:"y"}},uw=new Set(["triangle","polygon","star","diamond","ngon","cross","heart","gear","arrow","cloud","ring","lightning","speech-bubble","spiral"]),xz=[{key:"fillColor",prop:"fill"},{key:"borderColor",prop:"stroke"},{key:"borderWidth",prop:"stroke-width"},{key:"opacity",prop:"opacity"},{key:"fillOpacity",prop:"fill-opacity"},{key:"strokeOpacity",prop:"stroke-opacity"}],Iz=[{key:"fillColor",prop:"fill"},{key:"borderColor",prop:"stroke"},{key:"borderWidth",prop:"strokeWidth"},{key:"opacity",prop:"opacity"},{key:"fillOpacity",prop:"fillOpacity"},{key:"strokeOpacity",prop:"strokeOpacity"}];function pw(t,e){return t+(((e-t)%360+540)%360-180)}function an(t,e,n,r,i){return{element:"animate",attributes:[["attributeName",t],["from",e],["to",n],["begin",r],["dur",i],["fill","freeze"]]}}function xh(t,e,n,r,i,o){return{element:"animateTransform",attributes:[["attributeName","transform"],["type",t],["from",e],["to",n],["begin",r],["dur",i],["fill","freeze"],["additive",o]]}}function wz(t){let e=t.state.opacity;return e!==void 0?String(e):"1"}function fw(t){let e=t.state.opacity;return e!==void 0?String(Number(e)):"1"}function*kh(t,e){let{keyframes:n,def:r,overrides:i}=t;for(let o=0;o<n.length-1;o++){let s=n[o],a=n[o+1],c=String(s.value??""),l=String(a.value??"");if(c===l)continue;let d=lw(cw(r,c),i),u=lw(cw(r,l),i);yield{treeA:d,treeB:u,aById:new Map(d.map(p=>[p.id,p])),bById:new Map(u.map(p=>[p.id,p])),index:o,beginSec:s.time/e,durSec:(a.time-s.time)/e}}}function mw(t){let e=Ih(t);if(e.length===0)return[];let n=t.timeline.duration>0?t.timeline.duration:1,r=wh(t),i=[];for(let o of e){let s=r.get(o.symbolId),a=[];for(let c of kh(o,n)){let l=`${c.beginSec}s`,d=`${c.durSec}s`;for(let u of c.treeB){let p=c.aById.get(u.id);if(!p||!s.has(u.id))continue;let f=p.state,m=u.state,g=[];for(let{key:y,attr:b}of bz){let v=f[y],I=m[y];v===void 0&&I===void 0||v!==I&&(v==null||I==null||g.push({action:"animate",spec:an(b,String(v),String(I),l,d)}))}let h=vz[u.type];if(h)for(let[y,b]of Object.entries(h)){let v=f[y],I=m[y];v===void 0&&I===void 0||v!==I&&(v==null||I==null||g.push({action:"animate",spec:an(b,String(v),String(I),l,d)}))}if(uw.has(u.type)){let y=Number(f.cx),b=Number(f.cy),v=Number(m.cx),I=Number(m.cy),x=Number(f.rotation??0),k=Number(m.rotation??0);if(Number.isFinite(y)&&Number.isFinite(b)&&Number.isFinite(v)&&Number.isFinite(I)&&Number.isFinite(x)&&Number.isFinite(k)&&(y!==v||b!==I||x!==k)){c.index===0&&g.push({action:"setBaseTransform",transform:`translate(${y}, ${b}) rotate(${x})`}),g.push({action:"animate",spec:xh("translate",`${y} ${b}`,`${v} ${I}`,l,d,"replace")});let R=pw(x,k);g.push({action:"animate",spec:xh("rotate",String(x),String(R),l,d,"sum")})}let w=f.sides,P=m.sides;if((f.radius!==m.radius||f.shiftAngle!==m.shiftAngle||f.cornerRadius!==m.cornerRadius)&&w===P){let R=Uo(p,"d"),$=Uo(u,"d");R&&$&&R!==$&&g.push({action:"animate",spec:an("d",R,$,l,d)})}else if(w!==P){let R=`${u.id}--xf`,$=1;for(;s.has(R);)R=`${u.id}--xf${$++}`;s.add(R),g.push({action:"crossfade",innerId:R,shape:u,fadeOut:an("opacity","1","0",l,d),fadeIn:an("opacity","0",wz(u),l,d)})}}if(u.type==="polyline"){let y=f.polylinePoints??null,b=m.polylinePoints??null;if(y&&b&&y.length===b.length){let v=Uo(p,"points"),I=Uo(u,"points");v&&I&&v!==I&&g.push({action:"animate",spec:an("points",v,I,l,d)})}}if(f.lineStyle!==m.lineStyle||f.dashLength!==m.dashLength||f.gapLength!==m.gapLength){let y=Uo(p,"stroke-dasharray"),b=Uo(u,"stroke-dasharray");y&&b&&y!==b&&g.push({action:"animate",spec:an("stroke-dasharray",y,b,l,d)})}if(!uw.has(u.type)){let y=Number(f.rotation??0),b=Number(m.rotation??0);if(Number.isFinite(y)&&Number.isFinite(b)&&y!==b){let v=dw(t,p),I=dw(t,u);if(v&&I){let x=pw(y,b);g.push({action:"animate",spec:xh("rotate",`${y} ${v.x} ${v.y}`,`${x} ${I.x} ${I.y}`,l,d,"sum")})}}}for(let[y,b]of[["fillGradient","fill"],["strokeGradient","stroke"]]){let v=kz(f,m,y,b,l,d);v&&g.push(v)}a.push({op:"withInner",innerId:u.id,actions:g})}for(let u of c.treeA)c.bById.has(u.id)||s.has(u.id)&&a.push({op:"withInner",innerId:u.id,actions:[{action:"animate",spec:an("opacity","1","0",l,d)}]});for(let u of c.treeB)c.aById.has(u.id)||(s.add(u.id),a.push({op:"ensureInner",innerId:u.id,shape:u,animations:[an("opacity","0",fw(u),l,d)]}))}i.push({symbolId:o.symbolId,ops:a})}return i}function kz(t,e,n,r,i,o){let s=t[n],a=e[n];if(!s||!a||s.type!==a.type||!Array.isArray(s.stops)||!Array.isArray(a.stops)||s.stops.length!==a.stops.length)return null;let c=[];for(let u=0;u<s.stops.length;u++){let p=s.stops[u],f=a.stops[u],m=[];p.offset!==f.offset&&m.push(an("offset",String(p.offset),String(f.offset),i,o)),p.color!==f.color&&m.push(an("stop-color",p.color,f.color,i,o)),p.opacity!==f.opacity&&m.push(an("stop-opacity",String(p.opacity),String(f.opacity),i,o)),m.length>0&&c.push({index:u,animations:m})}let l=s.type==="linear-gradient"?["x1","y1","x2","y2"]:["cx","cy","fx","fy","r"],d=[];for(let u of l){let p=s[u],f=a[u];typeof p!="number"||typeof f!="number"||p===f||d.push(an(u,String(p),String(f),i,o))}return{action:"gradient",paintAttr:r,expectedStopCount:s.stops.length,stops:c,gradient:d}}var Pz=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_");function gw(t){let e=Ih(t);if(e.length===0)return{stylesheet:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=wh(t),i=[],o=0,s=[],a=new Map;for(let c of e){let l=r.get(c.symbolId),d=s.find(f=>f.symbolId===c.symbolId);d||(d={symbolId:c.symbolId,scopeClass:`svgsketch-variant-${Pz(c.symbolId)}`,ensure:[],assignments:[]},s.push(d),a.set(d,new Map));let u=a.get(d),p=(f,m,g,h,y,b)=>{let v=`svgsketch-vt-${++o}`;i.push(`@keyframes ${v} { 0% { ${h}: ${m}; } 100% { ${h}: ${g}; } }`);let I=`${v} ${b}s linear ${y}s forwards`,x=u.get(f);x?x.push(I):u.set(f,[I])};for(let f of kh(c,n))if(!(f.durSec<=0)){for(let m of f.treeB){let g=f.aById.get(m.id);if(!g||!l.has(m.id))continue;let h=g.state,y=m.state;for(let{key:b,prop:v}of xz){let I=h[b],x=y[b];I===void 0&&x===void 0||I!==x&&(I==null||x==null||p(m.id,String(I),String(x),v,f.beginSec,f.durSec))}}for(let m of f.treeA)f.bById.has(m.id)||l.has(m.id)&&p(m.id,"1","0","opacity",f.beginSec,f.durSec);for(let m of f.treeB)f.aById.has(m.id)||(l.has(m.id)||(d.ensure.push({innerId:m.id,shape:m}),l.add(m.id)),p(m.id,"0",fw(m),"opacity",f.beginSec,f.durSec))}}for(let[c,l]of a)for(let[d,u]of l)c.assignments.push({innerId:d,animation:u.join(", ")});return{stylesheet:i.length>0?i.join(`
49
+ `):null,symbols:s}}function hw(t){let e=Ih(t);if(e.length===0)return{scriptBody:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=wh(t),i=[],o=[];for(let c of e){let l=r.get(c.symbolId),d=o.find(u=>u.symbolId===c.symbolId);d||(d={symbolId:c.symbolId,ensure:[]},o.push(d));for(let u of kh(c,n)){let p=u.beginSec*1e3,f=u.durSec*1e3;if(f<=0)continue;let m=(g,h)=>{let y={},b={};for(let[v,[I,x]]of Object.entries(h))y[v]=I,b[v]=x;i.push({symbolId:c.symbolId,innerId:g,keyframes:[y,b],durationMs:f,delayMs:p})};for(let g of u.treeB){let h=u.aById.get(g.id);if(!h)continue;let y=h.state,b=g.state,v={};for(let{key:I,prop:x}of Iz){let k=y[I],T=b[I];k===void 0&&T===void 0||k!==T&&(k==null||T==null||(v[x]=[k,T]))}Object.keys(v).length>0&&m(g.id,v)}for(let g of u.treeA)u.bById.has(g.id)||m(g.id,{opacity:[1,0]});for(let g of u.treeB){if(u.aById.has(g.id))continue;l.has(g.id)||(d.ensure.push({innerId:g.id,shape:g}),l.add(g.id));let h=g.state.opacity,y=h!==void 0?Number(h):1;m(g.id,{opacity:[0,y]})}}}return i.length===0?{scriptBody:null,symbols:o}:{scriptBody:`
50
+ (function () {
51
+ function start() {
52
+ var specs = ${JSON.stringify(i)};
53
+ for (var i = 0; i < specs.length; i++) {
54
+ var spec = specs[i];
55
+ var symbolEl = document.getElementById(spec.symbolId);
56
+ if (!symbolEl) continue;
57
+ var innerEl = symbolEl.querySelector('[data-svgsketch-inner-id="' + spec.innerId + '"]');
58
+ if (!innerEl || !innerEl.animate) continue;
59
+ try {
60
+ innerEl.animate(spec.keyframes, {
61
+ duration: spec.durationMs,
62
+ delay: spec.delayMs,
63
+ fill: 'forwards',
64
+ easing: 'linear'
65
+ });
66
+ } catch (err) {
67
+ // Element.animate may throw on unsupported property names; skip silently.
68
+ }
69
+ }
70
+ }
71
+ if (document.readyState === 'loading') {
72
+ document.addEventListener('DOMContentLoaded', start);
73
+ } else {
74
+ start();
75
+ }
76
+ })();
77
+ `,symbols:o}}function Wu(t,e){let n=tx(t,e);return Vo(t,{width:n.width,height:n.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function Tz(t){return t==="class"?"className":t==="for"?"htmlFor":t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function Ku(t){return t.replace(/\s([a-z][a-z-]*?)=/g,(e,n)=>n.startsWith("data-")||n.startsWith("aria-")?e:` ${Tz(n)}=`)}function Xu(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=Sn(t,{width:e.width,height:e.height}),s=[];for(let u of o.body){if(u.kind==="shape"){s.push(`${r}${r}${r}${Ku(u.markup)}`);continue}s.push(`${r}${r}${r}${Ku(u.open)}`);for(let p of u.members)s.push(`${r}${r}${r}${r}${Ku(p.markup)}`);s.push(`${r}${r}${r}${u.close}`)}let a=Vt(o.defs),c=a.length>0,l=o.strippedDocumentCss,d=[];d.push("import React from 'react';"),d.push(""),i?(d.push(`interface ${n}Props {`),d.push(`${r}className?: string;`),d.push(`${r}style?: React.CSSProperties;`),d.push("}"),d.push(""),d.push(`const ${n}: React.FC<${n}Props> = ({ className, style }) => {`)):d.push(`const ${n} = ({ className, style }) => {`),d.push(`${r}return (`),d.push(`${r}${r}<svg xmlns="http://www.w3.org/2000/svg" width="${o.frame.width}" height="${o.frame.height}" viewBox="${o.frame.viewBox}" className={className} style={style}>`),c&&(d.push(`${r}${r}${r}<defs>`),d.push(`${r}${r}${r}${r}${Ku(a)}`),d.push(`${r}${r}${r}</defs>`));for(let u of s)d.push(u);return l.length>0&&d.push(`${r}${r}${r}<style>{${JSON.stringify(l)}}</style>`),d.push(`${r}${r}</svg>`),d.push(`${r});`),d.push("};"),d.push(""),d.push(`export default ${n};`),d.push(""),d.join(`
78
+ `)}function Yu(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=Sn(t,{width:e.width,height:e.height}),s=[];for(let u of o.body){if(u.kind==="shape"){s.push(`${r}${r}${u.markup}`);continue}s.push(`${r}${r}${u.open}`);for(let p of u.members)s.push(`${r}${r}${r}${p.markup}`);s.push(`${r}${r}${u.close}`)}let a=Vt(o.defs),c=a.length>0,l=o.strippedDocumentCss,d=[];d.push("<template>"),d.push(`${r}<svg xmlns="http://www.w3.org/2000/svg" width="${o.frame.width}" height="${o.frame.height}" viewBox="${o.frame.viewBox}" :class="className" :style="style">`),c&&(d.push(`${r}${r}<defs>`),d.push(`${r}${r}${r}${a}`),d.push(`${r}${r}</defs>`));for(let u of s)d.push(u);return l.length>0&&d.push(`${r}${r}<component :is="'style'">${l}</component>`),d.push(`${r}</svg>`),d.push("</template>"),d.push(""),i?d.push('<script setup lang="ts">'):d.push("<script setup>"),d.push(`// ${n}`),i?(d.push("defineProps<{"),d.push(`${r}className?: string;`),d.push(`${r}style?: Record<string, string>;`),d.push("}>();")):(d.push("defineProps({"),d.push(`${r}className: { type: String, default: '' },`),d.push(`${r}style: { type: Object, default: () => ({}) },`),d.push("});")),d.push("</script>"),d.push(""),d.join(`
79
+ `)}var Rz=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function yw(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function qu(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Cz(t){let e=t.shape;if(!Rz.has(e.type)||t.smil.length>0)return!0;let n=e.state.metadata;return!!(n?.title||n?.description||e.type==="text"&&e.state.isTextPath||/\s(?:clip-path|mask)="url\(#/u.test(t.markup))}function Zu(t,e){let n=e.componentName??"createSvg",r=e.indent??" ",i=e.typescript??!1,o=Sn(t,{width:e.width,height:e.height}),s=[];s.push("import * as d3 from 'd3';"),s.push(""),i?s.push(`export function ${n}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):s.push(`export function ${n}(container) {`),s.push(`${r}const svg = d3.select(container)`),s.push(`${r}${r}.append('svg')`),s.push(`${r}${r}.attr('xmlns', 'http://www.w3.org/2000/svg')`),s.push(`${r}${r}.attr('width', ${o.frame.width})`),s.push(`${r}${r}.attr('height', ${o.frame.height})`),s.push(`${r}${r}.attr('viewBox', '${o.frame.viewBox}');`),s.push("");let a=Vt(o.defs);a.length>0&&(s.push(`${r}svg.append('defs').html(\`${qu(a)}\`);`),s.push(""));let c=o.strippedDocumentCss;c.length>0&&(s.push(`${r}svg.append('style').text(\`${qu(c)}\`);`),s.push(""));let l=0;for(let d of o.body){if(l++,d.kind==="clip-mask-run"){s.push(`${r}// group`);let g=d.open+d.members.map(h=>h.markup).join("")+d.close;s.push(`${r}svg.append('g').html(\`${qu(g)}\`);`),s.push("");continue}let u=d.shape;if(s.push(`${r}// ${u.type}${u.state.metadata?.name?` \u2014 ${u.state.metadata.name}`:""}`),Cz(d)){s.push(`${r}svg.append('g').html(\`${qu(d.markup)}\`);`),s.push("");continue}let p=ex(u),f=wd(u),m=`shape${l}`;s.push(`${r}const ${m} = svg.append('${p}')`);for(let[g,h]of f)s.push(`${r}${r}.attr('${g}', '${yw(h)}')`);u.type==="text"&&u.state.text&&s.push(`${r}${r}.text('${yw(u.state.text)}')`),s[s.length-1]=s[s.length-1]+";",s.push("")}return s.push(`${r}return svg;`),s.push("}"),s.push(""),s.join(`
80
+ `)}function $z(t,e){let n=t.state.metadata?.name;return n?n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${t.type}-${e+1}`}var Nz=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function Sw(t,e){let n=t.indexOf(" ");return n===-1?t:t.slice(0,n)+` class="${e}"`+t.slice(n)}function Ju(t,e){let n=e.indent??" ",r=Sn(t,{width:e.width,height:e.height}),i=0,o=new Map,s=[],a=f=>{o.set(f,$z(f.shape,i)),s.push(f),i++};for(let f of r.body)f.kind==="shape"?a(f):f.members.forEach(a);let c=[];for(let f of s){let m=wd(f.shape),g=[];for(let[h,y]of m)Nz.has(h)&&g.push(`${n}${h}: ${y};`);g.length>0&&c.push(`.${o.get(f)} {
81
+ ${g.join(`
18
82
  `)}
19
- }`)}let o=[];for(let l=0;l<i.length;l++){let c=i[l],f=Ll(c,l),d=de(c),p=d.indexOf(" ");p!==-1&&(d=d.slice(0,p)+` class="${f}"`+d.slice(p)),o.push(`${r}${d}`)}let a=[];a.push("<style>");for(let l of s)a.push(l);a.push("</style>"),a.push(""),a.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}">`);for(let l of o)a.push(l);return a.push("</svg>"),a.push(""),a.join(`
20
- `)}function fi(n,e){let t=gp(n,e),r={...e};switch(r.format){case"svg":return oi(t,r);case"react":return li(t,r);case"vue":return ui(t,r);case"d3":return ci(t,r);case"css":return di(t,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function gp(n,e){return Array.isArray(n)?{shapes:n,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}]}:n}var wn=class n{_snapshot;constructor(e={}){let{width:t=800,height:r=600,viewboxId:i}=e,s=fn(0,0,t,r,i);this._snapshot=lr({viewboxes:[s]})}static fromSnapshot(e){let t=new n;return t._snapshot=JSON.parse(JSON.stringify(e)),t}static fromJSON(e,t){let r=cr(e,t),i=new n;return i._snapshot=r,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(r=>r.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=[fn(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,r){let i=_(),s=t.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"symbol",id:i,name:e,viewBox:r?.viewBox??"0 0 100 100",shapes:s};return r?.groups&&(o.groups=r.groups),r?.thumbnail&&(o.thumbnail=r.thumbnail),r?.defKind&&(o.defKind=r.defKind),r?.wrapperAttrs&&(o.wrapperAttrs=r.wrapperAttrs),r?.variantAxes&&(o.variantAxes=r.variantAxes),r?.variants&&(o.variants=r.variants),r?.variantThumbnails&&(o.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(o),i}placeSymbolInstance(e,t,r,i,s){let o,a={};typeof i=="number"||i===void 0?o=i:(a=i,o=a.width,s=a.height??s);let l={symbolId:e,x:t,y:r,width:o??100,height:s??100};a.variantKey&&(l.variantKey=a.variantKey),a.symbolOverrides&&(l.symbolOverrides=a.symbolOverrides),a.instancePresentation&&(l.instancePresentation=a.instancePresentation);let c={id:_(),type:"symbol-instance",state:l};return this._snapshot.shapes.push(c),this}removeSymbol(e){if(!this._snapshot.library)return!1;let t=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===e)),this._snapshot.library.length<t}get symbols(){return(this._snapshot.library??[]).filter(e=>e.kind==="symbol")}defineMarker(e,t,r){let i=_(),s=t.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"marker",id:i,name:e,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:s};return r?.groups&&(o.groups=r.groups),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineFilter(e,t,r){let i=_(),s={kind:"filter",id:i,name:e,filters:t};return r?.colorInterpolation&&(s.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(s.filterUnits=r.filterUnits),r?.primitiveUnits&&(s.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(s.x=r.x),r?.y!==void 0&&(s.y=r.y),r?.width!==void 0&&(s.width=r.width),r?.height!==void 0&&(s.height=r.height),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineLinearGradientLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,...l}=s,c={kind:"linear-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,...l}=s,c={kind:"radial-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,customPatternId:l,...c}=s,f={kind:"pattern",id:i,name:e,pattern:c};return r?.thumbnail&&(f.thumbnail=r.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(r=>r.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(r=>r.id===e.id);t>=0?this._snapshot.library[t]=e:this._snapshot.library.push(e)}addClipGroup(e,t,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"clip",clipShapeIds:e,contentShapeIds:t,parentId:null};return r?.clipPathUnits&&(s.clipPathUnits=r.clipPathUnits),r?.clipRule&&(s.clipRule=r.clipRule),r?.rawDefinition&&(s.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}addMaskGroup(e,t,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"mask",clipShapeIds:e,contentShapeIds:t,parentId:null};return r?.maskUnits&&(s.maskUnits=r.maskUnits),r?.maskContentUnits&&(s.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(s.maskBounds=r.maskBounds),r?.maskType&&(s.maskType=r.maskType),r?.rawDefinition&&(s.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let t=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==e),this._snapshot.clipMaskGroups.length<t}addGuide(e,t,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=_(),s={id:i,orientation:e,position:t,controlPointOffset:0};return r?.color&&(s.color=r.color),r?.opacity!==void 0&&(s.opacity=r.opacity),this._snapshot.guides.push(s),i}removeGuide(e){if(!this._snapshot.guides)return!1;let t=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==e),this._snapshot.guides.length<t}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,t,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=_(),s={id:i,type:e,points:t,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(s.color=r.color),r?.opacity!==void 0&&(s.opacity=r.opacity),this._snapshot.measurements.push(s),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let t=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==e),this._snapshot.measurements.length<t}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,t,r,i){let s=_();return this._pushLibraryDef(Ue({id:s,name:e,svgContent:t,width:r,height:i})),s}removeCustomPattern(e){let t=this._snapshot.library;if(!t)return!1;let r=t.length;return this._snapshot.library=t.filter(i=>!(i.kind==="pattern"&&i.id===e)),this._snapshot.library.length<r}get customPatterns(){let e=[];for(let t of this._snapshot.library??[]){if(t.kind!=="pattern")continue;let r=kt(t);r&&e.push(r)}return e}addGroup(e,t){this._snapshot.groups||(this._snapshot.groups=[]);let r=e??_();return this._snapshot.groups.push({id:r,parentId:t??null}),r}removeGroup(e){if(!this._snapshot.groups)return!1;let t=this._snapshot.groups.length;this._snapshot.groups=this._snapshot.groups.filter(r=>r.id!==e);for(let r of this._snapshot.shapes)r.state.groupId===e&&delete r.state.groupId;return this._snapshot.groups.length<t}moveToGroup(e,t){let r=this._snapshot.shapes.find(i=>i.id===e);return r&&(r.state.groupId=t),this}removeFromGroup(e){let t=this._snapshot.shapes.find(r=>r.id===e);return t&&delete t.state.groupId,this}bringToFront(e){let t=this._snapshot.shapes.findIndex(r=>r.id===e);if(t>=0){let[r]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.push(r)}return this}sendToBack(e){let t=this._snapshot.shapes.findIndex(r=>r.id===e);if(t>=0){let[r]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.unshift(r)}return this}reorder(e,t){let r=this._snapshot.shapes.findIndex(i=>i.id===e);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),s=Math.max(0,Math.min(t,this._snapshot.shapes.length));this._snapshot.shapes.splice(s,0,i)}return this}defineVariable(e,t,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let s=this._snapshot.templateVariables.find(o=>o.name===e);if(s)s.type=t,s.defaultValue=r,i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description);else{let o={name:e,type:t,defaultValue:r};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 hr(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,...r}=e??{},i=mr(this._snapshot,t);return Et(i,r)}toJSON(e){return ur(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return fi(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var pi=class{_track;constructor(e,t){this._track={id:_(),shapeId:e,property:t,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,t,r="linear"){return this._track.keyframes.push({id:_(),time:e,value:t,easing:r}),this}keyframeBezier(e,t,r){return this._track.keyframes.push({id:_(),time:e,value:t,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(e,t,r){return this._track.keyframes.push({id:_(),time:e,value:t,easing:"linear-function",linearPoints:r}),this}keyframes(...e){return this._track.keyframes.push(...e.map(t=>t.id?t:{...t,id:_()})),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,r)=>t.time-r.time);return{...this._track,keyframes:e}}},mi=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(r=>({...r.id?{id:r.id}:{},time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var ae=class{_id;_type;_state={};constructor(e,t){this._type=e,this._id=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,r){return this._state.lineStyle=e,e==="custom"&&(t!==void 0&&(this._state.dashLength=t),r!==void 0&&(this._state.gapLength=r)),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=Ye(ln(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let t=this._state.x,r=this._state.y,i=this._state.width,s=this._state.height;if(t!==void 0&&r!==void 0&&i!==void 0&&s!==void 0)return{x:t+i/2,y:r+s/2};let o=this._state.radius;if(t!==void 0&&r!==void 0&&o!==void 0)return{x:t,y:r};let a=this._state.cx,l=this._state.cy;if(a!==void 0&&l!==void 0)return{x:a,y:l};let c=this._state.x1,f=this._state.y1,d=this._state.x2,p=this._state.y2;if(c!==void 0&&f!==void 0&&d!==void 0&&p!==void 0)return{x:(c+d)/2,y:(f+p)/2};let m=this._state.pathPoints;if(m?.[0])return{x:m[0].x,y:m[0].y};let h=this._state.polylinePoints;if(h?.[0])return h[0]}filter(...e){let t=this._state.filters??[];return this._state.filters=[...t,...e],this}dropShadow(e={}){let t={id:`drop-shadow-${_()}`,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-${_()}`,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,r){let i=e??4,s=t??i,o={id:`gaussian-blur-${_()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:s,linked:i===s,quality:r?.quality??"normal"};return this.filter(o)}glow(e={}){let t={id:`glow-${_()}`,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-${_()}`,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-${_()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(t)}sepia(e=1){let t={id:`sepia-${_()}`,type:"sepia",enabled:!0,amount:e};return this.filter(t)}outline(e={}){return this.filter({id:`outline-${_()}`,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-${_()}`,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-${_()}`,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-${_()}`,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-${_()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(t)}pixelate(e=8){let t={id:`pixelate-${_()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(t)}warp(e={}){let t={id:`warp-${_()}`,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,r=e.radiusY??t,i={id:`morphology-${_()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:t,radiusY:r,linked:e.linked??t===r};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${_()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${_()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(r)}roundEdges(e=4){let t={id:`round-edges-${_()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(t)}channelPainter(e={}){let t={id:`channel-painter-${_()}`,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-${_()}`,type:"brightness",enabled:!0,amount:e};return this.filter(t)}contrast(e=1){let t={id:`contrast-${_()}`,type:"contrast",enabled:!0,amount:e};return this.filter(t)}filterOpacity(e=1){let t={id:`opacity-${_()}`,type:"opacity",enabled:!0,amount:e};return this.filter(t)}invert(e=1){let t={id:`invert-${_()}`,type:"invert",enabled:!0,amount:e};return this.filter(t)}hueRotate(e=0){let t={id:`hue-rotate-${_()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(t)}saturate(e=1){let t={id:`saturate-${_()}`,type:"saturate",enabled:!0,amount:e};return this.filter(t)}blackAndWhite(e=.5){let t={id:`black-and-white-${_()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(t)}duotone(e={}){let t={id:`duotone-${_()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(t)}xray(e=1){let t={id:`xray-${_()}`,type:"xray",enabled:!0,intensity:e};return this.filter(t)}noise(e={}){let t={id:`noise-${_()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(t)}emboss(e={}){let t={id:`emboss-${_()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(t)}filmGrain(e={}){let t={id:`film-grain-${_()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(t)}watercolor(e={}){let t={id:`watercolor-${_()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(t)}gouache(e={}){let t={id:`gouache-${_()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(t)}inkBlot(e={}){let t={id:`ink-blot-${_()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(t)}crumpledPlastic(e={}){let t={id:`crumpled-plastic-${_()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(t)}riddled(e={}){let t={id:`riddled-${_()}`,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 r=this._state.bindings??{};return this._state.bindings={...r,[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}}}},hi=class extends ae{constructor(e,t,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=t,this._state.radius=r}position(e,t){return this._state.x=e,this._state.y=t,this}radius(e){return this._state.radius=e,this}},gi=class extends ae{constructor(e,t,r,i){if(r<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=r,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}},yi=class extends ae{constructor(e,t,r,i){if(r<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=r,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}},bi=class extends ae{constructor(e,t,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=t,this._state.width=r,this._state.height=r}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}},Si=class extends ae{constructor(e,t,r,i){super("line"),this._state.x1=e,this._state.y1=t,this._state.x2=r,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}},xi=class extends ae{constructor(e,t,r){super("text"),this._state.x=e,this._state.y=t,this._state.text=r}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){let t=at(e);return this._state.richTextRuns=t,this._state.richTextData=Ve(t),this}richTextRuns(e){let t=st(e);return this._state.richTextRuns=t,this._state.richTextData=Ve(t),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}},Se=class extends ae{constructor(e,t,r,i){super(e),this._state.cx=t,this._state.cy=r,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}},$i=class extends Se{constructor(e,t,r){super("triangle",e,t,r)}},vi=class extends Se{constructor(e,t,r,i=5){super("ngon",e,t,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},ki=class extends Se{constructor(e,t,r){super("star",e,t,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Ti=class extends Se{constructor(e,t,r){super("cross",e,t,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},wi=class extends Se{constructor(e,t,r){super("ring",e,t,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Pi=class extends Se{constructor(e,t,r){super("spiral",e,t,r),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}},_i=class extends Se{constructor(e,t,r){super("gear",e,t,r),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}},Ri=class extends Se{constructor(e,t,r){super("arrow",e,t,r),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}},Ai=class extends Se{constructor(e,t,r){super("heart",e,t,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},Ii=class extends Se{constructor(e,t,r){super("lightning",e,t,r),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}},Mi=class extends Se{constructor(e,t,r){super("cloud",e,t,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},Ci=class extends Se{constructor(e,t,r){super("speechBubble",e,t,r),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}},tt=class extends ae{add(e){let t="build"in e&&typeof e.build=="function"?e.build():e,r=this._state.children??[];return this._state.children=[...r,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}},Di=class extends tt{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}},Fi=class extends tt{constructor(){super("switch")}},Ei=class extends tt{constructor(){super("container")}},Oi=class extends ae{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,r,i){return this._state.viewBoxX=e,this._state.viewBoxY=t,this._state.viewBoxWidth=r,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}},Li=class extends tt{constructor(e=0,t=0,r=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=t,this._state.svgWidth=r,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,r,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=t,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},Ni=class extends ae{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}},Bi=class extends ae{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}},zi=class extends Bi{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}},Gi=class extends Bi{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},Vi=class extends ae{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 r=this._state.pathPoints??[];return r.push({x:e,y:t}),this._state.pathPoints=r,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",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,s=this._state.pathArcParams;return qe(e,t,r,i,s)}},Ui=class extends ae{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,t){let r=this._state.polylinePoints??[];return r.push({x:e,y:t}),this._state.polylinePoints=r,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}},Wi=class extends ae{constructor(e,t,r,i,s){super("image"),this._state.x=e,this._state.y=t,this._state.width=r,this._state.height=i,this._state.href=s}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 Pn=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,t=0,r=1,i=0){this._x1=e,this._y1=t,this._x2=r,this._y2=i,this._id=_()}stop(e,t,r=1){return this._stops.push({offset:e,color:t,opacity:r}),this}direction(e,t,r,i){return this._x1=e,this._y1=t,this._x2=r,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}}},_n=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=_()}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,r=1){return this._stops.push({offset:e,color:t,opacity:r}),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}}},Rn=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",r="#ffffff"){this._patternType=e,this._color=t,this._backgroundColor=r,this._id=_()}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,r;if(this._svgContent!==void 0)e=this._svgContent,t=this._width??10,r=this._height??10;else{let s=Or(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=s.svgContent,t=this._width??s.width,r=this._height??s.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:r,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 Nl(n=0,e=0,t=1,r=0){return new Pn(n,e,t,r)}function Bl(){return new _n}function zl(n="stripes",e="#000000",t="#ffffff"){return new Rn(n,e,t)}var ya={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},yp=.04,bp=0;function Sp(n){let e=n>>>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(n){return Number(n.toFixed(3)).toString()}function xp(n,e,t,r,i,s,o,a,l,c,f,d){return[[0,0],[.2,a],[.5+l+f,-s+c],[.5-s+l,s+c],[.5-2*s+l-f,3*s+c],[.5+2*s+l-f,3*s+c],[.5+s+l,s+c],[.5+l+f,-s+c],[.8,d],[1,0]].map(([m,h])=>{let g=e+m*r,b=t+h*i*o;return n?{x:g,y:b}:{x:b,y:g}})}function Gl(n,e,t,r,i,s,o,a,l,c,f){let d=[],p=(v,w)=>l==="alternating"?0:v+c()*(w-v),m=()=>c()<.5,h=p(-a,a),g=l==="alternating"?f%2===0:m(),b=null,$=h,k=p(-a,a),S=p(-a,a),x=p(-a,a);h=p(-a,a);for(let v=0;v<n;v++){v>0&&(b=g,g=l==="alternating"?(f+v)%2===0:m(),$=g===b?-h:h,k=p(-a,a),S=p(-a,a),x=p(-a,a),h=p(-a,a));let w=g?-1:1,T=t+v*i;d.push(xp(e,T,r,i,s,o,w,$,k,S,x,h))}return d}function Vl(n,e,t,r,i,s,o){let a=2*s;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([c,f])=>{let d=e+c*r,p=t+f*i*o;return n?{x:d,y:p}:{x:p,y:d}})}function Ul(n,e){return n+` 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 Wl(n,e){return n+` 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 Hl(n,e={}){let t={...ya,...e};if(t.rows<1||t.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(n.width)||!Number.isFinite(n.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(n.width<=0||n.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:s,tabDepthPercent:o,tabPattern:a,seed:l}=t,c=Sp(l),f=n.width/i,d=n.height/r,p=Math.max(0,Math.min(.4,o/200)),m=(s==="classic"||s==="curved")&&p>0,h=s==="square-tabs"&&p>0,g=s==="classic"&&a==="random"?yp:bp,b=[];for(let S=0;S<r-1;S++){let x=n.y+(S+1)*d;if(m)b.push(Gl(i,!0,n.x,x,f,d,p,g,a,c,S));else if(h){let v=[];for(let w=0;w<i;w++){let T=a==="alternating"?(S+w)%2===0?1:-1:c()<.5?1:-1;v.push(Vl(!0,n.x+w*f,x,f,d,p,T))}b.push(v)}else b.push(new Array(i).fill(null))}let $=[];for(let S=0;S<i-1;S++){let x=n.x+(S+1)*f;if(m)$.push(Gl(r,!1,n.y,x,d,f,p,g,a,c,S));else if(h){let v=[];for(let w=0;w<r;w++){let T=a==="alternating"?(w+S)%2===0?1:-1:c()<.5?1:-1;v.push(Vl(!1,n.y+w*d,x,d,f,p,T))}$.push(v)}else $.push(new Array(r).fill(null))}let k=[];for(let S=0;S<r;S++)for(let x=0;x<i;x++){let v=n.x+x*f,w=n.y+S*d,T=v+f,P=w+d,R=`M ${F(v)} ${F(w)}`;if(S===0)R+=` L ${F(T)} ${F(w)}`;else{let M=b[S-1][x];M?R=Ul(R,M):R+=` L ${F(T)} ${F(w)}`}if(x===i-1)R+=` L ${F(T)} ${F(P)}`;else{let M=$[x][S];M?R=Ul(R,M):R+=` L ${F(T)} ${F(P)}`}if(S===r-1)R+=` L ${F(v)} ${F(P)}`;else{let M=b[S][x];M?R=Wl(R,M):R+=` L ${F(v)} ${F(P)}`}if(x===0)R+=` L ${F(v)} ${F(w)}`;else{let M=$[x-1][S];M?R=Wl(R,M):R+=` L ${F(v)} ${F(w)}`}R+=" Z",k.push({id:`puzzle-${l}-r${S}-c${x}`,row:S,col:x,d:R})}return k}var Xl=[1,2,3,4,5,6,7,8,9],$p={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 An(n){return n.map(e=>[...e])}function vp(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function Yl(n){let e=n>>>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 ql(n,e){let t=[...n];for(let r=t.length-1;r>0;r--){let i=Math.floor(e()*(r+1));[t[r],t[i]]=[t[i],t[r]]}return t}function Lt(n){return 1<<n-1}function Zl(n){let e=0,t=n;for(;t;)t&=t-1,e++;return e}function kp(n){for(let e=1;e<=9;e++)if(n===Lt(e))return e;return 0}function Sa(n,e){return Math.floor(n/3)*3+Math.floor(e/3)}function ba(n){let e=0;for(let t of n)for(let r of t)r!==0&&e++;return e}function Tp(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function Jl(n,e){if(!Array.isArray(n)||n.length!==9)return e.push("Grid must contain 9 rows."),!1;let t=!0;for(let r=0;r<9;r++){if(!Array.isArray(n[r])||n[r].length!==9){e.push(`Row ${r+1} must contain 9 cells.`),t=!1;continue}for(let i=0;i<9;i++){let s=n[r][i];(!Number.isInteger(s)||s<0||s>9)&&(e.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),t=!1)}}return t}function Ql(n,e){let t=!0,r=(i,s)=>{let o=0;for(let a of s){if(a===0)continue;let l=Lt(a);if(o&l){e.push(`${i} contains duplicate ${a}.`),t=!1;return}o|=l}};for(let i=0;i<9;i++)r(`Row ${i+1}`,n[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,n.map(s=>s[i]));for(let i=0;i<9;i+=3)for(let s=0;s<9;s+=3){let o=[];for(let a=i;a<i+3;a++)for(let l=s;l<s+3;l++)o.push(n[a][l]);r(`Box ${Math.floor(i/3)*3+Math.floor(s/3)+1}`,o)}return t}function xa(n){let e=Array.from({length:9},()=>0),t=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let s=0;s<9;s++){let o=n[i][s];if(o===0)continue;let a=Lt(o),l=Sa(i,s);if(e[i]&a||t[s]&a||r[l]&a)return null;e[i]|=a,t[s]|=a,r[l]|=a}return{rows:e,cols:t,boxes:r}}function $a(n,e,t,r,i){return 511&~(t[n]|r[e]|i[Sa(n,e)])}function eu(n,e,t){let r=xa(n);if(!r)return[];let i=An(n),s=[],{rows:o,cols:a,boxes:l}=r,c=()=>{if(s.length>=e)return;let f=-1,d=-1,p=0,m=10;for(let g=0;g<9;g++){for(let b=0;b<9;b++){if(i[g][b]!==0)continue;let $=$a(g,b,o,a,l),k=Zl($);if(k===0)return;if(k<m&&(f=g,d=b,p=$,m=k,k===1))break}if(m===1)break}if(f===-1){s.push(An(i));return}let h=Xl.filter(g=>p&Lt(g));t&&(h=ql(h,t));for(let g of h){let b=Lt(g),$=Sa(f,d);if(i[f][d]=g,o[f]|=b,a[d]|=b,l[$]|=b,c(),l[$]&=~b,a[d]&=~b,o[f]&=~b,i[f][d]=0,s.length>=e)return}};return c(),s}function wp(n){let e=vp(),t=Yl(n),[r]=eu(e,1,t);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function Pp(n){let e=xa(n);if(!e)return null;for(let t=0;t<9;t++)for(let r=0;r<9;r++){if(n[t][r]!==0)continue;let i=$a(t,r,e.rows,e.cols,e.boxes);if(Zl(i)===1)return{row:t,col:r,value:kp(i)}}return null}function _p(n){let e=xa(n);if(!e)return null;let t=r=>{for(let i of Xl){let s=Lt(i),o=null;for(let a of r)if(!(n[a.row][a.col]!==0||!($a(a.row,a.col,e.rows,e.cols,e.boxes)&s))){if(o){o=null;break}o=a}if(o)return{...o,value:i}}return null};for(let r=0;r<9;r++){let i=t(Array.from({length:9},(s,o)=>({row:r,col:o})));if(i)return i}for(let r=0;r<9;r++){let i=t(Array.from({length:9},(s,o)=>({row:o,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let s=[];for(let a=r;a<r+3;a++)for(let l=i;l<i+3;l++)s.push({row:a,col:l});let o=t(s);if(o)return o}return null}function jl(n){let e=An(n),t=!1;for(;ba(e)<81;){let r=Pp(e);if(r){e[r.row][r.col]=r.value;continue}let i=_p(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function Kl(n,e){let t={singles:0,"hidden-singles":1,search:2};return t[n]<=t[e]}function In(n,e={}){let t=[];return Jl(n,t)?Ql(n,t)?eu(n,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function tu(n){let e=[];if(!Jl(n,e))return{valid:!1,unique:!1,solution:null,errors:e};if(Ql(n,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=In(n,{maxSolutions:2});return r.length===0?e.push("Puzzle has no solution."):r.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:r.length===1,solution:r[0]?An(r[0]):null,errors:e}}function nu(n){let e=n.difficulty,t=$p[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=Tp(n.seed);for(let i=0;i<30;i++){let s=r+i*104729>>>0,o=Yl(s),a=wp(s),l=An(a),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=ql(Array.from({length:81},(h,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let h of f){if(ba(l)<=c)break;let g=l[h.row][h.col];if(l[h.row][h.col]=0,In(l,{maxSolutions:2}).length!==1){l[h.row][h.col]=g;continue}let $=jl(l);Kl($,t.maxRating)||(l[h.row][h.col]=g)}let d=ba(l),p=jl(l);if(In(l,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&Kl(p,t.maxRating))return{puzzle:l,solution:a,difficulty:e,seed:r,givens:d,rating:p}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}var ru="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Rp={E:{direction:"E",dr:0,dc:1},S:{direction:"S",dr:1,dc:0},SE:{direction:"SE",dr:1,dc:1},NE:{direction:"NE",dr:-1,dc:1},W:{direction:"W",dr:0,dc:-1},N:{direction:"N",dr:-1,dc:0},NW:{direction:"NW",dr:-1,dc:-1},SW:{direction:"SW",dr:1,dc:-1}};function su(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function au(n){let e=n>>>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 Nt(n){let e=globalThis.Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(n),t=>t.segment.normalize("NFC")):Array.from(n.normalize("NFC"))}function Ap(n,e,t,r){return n>=0&&e>=0&&n<r&&e<t}function va(n,e){return Array.from({length:e},()=>Array.from({length:n},()=>!0))}function ou(n,e,t,r){if(!t)return va(n,e);if(!Array.isArray(t)||t.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),va(n,e);let i=[];for(let s=0;s<e;s++){if(!Array.isArray(t[s])||t[s].length!==n)return r.push(`Mask row ${s+1} must contain exactly ${n} cells.`),va(n,e);i.push(t[s].map(Boolean))}return i}function Ip(n){let e=0;for(let t of n)for(let r of t)r&&e++;return e}function Mp(n){return n.trim().normalize("NFC")}function lu(n){return n.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function ka(n,e){let t=[];return n.across&&(t.push("E"),e&&t.push("W")),n.down&&(t.push("S"),e&&t.push("N")),n.diagonal&&(t.push("SE","NE"),e&&t.push("NW","SW")),t}function Cp(n,e,t,r,i,s,o,a){let l=Nt(n),c=[];for(let f=0;f<l.length;f++){let d=e+r.dr*f,p=t+r.dc*f;if(!Ap(d,p,s,o)||!i[d][p])return null;c.push({row:d,col:p,grapheme:l[f]})}return{word:n,graphemes:l,row:e,col:t,direction:r.direction,dr:r.dr,dc:r.dc,cells:c,jitter:a}}function uu(n,e,t,r,i,s){let o=[];for(let a of e){let l=Rp[a];for(let c=0;c<i;c++)for(let f=0;f<r;f++){let d=Cp(n,c,f,l,t,r,i,s());d&&o.push(d)}}return o}function Ta(n){let e=[],t=[],r=[],i=Math.floor(n.width),s=Math.floor(n.height);(!Number.isInteger(i)||i<2||i>64)&&e.push("Width must be an integer from 2 to 64."),(!Number.isInteger(s)||s<2||s>64)&&e.push("Height must be an integer from 2 to 64.");let o=ka(n.axes,n.allowBackwards);o.length===0&&e.push("At least one word direction must be enabled.");let a=ou(Math.max(1,i),Math.max(1,s),n.mask,e),l=Ip(a);l===0&&e.push("Mask must contain at least one active cell.");let c=new Set,f=[];for(let m of n.words){let h=Mp(m);if(h){if(/\s/u.test(h)){r.push({input:m,reason:"Words cannot contain whitespace."});continue}if(c.has(h)){r.push({input:m,reason:"Duplicate word."});continue}c.add(h),f.push(h)}}f.length===0&&e.push("Enter at least one word.");let d=au(su(n.seed));if(e.length===0)for(let m=f.length-1;m>=0;m--){let h=f[m];uu(h,o,a,i,s,d).length===0&&(r.push({input:h,reason:"No legal placement exists for the current size, mask, and directions."}),f.splice(m,1))}r.length>0&&e.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let p=Math.max(0,l);return f.length>p&&t.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:f,rejectedWords:r,errors:e,warnings:t,minWords:1,maxWords:p,activeCells:l,directions:o}}function Dp(n,e){for(let t of e.cells){let r=n[t.row][t.col];if(r!==null&&r!==t.grapheme)return!0}return!1}function Fp(n,e){let t=[];for(let r of e.cells)n[r.row][r.col]===null&&(t.push({row:r.row,col:r.col}),n[r.row][r.col]=r.grapheme);return t}function Ep(n,e){for(let t of e)n[t.row][t.col]=null}function iu(n,e){let t=0;for(let r of e.cells)n[r.row][r.col]===r.grapheme&&t++;return t}function Op(n){return{word:n.word,row:n.row,col:n.col,direction:n.direction,path:n.cells.map(e=>({...e}))}}function Lp(n){let e=n.fillerAlphabet??ru,t=typeof e=="string"?Nt(e):e.flatMap(i=>Nt(i)),r=t.filter((i,s)=>i.trim()&&t.indexOf(i)===s);return r.length>0?r:Nt(ru)}function cu(n){let e=Math.floor(n.width),t=Math.floor(n.height),r=su(n.seed),i=Ta({...n,width:e,height:t,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let s=ou(e,t,n.mask,[]),o=Math.max(1,Math.floor(n.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let l=au(r+a*104729>>>0),c=i.directions,f=new Map;for(let k of i.acceptedWords)f.set(k,uu(k,c,s,e,t,l));let d=[...i.acceptedWords].sort((k,S)=>{let x=f.get(k)?.length??0,v=f.get(S)?.length??0;return x!==v?x-v:Nt(S).length-Nt(k).length}),p=Array.from({length:t},(k,S)=>Array.from({length:e},(x,v)=>s[S][v]?null:"")),m=[],h=new Map,g=0,b=k=>{if(++g>o)return!1;if(k>=d.length)return!0;let S=d[k],x=[...f.get(S)??[]].filter(v=>!Dp(p,v)).sort((v,w)=>{let T=iu(p,w)-iu(p,v);if(T!==0)return T;let P=(h.get(v.direction)??0)-(h.get(w.direction)??0);return P!==0?P:v.jitter-w.jitter});for(let v of x){let w=Fp(p,v);if(m.push(Op(v)),h.set(v.direction,(h.get(v.direction)??0)+1),b(k+1))return!0;h.set(v.direction,(h.get(v.direction)??1)-1),m.pop(),Ep(p,w)}return!1};if(!b(0))continue;let $=Lp(n);for(let k=0;k<t;k++)for(let S=0;S<e;S++)s[k][S]?p[k][S]===null&&(p[k][S]=$[Math.floor(l()*$.length)]):p[k][S]="";return{width:e,height:t,grid:p,mask:s.map(k=>[...k]),normalizedWords:[...i.acceptedWords],placements:[...m],seed:r,title:n.title,creator:n.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function Np(n,e,t){let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){let o=t[i],a=t[s];o.y>e!=a.y>e&&n<(a.x-o.x)*(e-o.y)/(a.y-o.y)+o.x&&(r=!r)}return r}function Bp(){let n=[];for(let e=0;e<10;e++){let t=e%2===0?.5:.23,r=-Math.PI/2+e*Math.PI/5;n.push({x:.5+Math.cos(r)*t,y:.5+Math.sin(r)*t})}return n}function du(n,e,t){let r=Math.max(1,Math.floor(n)),i=Math.max(1,Math.floor(e)),s=Bp();return Array.from({length:i},(o,a)=>Array.from({length:r},(l,c)=>{let f=(c+.5)/r,d=(a+.5)/i,p=f*2-1,m=d*2-1;switch(t){case"rectangle":return!0;case"circle":return p*p+m*m<=1;case"triangle":return d>=.08&&d<=.95&&Math.abs(p)<=d;case"diamond":return Math.abs(p)+Math.abs(m)<=1;case"star":return Np(f,d,s);case"heart":{let h=p*1.25,g=-m*1.25;return Math.pow(h*h+g*g-1,3)-h*h*g*g*g<=0}case"cross":return Math.abs(p)<=.32||Math.abs(m)<=.32;default:return!0}}))}0&&(module.exports={Arrow,Audio,BUILTIN_MARKER_ID_MAP,COLLAB_PROTOCOL_VERSION,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DEFAULT_COORDINATE_PRECISION,DEFAULT_RICH_TEXT_STYLE,Document,DocumentBuilder,EASING_CURVES,EasingType,Ellipse,Gear,Heart,Hyperlink,IDENTITY_AFFINE,ImageShape,KNOWN_STATE_KEYS,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_TRANSFORM_STATE_KEYS,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,Switch,Text,Timeline,Track,Triangle,Video,View,affine,affineFromArray,affineToArray,almostEqualAffine,applyAffineToPoint,applyAffineToVector,applyOpToSnapshot,applyOpsInPlace,applyOpsToSnapshot,applyOpsToSnapshotWithAccepted,applyRichTextFormat,applyTextSplice,applyTextTransform,arcEndpointToCenter,areTracksTimingEquivalent,around,buildCompoundTransformValues,buildSmilKeyframeData,canonicalPolygonTransformString,canonicalTransformString,collaborationResourceKey,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,compareOrderKeys,composeLegacyTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,createDocument,createSceneNode,createShape,createViewbox,createWordSearchPrimitiveMask,cubicBezierExtent1D,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decomposeAffine2D,defaultVariableMode,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,downTranslateAnimationKeyframeOps,downTranslateCollectionMoveOps,downTranslateDocumentFieldOps,downTranslateScenePlaceOps,downTranslateTextFormatOps,ellipticalArcBounds,escXml,extractVariables,filterAttr,findShapeById,flattenShapeStateTree,flattenStateExtra,foldLegacyAncestorTransformIntoMatrix,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatOperationValidationIssues,formatSmilKeySpline,formatSmilKeyTime,freezeSiblingOrderKeys,generateCode,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getKeyframeCubicBezier,getMarkerDescriptors,getPatternElements,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getWordSearchDirections,initialOrderKeys,invertAffine,isDefaultKeyPoints,isDefaultKeyTimes,isFiniteAffineArray,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isReusablePatternTile,isSetSequenceTrack,isValidOrderKey,keyBetween,keysBetween,legacyEndpointMarkerId,linearGradient,lintWordSearchOptions,materializeSceneTreeOrderKeys,matrixTransformPart,maxCollaborationTimestamp,mergeRichTextStyle,migrateSnapshot,moveResourceById,multiplyAffine,nodeSchemas,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,orderSiblings,parseDocument,parseSvgTransformList,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,pathDataBounds,pattern,patternLibraryDefToCustomPatternDef,patternTileSize,planTransformFusion,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,promoteRebasedShapeUpdateClock,quadraticBezierExtent1D,radialGradient,rebaseRichTextFormatRanges,rebaseRichTextRuns,reflectCubicBezier,removeResourceById,removeResourceByKey,removeResourceByName,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderEllipse,renderFilterDefs,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPatternLibraryDef,renderPolygonShape,renderPolyline,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderShape,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderText,renderToSvg,resolveRichTextStyleAt,resolveSymbolInstanceShapes,rewriteDocumentEmbeddedPayloads,rewriteShapeStateEmbeddedPayloads,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rotateAffine,roundCoord,roundNumberString,roundSerializedShape,roundSnapshot,runsFromSegments,sanitizeRichTextFormatRanges,scaleAffine,senderCorrectionsForOp,skewXAffine,skewYAffine,smilKeyframeAttributes,solveCubicBezier,solveSudoku,splinePathBounds,stringifyDocument,substituteString,substituteVariables,symbolInstanceTargetId,transformSplice,translateAffine,tryParseSvgTransformList,upsertResourceById,upsertResourceByKey,upsertResourceByName,upsertTrackKeyframe,validateDocumentOperations,validateOperation,validatePresenceOperation,validateSnapshot,validateSudokuPuzzle,verticesToPath});
83
+ }`)}let l=[];for(let f of r.body){if(f.kind==="shape"){l.push(`${n}${Sw(f.markup,o.get(f))}`);continue}l.push(`${n}${f.open}`);for(let m of f.members)l.push(`${n}${n}${Sw(m.markup,o.get(m))}`);l.push(`${n}${f.close}`)}let d=Vt(r.defs),u=r.strippedDocumentCss,p=[];p.push("<style>");for(let f of c)p.push(f);u.length>0&&p.push(u),p.push("</style>"),p.push(""),p.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${r.frame.width}" height="${r.frame.height}" viewBox="${r.frame.viewBox}">`),d.length>0&&p.push(`${n}<defs>${d}</defs>`);for(let f of l)p.push(f);return p.push("</svg>"),p.push(""),p.join(`
84
+ `)}function Qu(t,e){return Ph(t,e).code}function Ph(t,e){let n=new No;return{code:iu(n,()=>Az(t,e)),diagnostics:n.diagnostics}}function Az(t,e){let n=Ez(t,e),r={...e};switch(r.format){case"svg":return Wu(n,r);case"react":return Xu(n,r);case"vue":return Yu(n,r);case"d3":return Zu(n,r);case"css":return Ju(n,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function Ez(t,e){if(Array.isArray(t)){let n=II(t);return{shapes:t,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}],...n.length>0?{library:n}:{}}}return t}var ep=class t{_snapshot;constructor(e={}){let{width:n=800,height:r=600,viewboxId:i}=e,o=Pi(0,0,n,r,i);this._snapshot=ho({viewboxes:[o]})}static fromSnapshot(e){let n=new t;return n._snapshot=JSON.parse(JSON.stringify(e)),n}static fromJSON(e,n){let r=qd(e,n),i=new t;return i._snapshot=r,i}static fromSVG(e,n){return t.fromSnapshot(wu(e,n))}add(e){let n="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(n),this}addAll(...e){for(let n of e)this.add(n);return this}remove(e){let n=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(r=>r.id!==e),this._snapshot.shapes.length<n}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(n=>n.id===e)}size(e,n){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=n):this._snapshot.viewboxes=[Pi(0,0,e,n)],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,n){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,n!==void 0&&(this._snapshot.documentMetadata.licenseUrl=n),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,n,r){let i=J(),o=n.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),s={kind:"symbol",id:i,name:e,shapes:o};r?.thumbnail&&(s.thumbnail=r.thumbnail),r?.defKind&&(s.defKind=r.defKind);let a={...r?.rootAttributes??{}},c=a.viewBox;delete a.viewBox,r?.viewBox!==null&&(s.viewBox=r?.viewBox??c??"0 0 100 100");for(let l of["preserveAspectRatio","x","y","width","height","refX","refY"])r?.[l]!==void 0?s[l]=r[l]:s[l]===void 0&&a[l]!==void 0&&(s[l]=a[l]),delete a[l];return Object.keys(a).length>0&&(s.rootAttributes=a),r?.variantAxes&&(s.variantAxes=r.variantAxes),r?.variants&&(s.variants=Object.fromEntries(Object.entries(r.variants).map(([l,d])=>[l,d]))),r?.variantThumbnails&&(s.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(s),i}placeSymbolInstance(e,n,r,i={}){let o=i.width,s=i.height,a={symbolId:e,x:n,y:r,width:o??100,height:s??100},c=i.authoredUseGeometry??{x:String(n),y:String(r),...o!==void 0?{width:String(o)}:{},...s!==void 0?{height:String(s)}:{}};Object.keys(c).length>0&&(a.authoredUseGeometry=c),i.variantKey&&(a.variantKey=i.variantKey),i.symbolOverrides&&(a.symbolOverrides=i.symbolOverrides),i.instancePresentation&&(a.instancePresentation=i.instancePresentation);let l={id:J(),type:"symbol-instance",state:a};return this._snapshot.shapes.push(l),this}removeSymbol(e){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===e)),this._snapshot.library.length<n}get symbols(){return(this._snapshot.library??[]).filter(e=>e.kind==="symbol")}defineMarker(e,n,r){let i=J(),o=n.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),s={kind:"marker",id:i,name:e,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:o};return r?.preserveAspectRatio!==void 0&&(s.preserveAspectRatio=r.preserveAspectRatio),r?.authoredGeometry&&(s.authoredGeometry={...r.authoredGeometry}),r?.rootAttributes&&(s.rootAttributes={...r.rootAttributes}),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineFilter(e,n,r){let i=J(),o={kind:"filter",id:i,name:e,filters:n};return r?.colorInterpolation&&(o.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(o.filterUnits=r.filterUnits),r?.primitiveUnits&&(o.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(o.x=r.x),r?.y!==void 0&&(o.y=r.y),r?.width!==void 0&&(o.width=r.width),r?.height!==void 0&&(o.height=r.height),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineLinearGradientLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"linear-gradient",id:i,name:e,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}defineRadialGradientLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"radial-gradient",id:i,name:e,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}definePatternLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,customPatternId:c,...l}=o,d={kind:"pattern",id:i,name:e,pattern:l};return r?.thumbnail&&(d.thumbnail=r.thumbnail),this._pushLibraryDef(d),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>r.id!==e),this._snapshot.library.length<n}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let n=this._snapshot.library.findIndex(r=>r.id===e.id);n>=0?this._snapshot.library[n]=e:this._snapshot.library.push(e)}addClipGroup(e,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=J(),o={id:i,type:"clip",clipShapeIds:e,contentShapeIds:n,parentId:null};return r?.clipPathUnits&&(o.clipPathUnits=r.clipPathUnits),r?.clipRule&&(o.clipRule=r.clipRule),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}addMaskGroup(e,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=J(),o={id:i,type:"mask",clipShapeIds:e,contentShapeIds:n,parentId:null};return r?.maskUnits&&(o.maskUnits=r.maskUnits),r?.maskContentUnits&&(o.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(o.maskBounds=r.maskBounds),r?.maskType&&(o.maskType=r.maskType),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let n=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==e),this._snapshot.clipMaskGroups.length<n}addGuide(e,n,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=J(),o={id:i,orientation:e,position:n,controlPointOffset:0};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.guides.push(o),i}removeGuide(e){if(!this._snapshot.guides)return!1;let n=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==e),this._snapshot.guides.length<n}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,n,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=J(),o={id:i,type:e,points:n,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.measurements.push(o),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let n=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==e),this._snapshot.measurements.length<n}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,n,r,i){let o=J();return this._pushLibraryDef(ko({id:o,name:e,svgContent:n,width:r,height:i})),o}removeCustomPattern(e){let n=this._snapshot.library;if(!n)return!1;let r=n.length;return this._snapshot.library=n.filter(i=>!(i.kind==="pattern"&&i.id===e)),this._snapshot.library.length<r}get customPatterns(){let e=[];for(let n of this._snapshot.library??[]){if(n.kind!=="pattern")continue;let r=Wd(n);r&&e.push(r)}return e}bringToFront(e){let n=this._snapshot.shapes.findIndex(r=>r.id===e);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.push(r)}return this}sendToBack(e){let n=this._snapshot.shapes.findIndex(r=>r.id===e);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.unshift(r)}return this}reorder(e,n){let r=this._snapshot.shapes.findIndex(i=>i.id===e);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),o=Math.max(0,Math.min(n,this._snapshot.shapes.length));this._snapshot.shapes.splice(o,0,i)}return this}defineVariable(e,n,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let o=this._snapshot.templateVariables.find(s=>s.name===e);if(o)o.type=n,o.defaultValue=r,i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description);else{let s={name:e,type:n,defaultValue:r};i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description),this._snapshot.templateVariables.push(s)}return this}removeVariable(e){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(n=>n.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return eu(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:n,...r}=e??{},i=Sa(this._snapshot,n);return Vo(i,r)}toSVGWithDiagnostics(e){let{variables:n,...r}=e??{},i=Sa(this._snapshot,n);return qa(i,r)}toJSON(e){return Yd(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,n){return Qu(this._snapshot,{...n,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var tp=class{_track;constructor(e,n){this._track={id:J(),shapeId:e,property:n,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,n,r="linear"){return this._track.keyframes.push({id:J(),time:e,value:n,easing:r}),this}keyframeBezier(e,n,r){return this._track.keyframes.push({id:J(),time:e,value:n,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(e,n,r){return this._track.keyframes.push({id:J(),time:e,value:n,easing:"linear-function",linearPoints:r}),this}keyframes(...e){return this._track.keyframes.push(...e.map(n=>({...n,id:n.id??J()}))),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,n="trackShape"){return this._track.motionPathRef={shapeId:e,mode:n},this}beginTrigger(e,n){return this._track.beginTrigger={type:e,value:n},this}endTrigger(e,n){return this._track.endTrigger={type:e,value:n},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,n){return this._track.transformOrigin={x:e,y:n},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}fill(e){return this._track.fill=e,this}fillBackwards(e=!0){return this._track.fillBackwards=e,this}build(){let e=[...this._track.keyframes].sort((n,r)=>n.time-r.time);return{...this._track,keyframes:e}}},np=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(n=>({id:n.id,shapeId:n.shapeId,property:n.property,enabled:n.enabled,locked:n.locked||void 0,motionPath:n.motionPath,motionPathRef:n.motionPathRef,beginTrigger:n.beginTrigger,endTrigger:n.endTrigger,cycleDuration:n.cycleDuration,cycleRepeats:n.cycleRepeats,cycleInfinite:n.cycleInfinite,cycleBehavior:n.cycleBehavior,fillBackwards:n.fillBackwards,transformOrigin:n.transformOrigin,motionRotate:n.motionRotate,additive:n.additive,fill:n.fill,keyframes:n.keyframes.map(r=>({id:r.id,time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var ht=class{_id;_type;_state={};constructor(e,n){this._type=e,this._id=n??J()}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,n){return this._state.fillColor=e,this._state.fillType="solid",n!==void 0&&(this._state.fillOpacity=n),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let n="build"in e?e.build():e;return this._state.fillType=n.type,this._state.fillGradient=n,this}fillPattern(e){let n="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=n,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,n){return this._state.borderColor=e,n!==void 0&&(this._state.borderWidth=n),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 n="build"in e?e.build():e;return this._state.strokeType=n.type,this._state.strokeGradient=n,this}strokePattern(e){let n="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=n,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,n,r){return this._state.lineStyle=e,e==="custom"&&(n!==void 0&&(this._state.dashLength=n),r!==void 0&&(this._state.gapLength=r)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,n){return this._state.skewX=e,this._state.skewY=n,this.refreshTransformMatrix(),this}scale(e,n){return this._state.scaleX=e,this._state.scaleY=n??e,this.refreshTransformMatrix(),this}pivot(e,n){return this._state.customPivot={x:e,y:n},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=tt(ks(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let n=this._state.x,r=this._state.y,i=this._state.width,o=this._state.height;if(n!==void 0&&r!==void 0&&i!==void 0&&o!==void 0)return{x:n+i/2,y:r+o/2};let s=this._state.radius;if(n!==void 0&&r!==void 0&&s!==void 0)return{x:n,y:r};let a=this._state.cx,c=this._state.cy;if(a!==void 0&&c!==void 0)return{x:a,y:c};let l=this._state.x1,d=this._state.y1,u=this._state.x2,p=this._state.y2;if(l!==void 0&&d!==void 0&&u!==void 0&&p!==void 0)return{x:(l+u)/2,y:(d+p)/2};let f=this._state.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let m=this._state.polylinePoints;if(m?.[0])return m[0]}filter(...e){let n=this._state.filters??[];return this._state.filters=[...n,...e],this}dropShadow(e={}){let n={id:`drop-shadow-${J()}`,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(n)}innerShadow(e={}){let n={id:`inner-shadow-${J()}`,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(n)}blur(e,n,r){let i=e??4,o=n??i,s={id:`gaussian-blur-${J()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:o,linked:i===o,quality:r?.quality??"normal"};return this.filter(s)}glow(e={}){let n={id:`glow-${J()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(n)}innerGlow(e={}){let n={id:`inner-glow-${J()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(n)}grayscale(e=1){let n={id:`grayscale-${J()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(n)}sepia(e=1){let n={id:`sepia-${J()}`,type:"sepia",enabled:!0,amount:e};return this.filter(n)}outline(e={}){return this.filter({id:`outline-${J()}`,type:"outline",enabled:!0,width:e.width??3,color:e.color??"#000000",opacity:e.opacity??1,position:e.position??"outside"})}motionBlur(e={}){let n={id:`motion-blur-${J()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(n)}pointLight(e={}){let n={id:`point-light-${J()}`,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(n)}spotLight(e={}){let n={id:`spot-light-${J()}`,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(n)}sharpen(e=1){let n={id:`sharpen-${J()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(n)}pixelate(e=8){let n={id:`pixelate-${J()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(n)}warp(e={}){let n={id:`warp-${J()}`,type:"warp",enabled:!0,scale:e.scale??10,frequency:e.frequency??.02,octaves:e.octaves??1,warpType:e.warpType??"turbulence"};return this.filter(n)}morphology(e={}){let n=e.radiusX??2,r=e.radiusY??n,i={id:`morphology-${J()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:n,radiusY:r,linked:e.linked??n===r};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${J()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${J()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(r)}roundEdges(e=4){let n={id:`round-edges-${J()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(n)}channelPainter(e={}){let n={id:`channel-painter-${J()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(n)}brightness(e=1){let n={id:`brightness-${J()}`,type:"brightness",enabled:!0,amount:e};return this.filter(n)}contrast(e=1){let n={id:`contrast-${J()}`,type:"contrast",enabled:!0,amount:e};return this.filter(n)}filterOpacity(e=1){let n={id:`opacity-${J()}`,type:"opacity",enabled:!0,amount:e};return this.filter(n)}invert(e=1){let n={id:`invert-${J()}`,type:"invert",enabled:!0,amount:e};return this.filter(n)}hueRotate(e=0){let n={id:`hue-rotate-${J()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(n)}saturate(e=1){let n={id:`saturate-${J()}`,type:"saturate",enabled:!0,amount:e};return this.filter(n)}blackAndWhite(e=.5){let n={id:`black-and-white-${J()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(n)}duotone(e={}){let n={id:`duotone-${J()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(n)}xray(e=1){let n={id:`xray-${J()}`,type:"xray",enabled:!0,intensity:e};return this.filter(n)}noise(e={}){let n={id:`noise-${J()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(n)}emboss(e={}){let n={id:`emboss-${J()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(n)}filmGrain(e={}){let n={id:`film-grain-${J()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(n)}watercolor(e={}){let n={id:`watercolor-${J()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(n)}gouache(e={}){let n={id:`gouache-${J()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(n)}inkBlot(e={}){let n={id:`ink-blot-${J()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(n)}crumpledPlastic(e={}){let n={id:`crumpled-plastic-${J()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(n)}riddled(e={}){let n={id:`riddled-${J()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(n)}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,n="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=n,this}strokeLibrary(e,n="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=n,this}filterLibrary(...e){let n=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...n,...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,n){let r=this._state.bindings??{};return this._state.bindings={...r,[e]:n},this}metadata(e){return this._state.metadata={...this._state.metadata,...e},this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},rp=class extends ht{constructor(e,n,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=n,this._state.radius=r}position(e,n){return this._state.x=e,this._state.y=n,this}radius(e){return this._state.radius=e,this}},ip=class extends ht{constructor(e,n,r,i){if(r<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=n,this._state.rx=r,this._state.ry=i}position(e,n){return this._state.cx=e,this._state.cy=n,this}radii(e,n){return this._state.rx=e,this._state.ry=n,this}},op=class extends ht{constructor(e,n,r,i){if(r<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=i}position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,n){return this._state.rx=e,this._state.ry=n,e===n&&(this._state.cornerRadius=e),this}},sp=class extends ht{constructor(e,n,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=r}position(e,n){return this._state.x=e,this._state.y=n,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,n){return this._state.rx=e,this._state.ry=n,e===n&&(this._state.cornerRadius=e),this}},ap=class extends ht{constructor(e,n,r,i){super("line"),this._state.x1=e,this._state.y1=n,this._state.x2=r,this._state.y2=i}from(e,n){return this._state.x1=e,this._state.y1=n,this}to(e,n){return this._state.x2=e,this._state.y2=n,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}},cp=class extends ht{constructor(e,n,r){super("text"),this._state.x=e,this._state.y=n,this._state.text=r}position(e,n){return this._state.x=e,this._state.y=n,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,n=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=n,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}richTextSegments(e){return this._state.richTextRuns=Jn(e),this}richTextRuns(e){let n=ei(e);return this._state.richTextRuns=n,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}},Kt=class extends ht{constructor(e,n,r,i){super(e),this._state.cx=n,this._state.cy=r,this._state.radius=i}position(e,n){return this._state.cx=e,this._state.cy=n,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}},lp=class extends Kt{constructor(e,n,r){super("triangle",e,n,r)}},dp=class extends Kt{constructor(e,n,r,i=5){super("ngon",e,n,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},up=class extends Kt{constructor(e,n,r){super("star",e,n,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},pp=class extends Kt{constructor(e,n,r){super("cross",e,n,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},fp=class extends Kt{constructor(e,n,r){super("ring",e,n,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},mp=class extends Kt{constructor(e,n,r){super("spiral",e,n,r),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}},gp=class extends Kt{constructor(e,n,r){super("gear",e,n,r),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}},hp=class extends Kt{constructor(e,n,r){super("arrow",e,n,r),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}},yp=class extends Kt{constructor(e,n,r){super("heart",e,n,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},Sp=class extends Kt{constructor(e,n,r){super("lightning",e,n,r),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}},bp=class extends Kt{constructor(e,n,r){super("cloud",e,n,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},vp=class extends Kt{constructor(e,n,r){super("speechBubble",e,n,r),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}},Kr=class extends ht{add(e){let n="build"in e&&typeof e.build=="function"?e.build():e,r=this._state.children??[];return this._state.children=[...r,n],this}addAll(...e){for(let n of e)this.add(n);return this}children(e){return this._state.children=e.map(n=>"build"in n&&typeof n.build=="function"?n.build():n),this}},xp=class extends Kr{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}},Ip=class extends Kr{constructor(){super("switch")}},wp=class extends Kr{constructor(){super("container")}},kp=class extends ht{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,n,r,i){return this._state.viewBoxX=e,this._state.viewBoxY=n,this._state.viewBoxWidth=r,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}},Pp=class extends Kr{constructor(e=0,n=0,r=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=n,this._state.svgWidth=r,this._state.svgHeight=i}position(e,n){return this._state.svgX=e,this._state.svgY=n,this}size(e,n){return this._state.svgWidth=e,this._state.svgHeight=n,this}viewBox(e,n,r,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=n,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},Tp=class extends ht{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,n){return this._state.offsetX=e,this._state.offsetY=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}},Rp=class extends ht{position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,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,n){return this._state.trimStart=e,this._state.trimEnd=n,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,n){return this._state.fadeInDuration=e,this._state.fadeOutDuration=n,this}language(e){return this._state.systemLanguage=e,this}},Cp=class extends Rp{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}},$p=class extends Rp{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},Np=class extends ht{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,n){let r=this._state.pathPoints??[];return r.push({x:e,y:n}),this._state.pathPoints=r,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,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}toD(){let e=this._state.pathPoints??[],n=this._state.pathCurveType??"CUBIC",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,o=this._state.pathArcParams;return kr(e,n,r,i,o)}},Ap=class extends ht{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,n){let r=this._state.polylinePoints??[];return r.push({x:e,y:n}),this._state.polylinePoints=r,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,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}},Ep=class extends ht{constructor(e,n,r,i,o){super("image"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=i,this._state.href=o}position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var Ja=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,n=0,r=1,i=0){this._x1=e,this._y1=n,this._x2=r,this._y2=i,this._id=J()}stop(e,n,r=1){return this._stops.push({offset:e,color:n,opacity:r}),this}direction(e,n,r,i){return this._x1=e,this._y1=n,this._x2=r,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}}},Qa=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=J()}center(e,n){return this._cx=e,this._cy=n,this}focus(e,n){return this._fx=e,this._fy=n,this}radius(e,n){return this._r=e,this._ry=n??e,this}rotation(e){return this._rotation=e,this}stop(e,n,r=1){return this._stops.push({offset:e,color:n,opacity:r}),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}}},ec=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",n="#000000",r="#ffffff"){this._patternType=e,this._color=n,this._backgroundColor=r,this._id=J()}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,n){return this._width=e,this._height=n,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,n){return this._x=e,this._y=n,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,n,r;if(this._svgContent!==void 0)e=this._svgContent,n=this._width??10,r=this._height??10;else{let o=ud(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=o.svgContent,n=this._width??o.width,r=this._height??o.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:n,height:r,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 bw(t=0,e=0,n=1,r=0){return new Ja(t,e,n,r)}function vw(){return new Qa}function xw(t="stripes",e="#000000",n="#ffffff"){return new ec(t,e,n)}var Th={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Mz=.04,Oz=0;function Dz(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function ae(t){return Number(t.toFixed(3)).toString()}function zz(t,e,n,r,i,o,s,a,c,l,d,u){return[[0,0],[.2,a],[.5+c+d,-o+l],[.5-o+c,o+l],[.5-2*o+c-d,3*o+l],[.5+2*o+c-d,3*o+l],[.5+o+c,o+l],[.5+c+d,-o+l],[.8,u],[1,0]].map(([f,m])=>{let g=e+f*r,h=n+m*i*s;return t?{x:g,y:h}:{x:h,y:g}})}function Iw(t,e,n,r,i,o,s,a,c,l,d){let u=[],p=(x,k)=>c==="alternating"?0:x+l()*(k-x),f=()=>l()<.5,m=p(-a,a),g=c==="alternating"?d%2===0:f(),h=null,y=m,b=p(-a,a),v=p(-a,a),I=p(-a,a);m=p(-a,a);for(let x=0;x<t;x++){x>0&&(h=g,g=c==="alternating"?(d+x)%2===0:f(),y=g===h?-m:m,b=p(-a,a),v=p(-a,a),I=p(-a,a),m=p(-a,a));let k=g?-1:1,T=n+x*i;u.push(zz(e,T,r,i,o,s,k,y,b,v,I,m))}return u}function ww(t,e,n,r,i,o,s){let a=2*o;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([l,d])=>{let u=e+l*r,p=n+d*i*s;return t?{x:u,y:p}:{x:p,y:u}})}function kw(t,e){return t+` C ${ae(e[1].x)} ${ae(e[1].y)} ${ae(e[2].x)} ${ae(e[2].y)} ${ae(e[3].x)} ${ae(e[3].y)} C ${ae(e[4].x)} ${ae(e[4].y)} ${ae(e[5].x)} ${ae(e[5].y)} ${ae(e[6].x)} ${ae(e[6].y)} C ${ae(e[7].x)} ${ae(e[7].y)} ${ae(e[8].x)} ${ae(e[8].y)} ${ae(e[9].x)} ${ae(e[9].y)}`}function Pw(t,e){return t+` C ${ae(e[8].x)} ${ae(e[8].y)} ${ae(e[7].x)} ${ae(e[7].y)} ${ae(e[6].x)} ${ae(e[6].y)} C ${ae(e[5].x)} ${ae(e[5].y)} ${ae(e[4].x)} ${ae(e[4].y)} ${ae(e[3].x)} ${ae(e[3].y)} C ${ae(e[2].x)} ${ae(e[2].y)} ${ae(e[1].x)} ${ae(e[1].y)} ${ae(e[0].x)} ${ae(e[0].y)}`}function Tw(t,e={}){let n={...Th,...e};if(n.rows<1||n.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(t.width)||!Number.isFinite(t.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(t.width<=0||t.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:o,tabDepthPercent:s,tabPattern:a,seed:c}=n,l=Dz(c),d=t.width/i,u=t.height/r,p=Math.max(0,Math.min(.4,s/200)),f=(o==="classic"||o==="curved")&&p>0,m=o==="square-tabs"&&p>0,g=o==="classic"&&a==="random"?Mz:Oz,h=[];for(let v=0;v<r-1;v++){let I=t.y+(v+1)*u;if(f)h.push(Iw(i,!0,t.x,I,d,u,p,g,a,l,v));else if(m){let x=[];for(let k=0;k<i;k++){let T=a==="alternating"?(v+k)%2===0?1:-1:l()<.5?1:-1;x.push(ww(!0,t.x+k*d,I,d,u,p,T))}h.push(x)}else h.push(new Array(i).fill(null))}let y=[];for(let v=0;v<i-1;v++){let I=t.x+(v+1)*d;if(f)y.push(Iw(r,!1,t.y,I,u,d,p,g,a,l,v));else if(m){let x=[];for(let k=0;k<r;k++){let T=a==="alternating"?(k+v)%2===0?1:-1:l()<.5?1:-1;x.push(ww(!1,t.y+k*u,I,u,d,p,T))}y.push(x)}else y.push(new Array(r).fill(null))}let b=[];for(let v=0;v<r;v++)for(let I=0;I<i;I++){let x=t.x+I*d,k=t.y+v*u,T=x+d,w=k+u,P=`M ${ae(x)} ${ae(k)}`;if(v===0)P+=` L ${ae(T)} ${ae(k)}`;else{let N=h[v-1][I];N?P=kw(P,N):P+=` L ${ae(T)} ${ae(k)}`}if(I===i-1)P+=` L ${ae(T)} ${ae(w)}`;else{let N=y[I][v];N?P=kw(P,N):P+=` L ${ae(T)} ${ae(w)}`}if(v===r-1)P+=` L ${ae(x)} ${ae(w)}`;else{let N=h[v][I];N?P=Pw(P,N):P+=` L ${ae(x)} ${ae(w)}`}if(I===0)P+=` L ${ae(x)} ${ae(k)}`;else{let N=y[I-1][v];N?P=Pw(P,N):P+=` L ${ae(x)} ${ae(k)}`}P+=" Z",b.push({id:`puzzle-${c}-r${v}-c${I}`,row:v,col:I,d:P})}return b}var $w=[1,2,3,4,5,6,7,8,9],_z={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 tc(t){return t.map(e=>[...e])}function Fz(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function Nw(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Aw(t,e){let n=[...t];for(let r=n.length-1;r>0;r--){let i=Math.floor(e()*(r+1));[n[r],n[i]]=[n[i],n[r]]}return n}function Ho(t){return 1<<t-1}function Ew(t){let e=0,n=t;for(;n;)n&=n-1,e++;return e}function Lz(t){for(let e=1;e<=9;e++)if(t===Ho(e))return e;return 0}function Ch(t,e){return Math.floor(t/3)*3+Math.floor(e/3)}function Rh(t){let e=0;for(let n of t)for(let r of n)r!==0&&e++;return e}function Bz(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function Mw(t,e){if(!Array.isArray(t)||t.length!==9)return e.push("Grid must contain 9 rows."),!1;let n=!0;for(let r=0;r<9;r++){if(!Array.isArray(t[r])||t[r].length!==9){e.push(`Row ${r+1} must contain 9 cells.`),n=!1;continue}for(let i=0;i<9;i++){let o=t[r][i];(!Number.isInteger(o)||o<0||o>9)&&(e.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),n=!1)}}return n}function Ow(t,e){let n=!0,r=(i,o)=>{let s=0;for(let a of o){if(a===0)continue;let c=Ho(a);if(s&c){e.push(`${i} contains duplicate ${a}.`),n=!1;return}s|=c}};for(let i=0;i<9;i++)r(`Row ${i+1}`,t[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,t.map(o=>o[i]));for(let i=0;i<9;i+=3)for(let o=0;o<9;o+=3){let s=[];for(let a=i;a<i+3;a++)for(let c=o;c<o+3;c++)s.push(t[a][c]);r(`Box ${Math.floor(i/3)*3+Math.floor(o/3)+1}`,s)}return n}function $h(t){let e=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let o=0;o<9;o++){let s=t[i][o];if(s===0)continue;let a=Ho(s),c=Ch(i,o);if(e[i]&a||n[o]&a||r[c]&a)return null;e[i]|=a,n[o]|=a,r[c]|=a}return{rows:e,cols:n,boxes:r}}function Nh(t,e,n,r,i){return 511&~(n[t]|r[e]|i[Ch(t,e)])}function Dw(t,e,n){let r=$h(t);if(!r)return[];let i=tc(t),o=[],{rows:s,cols:a,boxes:c}=r,l=()=>{if(o.length>=e)return;let d=-1,u=-1,p=0,f=10;for(let g=0;g<9;g++){for(let h=0;h<9;h++){if(i[g][h]!==0)continue;let y=Nh(g,h,s,a,c),b=Ew(y);if(b===0)return;if(b<f&&(d=g,u=h,p=y,f=b,b===1))break}if(f===1)break}if(d===-1){o.push(tc(i));return}let m=$w.filter(g=>p&Ho(g));n&&(m=Aw(m,n));for(let g of m){let h=Ho(g),y=Ch(d,u);if(i[d][u]=g,s[d]|=h,a[u]|=h,c[y]|=h,l(),c[y]&=~h,a[u]&=~h,s[d]&=~h,i[d][u]=0,o.length>=e)return}};return l(),o}function Gz(t){let e=Fz(),n=Nw(t),[r]=Dw(e,1,n);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function Vz(t){let e=$h(t);if(!e)return null;for(let n=0;n<9;n++)for(let r=0;r<9;r++){if(t[n][r]!==0)continue;let i=Nh(n,r,e.rows,e.cols,e.boxes);if(Ew(i)===1)return{row:n,col:r,value:Lz(i)}}return null}function jz(t){let e=$h(t);if(!e)return null;let n=r=>{for(let i of $w){let o=Ho(i),s=null;for(let a of r)if(!(t[a.row][a.col]!==0||!(Nh(a.row,a.col,e.rows,e.cols,e.boxes)&o))){if(s){s=null;break}s=a}if(s)return{...s,value:i}}return null};for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:r,col:s})));if(i)return i}for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:s,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let o=[];for(let a=r;a<r+3;a++)for(let c=i;c<i+3;c++)o.push({row:a,col:c});let s=n(o);if(s)return s}return null}function Rw(t){let e=tc(t),n=!1;for(;Rh(e)<81;){let r=Vz(e);if(r){e[r.row][r.col]=r.value;continue}let i=jz(e);if(i){n=!0,e[i.row][i.col]=i.value;continue}return"search"}return n?"hidden-singles":"singles"}function Cw(t,e){let n={singles:0,"hidden-singles":1,search:2};return n[t]<=n[e]}function nc(t,e={}){let n=[];return Mw(t,n)?Ow(t,n)?Dw(t,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function zw(t){let e=[];if(!Mw(t,e))return{valid:!1,unique:!1,solution:null,errors:e};if(Ow(t,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=nc(t,{maxSolutions:2});return r.length===0?e.push("Puzzle has no solution."):r.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:r.length===1,solution:r[0]?tc(r[0]):null,errors:e}}function _w(t){let e=t.difficulty,n=_z[e];if(!n)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=Bz(t.seed);for(let i=0;i<30;i++){let o=r+i*104729>>>0,s=Nw(o),a=Gz(o),c=tc(a),l=n.minGivens+Math.floor(s()*(n.maxGivens-n.minGivens+1)),d=Aw(Array.from({length:81},(m,g)=>({row:Math.floor(g/9),col:g%9})),s);for(let m of d){if(Rh(c)<=l)break;let g=c[m.row][m.col];if(c[m.row][m.col]=0,nc(c,{maxSolutions:2}).length!==1){c[m.row][m.col]=g;continue}let y=Rw(c);Cw(y,n.maxRating)||(c[m.row][m.col]=g)}let u=Rh(c),p=Rw(c);if(nc(c,{maxSolutions:2}).length===1&&u>=n.minGivens&&u<=n.maxGivens&&Cw(p,n.maxRating))return{puzzle:c,solution:a,difficulty:e,seed:r,givens:u,rating:p}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}var Fw="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Uz={E:{direction:"E",dr:0,dc:1},S:{direction:"S",dr:1,dc:0},SE:{direction:"SE",dr:1,dc:1},NE:{direction:"NE",dr:-1,dc:1},W:{direction:"W",dr:0,dc:-1},N:{direction:"N",dr:-1,dc:0},NW:{direction:"NW",dr:-1,dc:-1},SW:{direction:"SW",dr:1,dc:-1}};function Bw(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function Gw(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Wo(t){let e=globalThis.Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment.normalize("NFC")):Array.from(t.normalize("NFC"))}function Hz(t,e,n,r){return t>=0&&e>=0&&t<r&&e<n}function Ah(t,e){return Array.from({length:e},()=>Array.from({length:t},()=>!0))}function Vw(t,e,n,r){if(!n)return Ah(t,e);if(!Array.isArray(n)||n.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),Ah(t,e);let i=[];for(let o=0;o<e;o++){if(!Array.isArray(n[o])||n[o].length!==t)return r.push(`Mask row ${o+1} must contain exactly ${t} cells.`),Ah(t,e);i.push(n[o].map(Boolean))}return i}function Wz(t){let e=0;for(let n of t)for(let r of n)r&&e++;return e}function Kz(t){return t.trim().normalize("NFC")}function jw(t){return t.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function Eh(t,e){let n=[];return t.across&&(n.push("E"),e&&n.push("W")),t.down&&(n.push("S"),e&&n.push("N")),t.diagonal&&(n.push("SE","NE"),e&&n.push("NW","SW")),n}function Xz(t,e,n,r,i,o,s,a){let c=Wo(t),l=[];for(let d=0;d<c.length;d++){let u=e+r.dr*d,p=n+r.dc*d;if(!Hz(u,p,o,s)||!i[u][p])return null;l.push({row:u,col:p,grapheme:c[d]})}return{word:t,graphemes:c,row:e,col:n,direction:r.direction,dr:r.dr,dc:r.dc,cells:l,jitter:a}}function Uw(t,e,n,r,i,o){let s=[];for(let a of e){let c=Uz[a];for(let l=0;l<i;l++)for(let d=0;d<r;d++){let u=Xz(t,l,d,c,n,r,i,o());u&&s.push(u)}}return s}function Mh(t){let e=[],n=[],r=[],i=Math.floor(t.width),o=Math.floor(t.height);(!Number.isInteger(i)||i<2||i>64)&&e.push("Width must be an integer from 2 to 64."),(!Number.isInteger(o)||o<2||o>64)&&e.push("Height must be an integer from 2 to 64.");let s=Eh(t.axes,t.allowBackwards);s.length===0&&e.push("At least one word direction must be enabled.");let a=Vw(Math.max(1,i),Math.max(1,o),t.mask,e),c=Wz(a);c===0&&e.push("Mask must contain at least one active cell.");let l=new Set,d=[];for(let f of t.words){let m=Kz(f);if(m){if(/\s/u.test(m)){r.push({input:f,reason:"Words cannot contain whitespace."});continue}if(l.has(m)){r.push({input:f,reason:"Duplicate word."});continue}l.add(m),d.push(m)}}d.length===0&&e.push("Enter at least one word.");let u=Gw(Bw(t.seed));if(e.length===0)for(let f=d.length-1;f>=0;f--){let m=d[f];Uw(m,s,a,i,o,u).length===0&&(r.push({input:m,reason:"No legal placement exists for the current size, mask, and directions."}),d.splice(f,1))}r.length>0&&e.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let p=Math.max(0,c);return d.length>p&&n.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:d,rejectedWords:r,errors:e,warnings:n,minWords:1,maxWords:p,activeCells:c,directions:s}}function Yz(t,e){for(let n of e.cells){let r=t[n.row][n.col];if(r!==null&&r!==n.grapheme)return!0}return!1}function qz(t,e){let n=[];for(let r of e.cells)t[r.row][r.col]===null&&(n.push({row:r.row,col:r.col}),t[r.row][r.col]=r.grapheme);return n}function Zz(t,e){for(let n of e)t[n.row][n.col]=null}function Lw(t,e){let n=0;for(let r of e.cells)t[r.row][r.col]===r.grapheme&&n++;return n}function Jz(t){return{word:t.word,row:t.row,col:t.col,direction:t.direction,path:t.cells.map(e=>({...e}))}}function Qz(t){let e=t.fillerAlphabet??Fw,n=typeof e=="string"?Wo(e):e.flatMap(i=>Wo(i)),r=n.filter((i,o)=>i.trim()&&n.indexOf(i)===o);return r.length>0?r:Wo(Fw)}function Hw(t){let e=Math.floor(t.width),n=Math.floor(t.height),r=Bw(t.seed),i=Mh({...t,width:e,height:n,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let o=Vw(e,n,t.mask,[]),s=Math.max(1,Math.floor(t.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let c=Gw(r+a*104729>>>0),l=i.directions,d=new Map;for(let b of i.acceptedWords)d.set(b,Uw(b,l,o,e,n,c));let u=[...i.acceptedWords].sort((b,v)=>{let I=d.get(b)?.length??0,x=d.get(v)?.length??0;return I!==x?I-x:Wo(v).length-Wo(b).length}),p=Array.from({length:n},(b,v)=>Array.from({length:e},(I,x)=>o[v][x]?null:"")),f=[],m=new Map,g=0,h=b=>{if(++g>s)return!1;if(b>=u.length)return!0;let v=u[b],I=[...d.get(v)??[]].filter(x=>!Yz(p,x)).sort((x,k)=>{let T=Lw(p,k)-Lw(p,x);if(T!==0)return T;let w=(m.get(x.direction)??0)-(m.get(k.direction)??0);return w!==0?w:x.jitter-k.jitter});for(let x of I){let k=qz(p,x);if(f.push(Jz(x)),m.set(x.direction,(m.get(x.direction)??0)+1),h(b+1))return!0;m.set(x.direction,(m.get(x.direction)??1)-1),f.pop(),Zz(p,k)}return!1};if(!h(0))continue;let y=Qz(t);for(let b=0;b<n;b++)for(let v=0;v<e;v++)o[b][v]?p[b][v]===null&&(p[b][v]=y[Math.floor(c()*y.length)]):p[b][v]="";return{width:e,height:n,grid:p,mask:o.map(b=>[...b]),normalizedWords:[...i.acceptedWords],placements:[...f],seed:r,title:t.title,creator:t.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function e_(t,e,n){let r=!1;for(let i=0,o=n.length-1;i<n.length;o=i++){let s=n[i],a=n[o];s.y>e!=a.y>e&&t<(a.x-s.x)*(e-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function t_(){let t=[];for(let e=0;e<10;e++){let n=e%2===0?.5:.23,r=-Math.PI/2+e*Math.PI/5;t.push({x:.5+Math.cos(r)*n,y:.5+Math.sin(r)*n})}return t}function Ww(t,e,n){let r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(e)),o=t_();return Array.from({length:i},(s,a)=>Array.from({length:r},(c,l)=>{let d=(l+.5)/r,u=(a+.5)/i,p=d*2-1,f=u*2-1;switch(n){case"rectangle":return!0;case"circle":return p*p+f*f<=1;case"triangle":return u>=.08&&u<=.95&&Math.abs(p)<=u;case"diamond":return Math.abs(p)+Math.abs(f)<=1;case"star":return e_(d,u,o);case"heart":{let m=p*1.25,g=-f*1.25;return Math.pow(m*m+g*g-1,3)-m*m*g*g*g<=0}case"cross":return Math.abs(p)<=.32||Math.abs(f)<=.32;default:return!0}}))}0&&(module.exports={ANIMATION_MANAGER_INTERPOLATION_POLICY,Arrow,Audio,BROWSER_SVG_EXTENSION_URIS,BUILTIN_MARKER_ID_MAP,CANONICAL_NORMALIZATION_FAULT_POINTS,CC_NS,COLLAB_PROTOCOL_VERSION,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,CanonicalDocument,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DC_NS,DEFAULT_COORDINATE_PRECISION,DEFAULT_RICH_TEXT_STYLE,DOCUMENT_FIELDS,DOCUMENT_FIELD_LIVE_AUTHORITY,DOCUMENT_INGEST_POLICIES,DOCUMENT_SECTION_ORDER,DocumentBuilder,DocumentModel,DocumentSession,EASING_CURVES,EasingType,Ellipse,Gear,HEADLESS_SVG_STYLE_ENVIRONMENT,Heart,Hyperlink,IDENTITY_AFFINE,INGEST_APPLY_STAGES,INGEST_DIAGNOSTIC_CODES,INGEST_DOCUMENT_ROOT_IDENTITY,INGEST_FEATURES,INGEST_FEATURE_CAPABILITIES,INGEST_PLAN_VERSION,INGRESS_INTENTS,INLINE_CHILD_CONTAINER_TYPES,ImageShape,IngestApplicationError,KNOWN_METADATA_PREFIXES,KNOWN_STATE_KEYS,LIBRARY_ASSEMBLY_KIND_ORDER,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MATHML_EXTENSION_URI,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PAINT_SERVER_PASSTHROUGH_ATTR,PRESENTATION_SEMANTICS,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RDF_NS,RENDER_DIAGNOSTIC_CODES,RENDER_FEATURES,RENDER_FEATURE_CAPABILITIES,RENDER_TARGETS,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SAXES_SVG_XML_PARSER_HOST,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_ENVELOPE_KEYS,SHAPE_TRANSFORM_STATE_KEYS,SVGSKETCH_NS,SVGSKETCH_PATH_EXTENSIONS,SVG_CONDITIONAL_PROCESSING_ATTRIBUTES,SVG_IMPORT_CAPABILITY_OWNERS,SVG_NAMESPACE,SVG_NS,SVG_PRESENTATION_PROPERTIES,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,SvgImportError,SvgXmlParserHostError,Switch,TYPED_FIELD_PREDICATES,Text,TextLayoutEngine,Timeline,Track,Triangle,VARIANT_INTERPOLATION_POLICY,Video,View,XHTML_EXTENSION_URI,addSmilPointsValues,affine,affineFromArray,affineToArray,almostEqualAffine,animationBackwardsFillTrack,animationCycleDuration,animationTrackActiveEnd,animationTrackDocumentBegin,applyAffineToPoint,applyAffineToVector,applyClipMaskGroupDelta,applyClipMaskPlanToShapes,applyCssAnimationLonghandOverrides,applyGuideDeltaOp,applyIngestPlan,applyMeasurementDeltaOp,applyMetadataDeltaOp,applyOpToSnapshot,applyOpsInPlace,applyOpsToSnapshot,applyOpsToSnapshotWithAccepted,applyRichTextFormat,applyTextSplice,applyTextTransform,applyTimingFunctionToKeyframe,arcEndpointToCenter,areTracksTimingEquivalent,around,assembleLibraryDefs,assembleSvgFromPlan,assertIngestFeatureRegistry,assertIngestPolicyRegistry,assertSvgImportCapabilityOwners,buildCompoundTransformValues,buildFreshMetadataBlock,buildGuideDeltaOps,buildManagedChildren,buildManagedDescription,buildMeasurementDeltaOps,buildMetadataDeltaOps,buildRenderPlan,buildSmilKeyframeData,buildSmilKeyframes,buildSvgDestinationIdentityIndex,buildSvgIngestPlan,buildSymbolMaterializationPlan,canonicalPolygonTransformString,canonicalTransformMatrix,canonicalTransformString,classifySvgExternalAssetUrl,clipMaskDefinitionFromGroup,clipMaskDefinitionsFromGroups,clipMaskGroupDefId,clipMaskGroupDefinitionId,clipMaskGroupIsRawBacked,clipMaskGroupWithDefinition,clipMaskOwnedDefIds,collaborationResourceKey,collectDocumentEnvelopeLibraryReferenceIds,collectFontFamiliesFromPlan,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,collectSvgFragmentLibraryReferenceIds,collectUnknownDocumentFields,compareOrderKeys,composeDecomposedTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,containerTransformNeedsContentPivot,createDocument,createSceneNode,createShape,createSvgDestinationIdAllocator,createSvgPathMetrics,createTextLayoutKey,createTextLayoutProduct,createViewbox,createWordSearchPrimitiveMask,cssAnimationFillField,cssNamedColorToRgb,cubicBezierExtent1D,cubicBezierToEasingFields,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decodeCssEscapes,decomposeAffine2D,defaultVariableMode,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,documentObjectBounds,ellipticalArcBounds,emptyDocumentMetadata,escXml,evaluateParsedTimingFunction,evaluateSvgConditionalProcessing,extractVariables,filterAttr,filterChainExtendsBounds,filterDefinitionEnvelope,filterReferenceValue,finalizeRenderPlan,findShapeById,fingerprintIngestSource,flattenShapeStateTree,flattenStateExtra,flattenUnknownDocumentFields,foldSchemaV2AncestorTransformIntoMatrix,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatOperationValidationIssues,formatSmilKeySpline,formatSmilKeyTime,freezeIngestPlan,freezeSiblingOrderKeys,generateCode,generateCodeWithDiagnostics,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getIngestFeatureCapability,getIngestFieldPolicy,getKeyframeCubicBezier,getLicenseLabel,getLicenseUrl,getMarkerDescriptors,getPatternElements,getShapeGeometryKernel,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getSvgPropertySemantics,getSvgSourceAttribute,getSvgSourceHref,getWordSearchDirections,hasAnyTypedMetadataField,hasSvgSourceAttribute,importSvg,importSvgWithDiagnostics,indexLibraryDefinitions,initialOrderKeys,injectClipMaskReference,injectDomTargetAnimationElements,inspectCssTransformValue,interpolateAngle,interpolateCharOffsetArray,interpolateColor,interpolateDasharrayLists,interpolateGradient,interpolateNumericArray,interpolatePathData,interpolatePlainObject,interpolatePointArray,interpolatePolylinePoints,interpolateShapeTrees,interpolateSplinePointArray,invertAffine,isColorValue,isCssNamedColor,isDefaultKeyPoints,isDefaultKeyTimes,isFiniteAffineArray,isGradientLike,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isNumericArray,isReusablePatternTile,isSetSequenceTrack,isSvgPresentationProperty,isValidOrderKey,keyBetween,keysBetween,layoutText,legacyEndpointMarkerId,lerpNumber,linearGradient,linearGradientEnvelope,lintWordSearchOptions,mapAnimationTrackTime,matchCubicBezierToPreset,materializeSceneTreeOrderKeys,matrixTransformPart,maxCollaborationTimestamp,mergeRichTextStyle,migrateSnapshot,migrateV11toV12,migrateV6toV7,migrateViewboxSidecarToViews,motionPathD,moveResourceById,multiplyAffine,mutateSvgClipMaskDefinitionMarkup,nodeSchemas,normalizeClipMaskGroups,normalizePaintServerDef,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,normalizeSmilPointsValue,normalizeSnapshotStructure,normalizeSnapshotToCanonicalDocument,orderSiblings,parseColor,parseCssAnimationShorthand,parseCssTimingFunction,parseCssTransformOrigin,parseDocument,parseDocumentWithDiagnostics,parseInterpolationNumbers,parsePreserveAspectRatio,parseSmilAdditive,parseSmilClockValue,parseSmilDuration,parseSmilFillField,parseSmilKeySplines,parseSmilKeyTimes,parseSmilRepeatSettings,parseSmilValues,parseSvgAbsoluteLength,parseSvgLength,parseSvgLengthList,parseSvgLengthToken,parseSvgPathData,parseSvgRootFrame,parseSvgSourceDocument,parseSvgStyleAttribute,parseSvgTransformList,parseSvgViewBox,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,partitionUnknownDocumentFields,pathCommandStructuresMatch,pathDataBounds,pattern,patternDefinitionEnvelope,patternLibraryDefToCustomPatternDef,patternTileSize,pickCssAnimationListItem,planClipMaskGroups,planSnapshotExternalEffects,planSvgAnimations,planSvgAuthoredAttributes,planSvgClipMasks,planSvgConditionalProcessing,planSvgContainerHierarchy,planSvgEmbeddedFrames,planSvgExternalEffects,planSvgFilters,planSvgGradients,planSvgImport,planSvgLeafGeometry,planSvgMarkers,planSvgMetadata,planSvgPaintServerDefinitions,planSvgPatterns,planSvgResourceDependencies,planSvgScripts,planSvgSourceIdentifiers,planSvgStyleCascade,planSvgSymbolUses,planSvgUseOccurrences,planSvgViews,planTransformFusion,planVariantTransitionsCss,planVariantTransitionsSmil,planVariantTransitionsWaapi,prepareSvgAuthorCssForLiveProjection,prepareSvgExternalAssetUrlForLiveProjection,prepareSvgMarkupForLiveProjection,prepareSvgXmlSource,preserveAspectRatioAlignFactor,projectCssTransformStops,projectPresentation,projectPresentationEntry,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,projectSvgAnimationPlan,projectSvgAnimationTimeline,projectSvgCustomProperties,projectSvgImportToIngestPlan,projectSvgImportToSnapshot,promoteManagedDescription,promoteRebasedShapeUpdateClock,pruneAndWrapSubtree,quadraticBezierExtent1D,radialGradient,radialGradientEnvelope,rebaseRichTextFormatRanges,rebaseRichTextRuns,reflectCubicBezier,registeredShapeGeometryTypes,removeResourceById,removeResourceByKey,removeResourceByName,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderDescriptiveElements,renderDocumentScripts,renderDocumentStyles,renderEllipse,renderFilterDefs,renderFilterElement,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderForeignObject,renderGradientDefs,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradient,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPaintServerDefs,renderPatternLibraryDef,renderPlanDefsBody,renderPolygonShape,renderPolyline,renderRadialGradient,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderResolvedSymbolLibraryDef,renderShape,renderShapeContextForLibrary,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderTemplateVariablesStyle,renderText,renderToSvg,renderToSvgWithDiagnostics,replaceClipMaskDefinition,replaceClipMaskGroupsInSceneTree,replaySceneTreePlacements,resolveContainerTransform,resolveContainerTransformFromContentBounds,resolveCssAnimationEasingType,resolveEmbeddedSvgTransform,resolveEmbeddedSvgViewportFrameBounds,resolveInlineContainerTransform,resolveMetadataQName,resolveRichTextStyleAt,resolveShapeGeometry,resolveShapeLocalObjectBounds,resolveShapeObjectBounds,resolveShapeReferenceTransform,resolveSvgGradientGeometry,resolveSvgLengthToken,resolveSvgPatternTile,resolveSvgViewport,resolveSymbolInstanceContent,resolveSymbolInstanceShapes,resolveSymbolInstanceTransform,resolveSymbolViewport,rewriteDocumentEmbeddedPayloads,rewriteIdReferencesInMarkup,rewriteShapeStateEmbeddedPayloads,rewriteSvgResourceReferenceValue,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rootMetadataAttrs,rootPaintServerDefId,rotateAffine,roundCoord,roundMarkupCoordinates,roundNumberString,roundSerializedShape,roundSnapshot,runsFromSegments,sanitizeRichTextFormatRanges,sanitizeXmlId,scaleAffine,scanCssFunctionTokens,scanCssLocalUrlTokens,senderCorrectionsForOp,serializeSvgPathData,serializedPresentationReader,shapeLocalObjectBounds,shapeLocalObjectCenter,shapeObjectBoundsInSpace,skewXAffine,skewYAffine,smilKeyframeAttributes,snapshotBoundsView,solveCubicBezier,solveSudoku,splinePathBounds,splitCssAnimationList,splitCssTopLevel,splitCssTopLevelRanges,splitTopLevelElements,stringifyDocument,stripAnimationDeclarations,substituteString,substituteVariables,symbolDefinitionSemanticHash,symbolInstanceTargetId,synthesizeCssAnimationShorthand,templateVariablesCss,transformSplice,transformSvgPathData,translateAffine,translateSvgPathData,tryParseSvgTransformList,upsertResourceById,upsertResourceByKey,upsertResourceByName,upsertTrackKeyframe,validateDocumentOperations,validateOperation,validatePresenceOperation,validateSnapshot,validateSudokuPuzzle,verticesToPath,visitShapeTree,visitSnapshotShapeTrees});