@svgsketch/core 2.3.0 → 2.4.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.mjs CHANGED
@@ -1,20 +1,83 @@
1
- var er=(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))(er||{}),tr={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 Pp(n){let e=tr[n];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var Rs=(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))(Rs||{}),bl=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(bl||{});function Ap(n){return n==="color"?"live":"stamped"}var As=["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"],ve=6;var Is=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],qt=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],Ms={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Fe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Jt=Fe.length,Ee=Fe[0],Cs=Fe[Jt-1],Fs=Fe[Math.floor(Jt/2)],nr=97,Sl=122;function ut(n){let e=Fe.indexOf(n);if(e===-1)throw new Error(`order-key: invalid digit '${n}'`);return e}function xl(n){let e=n.charCodeAt(0);if(e<nr||e>Sl)throw new Error(`order-key: invalid head '${n}'`);return e-nr+1}function Ve(n){if(n<1||n>26)throw new Error(`order-key: integer length ${n} out of range`);return String.fromCharCode(nr+n-1)}function Rt(n){let e=xl(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)ut(i);for(let i of r)ut(i);return{integer:t,fraction:r}}function Zt(n){for(let e of n)if(e!==Ee)return!1;return!0}function Qt(n){if(n.length===0)return!1;try{let{integer:e,fraction:t}=Rt(n);return!(t.endsWith(Ee)||Zt(e)&&t.length===0||e.length>1&&e[0]===Ee)}catch{return!1}}function Ds(n,e){if(!Qt(n))throw new Error(`order-key: invalid ${e} '${n}'`)}function en(n,e){return n<e?-1:n>e?1:0}function $l(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=ut(e[t]);if(r<Jt-1){e[t]=Fe[r+1];for(let i=t+1;i<e.length;i++)e[i]=Ee;return e.join("")}}return null}function rr(n){let{integer:e}=Rt(n),t=$l(e);if(t!==null)return Ve(e.length)+t;let r="1"+Ee.repeat(e.length);return Ve(r.length)+r}function vl(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=ut(e[t]);if(r>0){e[t]=Fe[r-1];for(let i=t+1;i<e.length;i++)e[i]=Cs;return e.join("")}e[t]=Cs}throw new Error(`order-key: cannot decrement zero integer '${n}'`)}function kl(n){let e=0;for(;e<n.length-1&&n[e]===Ee;)e++;return n.slice(e)}function Tl(n){let{integer:e,fraction:t}=Rt(n);if(!Zt(e)){let r=vl(e);if(!Zt(r)){let i=kl(r);return Ve(i.length)+i}return Ve(1)+Ee+Fs}return Ve(1)+Ee+At("",t)}function At(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]??Ee)===e[i];)i++;if(i>0)return e.slice(0,i)+At(n.slice(i),e.slice(i))}let t=n.length>0?ut(n[0]):0,r=e!==null?ut(e[0]):Jt;return r-t>1?Fe[Math.floor((t+r)/2)]:Fe[t]+At(n.slice(1),null)}function It(n,e){if(n!==null&&Ds(n,"lower bound"),e!==null&&Ds(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 Ve(1)+"1";if(n===null)return Tl(e);if(e===null)return rr(n);let t=Rt(n),r=Rt(e),i=Ve(t.integer.length)+t.integer,s=Ve(r.integer.length)+r.integer;if(i===s)return i+At(t.fraction,r.fraction);let o=rr(i+(Zt(t.integer)?Fs:""));return en(o,e)<0?o:i+At(t.fraction,null)}function ir(n,e,t){if(t<=0)return[];let r=[],i=n;for(let s=0;s<t;s++){let o=It(i,e);r.push(o),i=o}return r}function sr(n){if(n<=0)return[];let e=[],t=It(null,null);e.push(t);for(let r=1;r<n;r++)t=rr(t),e.push(t);return e}var tn=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),ct=n=>Math.max(0,Math.min(1,n)),ee=n=>Math.max(0,Math.min(100,n)),wl=n=>Math.max(1,n),Pl=n=>Math.max(3,Math.min(100,Math.floor(n))),_l=n=>Math.max(3,Math.min(50,Math.floor(n))),Rl=n=>Math.max(3,Math.min(30,Math.floor(n))),Al=n=>Math.max(1,Math.min(10,n));function Il(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{default:t}]))}var Ml=Il(Ms),te={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:ct},fillOpacity:{default:1,validate:ct},strokeOpacity:{default:1,validate:ct},...Ml,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:wl},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={...te,cx:{default:0},cy:{default:0},radius:{default:50,validate:E},cornerRadius:{default:0,validate:E},shiftAngle:{default:0}},dt={...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:60,validate:E}},Es={...te,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:ct},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:ct},fadeInDuration:{default:0,validate:E},fadeOutDuration:{default:0,validate:E},posterHref:{default:""},sourceRect:{default:null}},O=new tn;O.register("rectangle",{...te,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",{...te,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",{...te,x:{default:0},y:{default:0},radius:{default:50,validate:E}});O.register("ellipse",{...te,cx:{default:0},cy:{default:0},rx:{default:50,validate:E},ry:{default:30,validate:E}});O.register("line",{...te,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("text",{...te,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",{...te,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:ct}});O.register("path",{...te,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",{...te,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:Pl}});O.register("star",{...ke,arms:{default:5,validate:_l},innerRadiusPercent:{default:40,validate:ee}});O.register("cross",{...ke,armWidthPercent:{default:30,validate:ee}});O.register("ring",{...ke,innerRadiusPercent:{default:50,validate:ee}});O.register("spiral",{...ke,turns:{default:3,validate:Al},thicknessPercent:{default:15,validate:ee},spiralDirection:{default:1}});O.register("gear",{...ke,teeth:{default:8,validate:Rl},toothDepthPercent:{default:25,validate:ee},holeRadiusPercent:{default:20,validate:ee}});O.register("arrow",{...ke,headWidthPercent:{default:100,validate:ee},headLengthPercent:{default:40,validate:ee},shaftWidthPercent:{default:40,validate:ee}});O.register("symbol-instance",{...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},symbolId:{default:""}});O.register("group",{...te,groupId:{default:null}});O.register("cloud",{...ke,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:ee}});O.register("heart",{...ke,lobeRadiusPercent:{default:50,validate:ee},cleftDepthPercent:{default:25,validate:ee}});O.register("lightning",{...ke,boltSegments:{default:3},boltWidthPercent:{default:30,validate:ee},boltJaggednessPercent:{default:40,validate:ee}});O.register("speechBubble",{...ke,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:ee},tailWidthPercent:{default:25,validate:ee}});O.register("diamond",{...dt});O.register("parallelogram",{...dt,slantPercent:{default:20,validate:ee}});O.register("trapezoid",{...dt,topWidthPercent:{default:70,validate:ee}});O.register("terminator",{...dt});O.register("cylinder",{...dt,capHeightPercent:{default:15,validate:ee}});O.register("document-shape",{...dt,waveAmplitudePercent:{default:15,validate:ee}});O.register("hyperlink",{...te,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});O.register("switch",{...te,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});O.register("svg",{...te,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",{...te,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",{...te,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:E},targetHeight:{default:0,validate:E},broken:{default:!1}});O.register("video",{...Es,mediaKind:{default:"video"}});O.register("audio",{...Es,mediaKind:{default:"audio"}});O.register("document",{});function Cl(){let n=new Set(As);for(let e of Is)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 Os=Cl(),Dl=new Set(["scaleAnchor","displayAttr"]);function ar(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"||Os.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 ft(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)ft(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)&&ar(i);return ar(e),n}function nn(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)nn(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)&&Ue(i);return Ue(e),n}function Ue(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 pt(n,e,t,r="verbatim"){if(r==="verbatim")return new We(n,e,t&&"extra"in t?Ue({...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 We(n,e,i)}var We=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 pt(e.id,e.type,e.state,"verbatim")}static create(e,t,r){return pt(e,t,r,"authoring")}};var Fl=5e3,El=1e4;function Ol(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 or=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=pt("__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>El){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",Ol(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>Fl){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=We.fromSerialized(r);t.addNode(i)}return t}};var G=["updatedAt","clientId"];function z(n,e,t){n.push({path:e,message:t})}function Ys(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function U(n,e,t){return Ys(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 ae(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 ae(n,e,t,r)?Number.isInteger(n)?!0:(z(t,e,"must be an integer"),!1):!1}function mt(n,e,t){return typeof n!="boolean"?(z(t,e,"must be a boolean"),!1):!0}function J(n,e,t,r,i=!1){n[e]!==void 0&&A(n[e],`${t}.${e}`,r,i)}function lr(n,e,t,r,i){n[e]!==void 0&&ae(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 rn(n,e,t,r){n[e]!==void 0&&mt(n[e],`${t}.${e}`,r)}function qe(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 re(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(Ys(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){lr(n,"updatedAt",e,t,0),J(n,"clientId",e,t)}function sn(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 Mt(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"),re(s,`${e}.state`,t),s.children!==void 0&&X(s.children,`${e}.state.children`,t,(o,a,l)=>Mt(o,a,l,r+1)))}function Ll(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"),re(r,e,t),r.children!==void 0&&X(r.children,`${e}.children`,t,(i,s,o)=>Mt(i,s,o)))}function ur(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),J(r,"pluginId",e,t),J(r,"pluginData",e,t,!0),r.attributes!==void 0&&sn(r.attributes,`${e}.attributes`,t),re(r,e,t))}function Ls(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&&qe(r.clipShapeIds,`${e}.clipShapeIds`,t),r.clipShapeId!==void 0&&J(r,"clipShapeId",e,t),r.clipShapeIds===void 0&&r.clipShapeId===void 0&&z(t,`${e}.clipShapeIds`,"or clipShapeId is required"),qe(r.contentShapeIds,`${e}.contentShapeIds`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),re(r,e,t))}function Ns(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)'),ae(r.position,`${e}.position`,t),i&&ae(r.controlPointOffset,`${e}.controlPointOffset`,t),J(r,"color",e,t,!0),lr(r,"opacity",e,t),re(r,e,t)}function Bs(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&&(ae(c.x,`${a}.x`,l),ae(c.y,`${a}.y`,l))}),mt(r.visible,`${e}.visible`,t),we(r.snapDivisions,`${e}.snapDivisions`,t,1)):s||z(t,e,"must be a current or legacy measurement payload"),J(r,"color",e,t,!0),lr(r,"opacity",e,t),re(r,e,t)}var zs=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawDescription","rawHtmlMetadata","coordinatePrecision"];function Gs(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?zs:zs.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)&&qe(i.keywords,`${e}.keywords`,t),(!r||i.customMetadata!==void 0)&&sn(i.customMetadata,`${e}.customMetadata`,t),J(i,"rawMetadata",e,t,!0),J(i,"rawDescription",e,t,!0),J(i,"rawHtmlMetadata",e,t,!0),se(i,"coordinatePrecision",e,t)}function Vs(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),J(r,"svgId",e,t,!0),J(r,"href",e,t,!0),rn(r,"async",e,t),rn(r,"defer",e,t),r.customAttrs!==void 0&&sn(r.customAttrs,`${e}.customAttrs`,t),re(r,e,t))}function Us(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.css,`${e}.css`,t,!0),mt(r.preserved,`${e}.preserved`,t),J(r,"svgId",e,t,!0),J(r,"type",e,t,!0),J(r,"media",e,t,!0),r.customAttrs!==void 0&&sn(r.customAttrs,`${e}.customAttrs`,t),re(r,e,t))}function Ws(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),J(r,"label",e,t,!0),J(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"')}re(r,e,t)}}function Hs(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),re(r,e,t))}function Nl(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),J(r,"glyphName",e,t,!0),se(r,"advanceWidth",e,t),J(r,"sourceFamily",e,t,!0),se(r,"sourceGlyphId",e,t),J(r,"label",e,t,!0),re(r,e,t))}function js(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),ae(r.width,`${e}.width`,t,0),ae(r.height,`${e}.height`,t,0),re(r,e,t))}function Ks(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),rn(r,"passthrough",e,t),re(r,e,t))}function Xs(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,Mt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ur)),i==="symbol"&&A(r.viewBox,`${e}.viewBox`,t,!0),i==="marker"){for(let s of["refX","refY","markerWidth","markerHeight"])ae(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)}),re(r,e,t)}function Bl(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),J(r,"viewBox",e,t,!0),r.shapes!==void 0&&X(r.shapes,`${e}.shapes`,t,Mt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ur),re(r,e,t))}function qs(n,e,t,r){let i=U(n,e,t);i&&((r||i.id!==void 0)&&A(i.id,`${e}.id`,t),ae(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),re(i,e,t))}function Zs(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),mt(r.enabled,`${e}.enabled`,t),rn(r,"locked",e,t),X(r.keyframes,`${e}.keyframes`,t,(i,s,o)=>qs(i,s,o,!1)),re(r,e,t))}function zl(n,e,t){let r=U(n,e,t);r&&(ae(r.duration,`${e}.duration`,t,0),mt(r.loop,`${e}.loop`,t),ae(r.playbackSpeed,`${e}.playbackSpeed`,t,0),X(r.tracks,`${e}.tracks`,t,Zs))}function Gl(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"),re(r,e,t)}function Vl(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 Js={"shape:add":(n,e,t)=>{I(n,e,["shape"],[],t),Mt(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),Ll(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))ae(s,`${e}.propTimestamps.${i}`,t,0)}J(n,"clientId",e,t),n.textSplices!==void 0&&X(n.textSplices,`${e}.textSplices`,t,Vl),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,Gl),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),qe(n.ids,`${e}.ids`,t)},"groups:set":(n,e,t)=>{I(n,e,["groups"],[],t),X(n.groups,`${e}.groups`,t,ur)},"clipmasks:set":(n,e,t)=>{I(n,e,["clipMaskGroups"],[],t),X(n.clipMaskGroups,`${e}.clipMaskGroups`,t,Ls)},"clipMask:upsert":(n,e,t)=>{I(n,e,["clipMaskGroup"],["index",...G],t),Ls(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,Ns)},"guide:upsert":(n,e,t)=>{I(n,e,["guide"],["index",...G],t),Ns(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,Bs)},"measurement:upsert":(n,e,t)=>{I(n,e,["measurement"],["index",...G],t),Bs(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),Gs(n.metadata,`${e}.metadata`,t,!1)},"metadata:patch":(n,e,t)=>{I(n,e,["patch"],["removeKeys",...G],t),Gs(n.patch,`${e}.patch`,t,!0),n.removeKeys!==void 0&&qe(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,Vs)},"documentScript:upsert":(n,e,t)=>{I(n,e,["documentScript"],["index",...G],t),Vs(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,Us)},"documentStyle:upsert":(n,e,t)=>{I(n,e,["documentStyle"],["index",...G],t),Us(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,Ws),V(n,e,t)},"templateVariable:upsert":(n,e,t)=>{I(n,e,["templateVariable"],["index",...G],t),Ws(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,Hs),V(n,e,t)},"exportItem:upsert":(n,e,t)=>{I(n,e,["exportItem"],["index",...G],t),Hs(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,Nl),re(r,`${e}.colorGlyphLibrary`,t))}V(n,e,t)},"animation:set":(n,e,t)=>{I(n,e,["animationTimeline"],[],t),n.animationTimeline!==void 0&&zl(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),ae(r.duration,`${e}.config.duration`,t,0),mt(r.loop,`${e}.config.loop`,t),ae(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),Zs(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),qs(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,Bl)},"customPatterns:set":(n,e,t)=>{I(n,e,["customPatterns"],[],t),X(n.customPatterns,`${e}.customPatterns`,t,js)},"customPattern:upsert":(n,e,t)=>{I(n,e,["customPattern"],["index",...G],t),js(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,Xs)},"library:upsert":(n,e,t)=>{I(n,e,["def"],["index",...G],t),Xs(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),qe(n.rawPaintServerDefs,`${e}.rawPaintServerDefs`,t)},"paintServerDefs:set":(n,e,t)=>{I(n,e,["paintServerDefs"],[],t),X(n.paintServerDefs,`${e}.paintServerDefs`,t,Ks)},"paintServerDef:upsert":(n,e,t)=>{I(n,e,["paintServerDef"],["index",...G],t),Ks(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),ae(r.x,`${e}.position.x`,t),ae(r.y,`${e}.position.y`,t))},"presence:selection":(n,e,t)=>{I(n,e,["shapeIds"],[],t),qe(n.shapeIds,`${e}.shapeIds`,t)}},Ul=new Set(Object.keys(Js)),Qs=new Set(["presence:cursor","presence:selection"]);function cr(n,e="operation"){let t=[],r=U(n,e,t);return r?!A(r.type,`${e}.type`,t)||!Ul.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&z(t,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:t}):(Js[r.type](r,e,t),t.length===0?{valid:!0,value:r}:{valid:!1,issues:t}):{valid:!1,issues:t}}function Wl(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=cr(o,`ops[${a}]`);if(!l.valid){t.push(...l.issues);return}if(Qs.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 Hl(n){let e=cr(n,"op");return e.valid?Qs.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function jl(n){return n.slice(0,5).map(({path:e,message:t})=>`${e} ${t}`).join("; ")}function dr(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 fr(n,e,t){return(n??[]).filter(r=>r[e]!==t)}function ye(n,e,t){return dr(n,e,"id",t)}function be(n,e){return fr(n,"id",e)}function pr(n,e,t){return dr(n,e,"name",t)}function mr(n,e){return fr(n,"name",e)}function Kl(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 Xl(n,e){return n.slice(0,e.start)+e.insert+n.slice(e.start+e.deleteCount)}function an(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 on=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}),Ct=Object.keys(on);function Ne(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Oe(n){return typeof n=="string"?n:void 0}function oe(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 He(n){return e=>typeof e=="string"&&n.includes(e)?e:void 0}function Yl(n){return n==="normal"||n==="bold"?n:oe(n)}function ql(n){return n==="baseline"||n==="super"||n==="sub"?n:oe(n)}function ta(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(!Ne(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 na(n){if(!Ne(n))return;let e={};for(let[t,r]of Object.entries(n)){let i=oe(r);i!==void 0&&(e[t]=i)}return e}var ra={fontFamily:Oe,fontSize:oe,fontWeight:Yl,fontStyle:He(["normal","italic","oblique"]),fontVariant:Oe,fontVariantLigatures:Oe,fontVariantPosition:Oe,fontVariantCaps:Oe,fontVariantNumeric:Oe,fontVariantEastAsian:Oe,textTransform:He(["none","capitalize","uppercase","lowercase"]),baselineShift:ql,dominantBaseline:He(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:He(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:He(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:He(["ltr","rtl"]),unicodeBidi:He(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:He(["start","middle","end"]),letterSpacing:oe,wordSpacing:oe,lineHeight:oe,fill:Oe,fillOpacity:oe,stroke:Oe,strokeWidth:oe,strokeOpacity:oe};function hr(n,e){return{...n,...e,textDecoration:{...n.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??n.fontVariationSettings}}}function Sr(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 xr(n,e){for(let t of Ct)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(!Sr(n.fontVariationSettings,e.fontVariationSettings))return!1}else if(n[t]!==e[t])return!1;return!0}function $r(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(!Sr(n.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let s=i;if(n[s]!==e[s])return!1}return!0}function gr(n,e){let t={};for(let i of Ct)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),Sr(n.fontVariationSettings,e.fontVariationSettings)||(t.fontVariationSettings={...n.fontVariationSettings}),t}function Le(n,e=on){let t=Ne(n)?n:{},r={...e};for(let i of Ct){if(i==="textDecoration"||i==="fontVariationSettings")continue;let s=ra[i](t[i]);s!==void 0&&(r[i]=s)}return r.textDecoration={...e.textDecoration,...ta(t.textDecoration)??{}},r.fontVariationSettings={...na(t.fontVariationSettings)??e.fontVariationSettings},r}function ln(n){let e=Ne(n)?n:{},t={};for(let r of Ct){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=ra[r](e[r]);i!==void 0&&(t[r]=i)}if(e.textDecoration!==void 0){let r=ta(e.textDecoration);r&&Object.keys(r).length>0&&(t.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=na(e.fontVariationSettings);r&&(t.fontVariationSettings=r)}return t}function ia(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 Zl(n,e,t){return n.start===n.end?t&&n.start===e:n.start<=e&&e<n.end}function yr(n,e,t,r){let i=n;for(let s of e)Zl(s,t,r)&&(i=hr(i,s.style));return i===n?hr(n,{}):i}function Jl(n,e,t={}){let r=Le(n.baseStyle),i=typeof n.text=="string"?n.text:"";return yr(r,vr(n.runs,i.length),e,t.collapsed===!0)}function ht(n,e=on){let t=Ne(n)?n:{},r=Le(t.baseStyle,e),i=typeof t.text=="string"?t.text:"";return{text:i,runs:vr(t.runs,i.length),baseStyle:r,lineHeight:oe(t.lineHeight)??r.lineHeight}}function vr(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ne(r))continue;let i=oe(r.start),s=oe(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:ln(r.style)})}return t}function je(n){let e=typeof n.text=="string"?n.text:"",t=Le(n.baseStyle),r=vr(n.runs,e.length),i=oe(n.lineHeight)??t.lineHeight;return{lines:ia(e).map(o=>{if(o.text.length===0)return{segments:[{text:"",style:yr(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=yr(t,r,d,!1),h=c[c.length-1];h&&xr(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 gt(n){let e=Le(n?.baseStyle),t=oe(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=Le(h?.style,e),$=gr(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=Le(p[0]?.style,e),g=gr(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
- `)&&$r(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 kr(n){let e=n.richTextRuns;if(Ne(e))return ht(e);let t=n.richTextData;return Ne(t)&&Array.isArray(t.lines)&&t.lines.length>0?gt(t):null}function br(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 Ql(n,e){if(n.start===n.end||e.start>=e.end||n.start<e.start||n.end>e.end)return!1;let t=br(e.style);for(let r of br(n.style))if(!t.has(r))return!1;return!0}function un(n,e){let t=[...n];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(t=t.filter(i=>!Ql(i,r)),t.push({start:r.start,end:r.end,style:r.style}));return t}function Tr(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ne(r))continue;let i=oe(r.start),s=oe(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=ln(r.style);Object.keys(l).length!==0&&t.push({start:o,end:a,style:l})}return t}function eu(n,e){let t=[];for(let r of n){let i=an({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 ea(n,e){return n.start===e.start&&n.end===e.end&&$r(n.style,e.style)}function tu(n,e){if(n.text!==e.text||n.lineHeight!==e.lineHeight||!xr(Le(n.baseStyle),Le(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(ea(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=un(t,o);if(a.length!==r.length)return null;for(let l=0;l<a.length;l++)if(!ea(a[l],r[l]))return null;return o.map(l=>({start:l.start,end:l.end,style:ln(l.style)}))}function nu(n,e){let t=e===0||n.charAt(e-1)===`
5
- `,r=e===n.length||n.charAt(e)===`
6
- `;return t&&r}function ru(n,e,t){let r=[];for(let i of n){let s=i.start===i.end,o=an({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=o.start,l=o.start+o.deleteCount;a===l&&(!s||!nu(t,a))||r.push({start:a,end:l,style:i.style})}return r}function Ke(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 cn(n){if(n.builtIn)return!1;let e=n.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function sa(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 Dt(n){if(!cn(n))return null;let{width:e,height:t}=sa(n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:e,height:t}}function Ae(n){let e=[...n].sort((i,s)=>i.index-s.index);if(!e.some(i=>i.orderKey))return e;let t=sr(e.length),r=new Map;return e.forEach((i,s)=>{r.set(i.id,i.orderKey??t[s])}),e.sort((i,s)=>{let o=en(r.get(i.id)??"",r.get(s.id)??"");return o!==0?o:i.id<s.id?-1:i.id>s.id?1:0})}var iu=/^structural:(clip|mask):(.+):(group|path|content)$/;function aa(n,e){let t=`structural:${n}:${e}`;return{group:`${t}:group`,path:`${t}:path`,content:`${t}:content`}}function oa(n,e){for(let t of n){e.add(t.id);let r=t.state.children;Array.isArray(r)&&oa(r,e)}}function la(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(...la(s,r.id))}),t}function dn(n){let e=n.sceneTree&&n.sceneTree.length>0?n.sceneTree:la(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,Ae(x));let i=S=>iu.test(S),s=new Set(e.filter(S=>!i(S.id)).map(S=>S.id)),o=new Set;oa(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=>[aa(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=aa(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 Se(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function wr(n){return Se(n)&&typeof n.updatedAt=="number"&&Number.isSafeInteger(n.updatedAt)&&n.updatedAt>=0&&typeof n.clientId=="string"}function Ze(n,e){return{updatedAt:typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:0,clientId:e??""}}function Ft(n,e){return wr(e)?n.updatedAt>e.updatedAt||n.updatedAt===e.updatedAt&&n.clientId>=e.clientId:!0}function ua(n){return Se(n.collaborationState)||(n.collaborationState={}),n.collaborationState}function ca(n,e){let t=ua(n);Se(t.shapeProps)||(t.shapeProps={});let r=t.shapeProps;return Se(r[e])||(r[e]={}),r[e]}function Et(n,e){let t=n.collaborationState?.shapeProps;if(!Se(t))return{};let r=t[e];return Se(r)?r:{}}function da(n,e,t,r){if(t.length===0)return;let i=ca(n,e);for(let s of t)Ft(r,i[s])&&(i[s]=r)}function Pr(n,e){let t=n.collaborationState?.shapeProps;if(Se(t)){for(let r of e)delete t[r];su(n)}}function su(n){let e=n.collaborationState;if(Se(e)){for(let t of["shapeProps","resources"]){let r=e[t];Se(r)&&Object.keys(r).length===0&&delete e[t]}Object.keys(e).length===0&&delete n.collaborationState}}function fa(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 pa(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){if(!t)return null;let a=Et(n,e.id),l={},c={},f=[];for(let[p,m]of Object.entries(e.state)){let h=Ze(e.propTimestamps[p],e.clientId);Ft(h,a[p])&&(l[p]=m,c[p]=h.updatedAt,f.push([p,h]))}if(f.length===0)return null;let d=ca(n,e.id);for(let[p,m]of f)d[p]=m;return{...e,state:l,propTimestamps:c}}let r=fa(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=Ze(e.updatedAt,e.clientId),s=ua(n);Se(s.resources)||(s.resources={});let o=s.resources;return Ft(i,o[r])?(o[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function au(n){let e=0,t=n.collaborationState?.shapeProps;if(Se(t)){for(let i of Object.values(t))if(Se(i))for(let s of Object.values(i))wr(s)&&(e=Math.max(e,s.updatedAt))}let r=n.collaborationState?.resources;if(Se(r))for(let i of Object.values(r))wr(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 ou(n,e){let t=Object.keys(e.state);if(t.length===0)return;let r=Et(n,e.id),i=0;for(let o of t){let a=Ze(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 Je(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=>Dt(e)).filter(e=>e!==null))}function Sa(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(...Sa(s,r.id))}),t}function pe(n,e){if(n===e)return!0;let t=n??ma,r=e??ma;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 ma=[];function Ot(n){return n.sceneTree&&n.sceneTree.length>0?n.sceneTree:Sa(n.shapes)}function lu(n,e){let t=n,r=new Set(n.map(o=>o.id)),i=(o,a,l)=>{r.has(o.id)||(t=Rr(t,{id:o.id,parentId:a,index:l}),r.add(o.id)),yt(o)?.forEach((f,d)=>i(f,o.id,d))},s=t.filter(o=>o.parentId===null).length;return i(e,null,s),t}function xa(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())Ae(r).forEach((i,s)=>t.push({...i,index:s}));return t}function pn(n,e){let t=n.filter(l=>l.parentId===e);if(t.every(l=>l.orderKey))return n;let r=Ae(t),i=new Map,s=[],o=null,a=l=>{if(s.length===0)return;let c=ir(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 Rr(n,e){let t,r=[],i=[],s=!1;for(let l of n){if(l.id===e.id){if(t=l,!Ir(e,t))return n;continue}l.parentId===e.parentId?(r.push(l),l.orderKey&&(s=!0)):i.push(l)}if(s){let l=pn([...i,...r],e.parentId),c=Ae(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:It(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 Ar(n,e,t){let r=n?[...n]:[],i=r.find(s=>s.id===e);return i?ye(r,i,t):r}function uu(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 $a(n,e){let t=n.keyframes.findIndex(r=>r.id===e.id);t>=0?n.keyframes[t]=e:n.keyframes.push(e),uu(n)}function va(n,e){n.keyframes=n.keyframes.filter(t=>t.id!==e)}function ha(n,e){let t=n.animationTimeline?.tracks;return Array.isArray(t)?t.find(r=>r.id===e)??null:null}function Ir(n,e){let t=n.updatedAt??0,r=e.updatedAt??0;return t!==r?t>r:(n.clientId??"")>=(e.clientId??"")}function yt(n){let e=n.state.children;return Array.isArray(e)?e:void 0}var _r=new Set(["group","hyperlink","switch","container","svg"]);function ka(n,e,t,r){for(let i of n){t.set(i.id,e),r.set(i.id,i);let s=yt(i);s&&ka(s,i.id,t,r)}}function Ta(n){let e=n.sceneTree;if(!e||e.length===0)return;let t=new Map,r=new Map;if(ka(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 Ae(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),_r.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&&_r.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(!_r.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 cu(n){let e=`structural:${n.type}:${n.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Lt(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=>Ae(i.get(o)??[]).map(a=>a.id).filter(a=>!a.startsWith("structural:"));n.clipMaskGroups=e.map(o=>{let a=cu(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(ga(l,o.clipShapeIds)&&ga(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 ga(n,e){return!e||n.length!==e.length?!1:n.every((t,r)=>t===e[r])}function Cr(n,e){e.add(n.id);let t=yt(n);if(t)for(let r of t)Cr(r,e)}function Mr(n,e){for(let t of n){e.set(t.id,t);let r=yt(t);r&&Mr(r,e)}}var fn=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,Mr(this.snapshot.shapes,this.shapeIndex)),t=this.shapeIndex.get(e)??null):t=bt(this.snapshot.shapes,e),this.memoId=e,this.memoShape=t,t}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&Mr([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=xa(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,Ta(this.snapshot))}};function bt(n,e){for(let t of n){if(t.id===e)return t;let r=yt(t);if(!r)continue;let i=bt(r,e);if(i)return i}return null}function Qe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function du(n){let e=n.richTextRuns;return!Qe(e)||typeof e.text!="string"?null:ht(e)}function fu(n,e){let t=n.state;"extra"in t&&Ue(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 wa(n,e,t){let r=[];for(let i of n){if(i.id===e){Cr(i,t);continue}let s=yt(i);if(s){let o=wa(s,e,t),a=i.state;o.length>0?a.children=o:delete a.children}r.push(i)}return r}function Pa(n,e){let t=n.snapshot,r=t,i=pa(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=Ot(r),c=nn(structuredClone(s.shape));r.shapes.push(c),r.sceneTree=lu(l,c),n.noteShapesAdded(c),n.requestSceneTreeNormalize(),n.requestInlineProjection();let f=new Set;Cr(c,f),Pr(t,f)}break}case"shape:update":{let a=n.findShape(s.id);if(!a)return null;fu(a,s.state);break}case"text:format":{let a=n.findShape(s.id);if(!a)return null;let l=a.state;"extra"in l&&Ue(l);let c=du(l);if(!c)return null;let f=Tr(s.ranges,c.text.length);if(f.length===0)return null;let d={...c,runs:un(c.runs,f)};l.richTextRuns=d;let p=["richTextRuns"];if(Qe(l.richTextData)&&(l.richTextData=je(d),p.push("richTextData")),s.updatedAt!==void 0){let m=Ze(s.updatedAt,s.clientId),h=Et(t,s.id);if(p.some(b=>!Ft(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}}da(t,s.id,p,m)}break}case"shape:remove":{let a=new Set,l=wa(r.shapes,s.id,a),c=a.size>0;c||a.add(s.id);let f=Ot(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(),Pr(t,a),Lt(r);break}case"scene:move":{let a=Ot(r),l=a.find(d=>d.id===s.id),c=s.updatedAt===void 0?void 0:Ze(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:s.index,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!Ir(f,l))return null;r.sceneTree=Rr(a,f),n.requestSceneTreeNormalize(),c&&(o={...s,...c}),n.requestInlineProjection(),Lt(r);break}case"scene:place":{if(!Qt(s.orderKey))return null;let a=Ot(r),l=a.find(p=>p.id===s.id),c=s.updatedAt===void 0?void 0:Ze(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&&!Ir(f,l))return null;let d=pn(a,s.parentId);r.sceneTree=[...d.filter(p=>p.id!==s.id),f],n.requestSceneTreeNormalize(),n.requestInlineProjection(),Lt(r),c&&(o={...s,...c});break}case"shapes:reorder":{let a=Ot(r);s.ids.forEach((l,c)=>{a.some(f=>f.id===l&&f.parentId===null)&&(a=Rr(a,{id:l,parentId:null,index:c}))}),r.sceneTree=a,n.requestSceneTreeNormalize(),n.requestInlineProjection(),Lt(r);break}case"groups:set":r.groups=s.groups;break;case"clipmasks:set":r.clipMaskGroups=s.clipMaskGroups,dn(r);break;case"clipMask:upsert":r.clipMaskGroups=ye(r.clipMaskGroups,s.clipMaskGroup,s.index),dn(r);break;case"clipMask:remove":{let a=be(r.clipMaskGroups,s.id);if(pe(r.clipMaskGroups,a))return null;r.clipMaskGroups=a,dn(r);break}case"guides:set":r.guides=s.guides;break;case"guide:upsert":r.guides=ye(r.guides,s.guide,s.index);break;case"guide:remove":{let a=be(r.guides,s.id);if(pe(r.guides,a))return null;r.guides=a;break}case"guide:move":{let a=Ar(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=ye(r.measurements,s.measurement,s.index);break;case"measurement:remove":{let a=be(r.measurements,s.id);if(pe(r.measurements,a))return null;r.measurements=a;break}case"measurement:move":{let a=Ar(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=ye(r.documentScripts,s.documentScript,s.index);break;case"documentScript:remove":{let a=be(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=ye(r.documentStyles,s.documentStyle,s.index);break;case"documentStyle:remove":{let a=be(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=pr(r.templateVariables,s.templateVariable,s.index);break;case"templateVariable:remove":{let a=mr(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=ye(r.exportItems,s.exportItem,s.index);break;case"exportItem:remove":{let a=be(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:ye(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=be(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=ha(r,s.trackId);if(!a)return null;$a(a,structuredClone(s.keyframe));break}case"animationKeyframe:remove":{let a=ha(r,s.trackId);if(!a)return null;let l=a.keyframes;if(va(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],Je(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"||!cn(c)));r.library=[...l,...s.customPatterns.map(c=>Ke(c))]}Je(r);break;case"customPattern:upsert":{r.customPatterns=ye(r.customPatterns,s.customPattern,s.index);let a=Ke(s.customPattern),l=[...r.library??[]],c=l.findIndex(f=>f.id===a.id);c>=0?l[c]=a:l.push(a),r.library=l,Je(r);break}case"customPattern:remove":{let a=be(r.customPatterns,s.id),l=be(r.library,s.id);if(pe(r.customPatterns,a)&&pe(r.library,l))return null;r.customPatterns=a,r.library=l,Je(r);break}case"library:set":r.library=s.library,Je(r);break;case"library:upsert":r.library=ye(r.library,s.def,s.index),Je(r);break;case"library:remove":{let a=be(r.library,s.id);if(pe(r.library,a))return null;r.library=a,Je(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=ye(r.paintServerDefs,s.paintServerDef,s.index),r.rawPaintServerDefs=r.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:remove":{let a=be(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 pu(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 ya(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=bt(n.shapes,e.id)?.state,s=i&&Qe(_a(i,"richTextData"))?["richTextRuns","richTextData"]:["richTextRuns"];return ya(n,e.id,s)}return[]}function _a(n,e){if(e in n)return n[e];let t=n.extra;return Qe(t)?t[e]:void 0}function mu(n,e){if(e in n)return!0;let t=n.extra;return Qe(t)&&e in t}function ya(n,e,t){if(t.length===0)return[];let r=bt(n.shapes,e);if(!r)return[];let i=r.state,s=Et(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]=mu(i,p)?structuredClone(_a(i,p)):null,d[p]=s[p].updatedAt;a.push({type:"shape:update",id:e,state:f,propTimestamps:d,clientId:l})}return a}function hu(n,e){let t=new fn(n,!1),r=Pa(t,e);return t.settle(),r}function Ra(n,e){let t=new fn(n,e.length>1),r=[];for(let i of e){let s=Pa(t,i);s&&r.push(s)}return t.settle(),r}function Aa(n,e){let t=structuredClone(n);return{snapshot:t,acceptedOps:Ra(t,e)}}function gu(n,e){return Aa(n,e).snapshot}function yu(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=pn(e,t);return xa(e)}function bu(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 Su(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 xu(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=bt(e,r.id);if(!i)continue;let s=i.state.richTextRuns;if(!Qe(s))continue;let o={richTextRuns:structuredClone(s)},a=i.state.richTextData;Qe(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 $u(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 vu=6,ba=new Set(["templateVariables:set","templateVariable:upsert","templateVariable:remove","exportItems:set","exportItem:upsert","exportItem:remove","colorGlyphLibrary:set"]);function ku(n){return n.some(e=>ba.has(e.type))?n.filter(e=>!ba.has(e.type)):n}var hn=Object.freeze([1,0,0,1,0,0]);function Xe(n,e,t,r,i,s){return[n,e,t,r,i,s]}function Dr(n){return Xe(n[0]??1,n[1]??0,n[2]??0,n[3]??1,n[4]??0,n[5]??0)}function et(n){return[n[0],n[1],n[2],n[3],n[4],n[5]]}function Bt(n){return Array.isArray(n)&&n.length>=6&&n.slice(0,6).every(Number.isFinite)}function Fa(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 Nm(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 ie(n,e){return Xe(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 Bm(n){let e=n[0]*n[3]-n[2]*n[1];if(Math.abs(e)<1e-10)return null;let t=1/e;return Xe(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 zm(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 Gm(n,e){return{x:n[0]*e.x+n[2]*e.y,y:n[1]*e.x+n[3]*e.y}}function Ie(n,e=0){return Xe(1,0,0,1,n,e)}function gn(n,e=n){return Xe(n,0,0,e,0,0)}function zt(n){let e=n*Math.PI/180,t=Math.cos(e),r=Math.sin(e);return Xe(t,r,-r,t,0,0)}function yn(n){return Xe(1,0,Math.tan(n*Math.PI/180),1,0,0)}function bn(n){return Xe(1,Math.tan(n*Math.PI/180),0,1,0,0)}function Ea(n,e){return ie(ie(Ie(n.x,n.y),e),Ie(-n.x,-n.y))}var Tu=9,wu=10,Pu=12,_u=13,Ru=32,Ia=43,Au=44,Ma=45,Iu=46,Mu=48,Cu=57,Du=40,Fu=41,Eu=69,Ou=101,Lu=0,Nu=1,Oa=2,Bu=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function zu(n){return n===Ru||n===Tu||n===wu||n===_u||n===Pu}function mn(n){return n>=Mu&&n<=Cu}function Gu(n){let e=n>=65&&n<=90,t=n>=97&&n<=122;return e||t||mn(n)}function St(n){for(;n.pos<n.src.length&&zu(n.src.charCodeAt(n.pos));)n.pos++}function La(n){let e=n.pos;return St(n),n.src.charCodeAt(n.pos)===Au?(n.pos++,St(n),Oa):n.pos>e?Nu:Lu}function Ca(n){let e=n.src,t=n.pos,r=t,i=e.charCodeAt(r);(i===Ia||i===Ma)&&r++;let s=!1;for(;r<e.length&&mn(e.charCodeAt(r));)r++,s=!0;if(e.charCodeAt(r)===Iu){let l=r+1;for(;l<e.length&&mn(e.charCodeAt(l));)l++;l>r+1&&(r=l,s=!0)}if(!s)return null;let o=e.charCodeAt(r);if(o===Ou||o===Eu){let l=r+1,c=e.charCodeAt(l);(c===Ia||c===Ma)&&l++;let f=l;for(;f<e.length&&mn(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 Vu(n,e){switch(n){case"matrix":return Dr(e);case"translate":return Ie(e[0],e[1]??0);case"scale":return gn(e[0],e[1]??e[0]);case"rotate":return e.length===3?Ea({x:e[1],y:e[2]},zt(e[0])):zt(e[0]);case"skewX":return yn(e[0]);case"skewY":return bn(e[0]);default:return null}}function Uu(n){let e=n.src,t=n.pos;for(;n.pos<e.length&&Gu(e.charCodeAt(n.pos));)n.pos++;if(n.pos===t)return null;let r=e.slice(t,n.pos),i=Bu.get(r);if(!i||(St(n),e.charCodeAt(n.pos)!==Du))return null;n.pos++,St(n);let s=i[i.length-1],o=Ca(n);if(o===null)return null;let a=[o];for(;;){let l=n.pos;La(n);let c=Ca(n);if(c===null){n.pos=l;break}if(a.push(c),a.length>s)return null}return St(n),e.charCodeAt(n.pos)!==Fu||(n.pos++,!i.includes(a.length))?null:Vu(r,a)}function Wu(n){let e={src:n,pos:0};if(St(e),e.pos>=n.length)return hn;let t=hn;for(;;){let r=Uu(e);if(r===null)return null;t=ie(t,r);let i=La(e);if(e.pos>=n.length)return i===Oa?null:t}}var Hu=2048,Nt=new Map;function ju(n){if(!n)return hn;let e=Nt.get(n);if(e!==void 0)return e;let t=Wu(n),r=t===null?null:Object.freeze(t);if(Nt.size>=Hu){let i=Nt.keys().next().value;i!==void 0&&Nt.delete(i)}return Nt.set(n,r),r}function Fr(n){return ju(n)??hn}function Vm(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 Da(n){return!Bt(n)||Fa(n)?null:`matrix(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]})`}function Sn(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=Ie(t,r);if(i)return ie(f,Fr(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=ie(ie(ie(zt(s),gn(l,c)),yn(o)),bn(a));return ie(f,Ea(d,p))}function Gt(n,e){let t=Da(n.transformMatrix);return t||(Da(et(Sn(n,e)))??null)}function Na(n,e){let t=n.ancestorTransform;if(!Bt(t)){delete n.ancestorTransform;return}if(Fa(t)){delete n.ancestorTransform;return}let r=Bt(n.transformMatrix)?Dr(n.transformMatrix):Sn(n,e);n.transformMatrix=et(ie(Dr(t),r)),delete n.ancestorTransform}function Ba(n,e,t){let r=Gt(n,{x:e,y:t});return r?`${r} translate(${e}, ${t})`:`translate(${e}, ${t})`}function Va(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 Vt(n){if(Array.isArray(n))for(let e of n){let t=e.state;Na(t,Va(t));let r=e.state.children;Vt(r)}}function Ku(n){Vt(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){Vt(e.shapes);for(let t of Object.values(e.variants??{}))Vt(t)}else e.kind==="marker"&&Vt(e.shapes);return n.schemaVersion=3,n}function Er(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 Xu(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=Ie(t,r);if(i)return et(ie(s,Fr(i)));let o=n.rotation??0,a=n.skewX??0,l=n.skewY??0;if(o!==0||a!==0||l!==0){let d=Er(n.customPivot)??e??Er(n.scaleAnchor);d&&(s=ie(s,Ie(d.x,d.y)),o!==0&&(s=ie(s,zt(o))),a!==0&&(s=ie(s,yn(a))),l!==0&&(s=ie(s,bn(l))),s=ie(s,Ie(-d.x,-d.y)))}let c=n.scaleX??1,f=n.scaleY??1;if(c!==1||f!==1){let d=Er(n.scaleAnchor)??e;d&&(s=ie(s,Ie(d.x,d.y)),s=ie(s,gn(c,f)),s=ie(s,Ie(-d.x,-d.y)))}return et(s)}function Ut(n){if(Array.isArray(n))for(let e of n){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!Bt(t.transformMatrix)&&(t.transformMatrix=Xu(t,Va(t))),delete t.scaleAnchor);let r=e.state.children;Ut(r)}}function Yu(n){Ut(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){Ut(e.shapes);for(let t of Object.values(e.variants??{}))Ut(t)}else e.kind==="marker"&&Ut(e.shapes);return n.schemaVersion=4,n}function qu(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-${xn()}`: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:za(l)}:{kind:"radial-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:za(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-${xn()}`:l.id;t.add(c),s.set(l.id,c),e.push(Ke(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-${xn()}`: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-${xn()}`: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 za(n){let{id:e,sourceId:t,...r}=n;return r}var Or=0;function xn(){return Or=Or+1&65535,`${Date.now().toString(36)}-${Or.toString(36)}`}function Zu(n){let e=t=>{if(Array.isArray(t))for(let r of t)ft(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 Ga(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=gt(t))}function Ua(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)Ua(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))Ga(i);Ga(e)}function Ju(n){let e=t=>{if(Array.isArray(t))for(let r of t)Ua(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 Wa=Object.freeze({1:qu,2:Ku,3:Yu,4:Zu,5:Ju});function Qu(n){let e=n.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function Lr(n,e=Wa){let t=JSON.parse(JSON.stringify(n)),r=Qu(t);if(r>ve)return t;if(r===ve)return t.schemaVersion=ve,t;for(;r<ve;){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 ${ve}.`);t=i(t),r+=1}return t.schemaVersion=ve,t}function tt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}async function Br(n,e,t,r){let i=n[e];typeof i=="string"&&(n[e]=await r(i,t))}async function Nr(n,e){tt(n)&&await Br(n,"svgContent","svgMarkup",e)}async function zr(n,e){if(!tt(n))return;await Br(n,"href","href",e),await Nr(n.fillGradient,e),await Nr(n.strokeGradient,e);let t=n.children;if(Array.isArray(t))for(let r of t)tt(r)&&await zr(r.state,e)}async function ec(n,e){if(!tt(n))return;let t=n.shapes;if(Array.isArray(t))for(let s of t)tt(s)&&await zr(s.state,e);let r=n.library;if(Array.isArray(r))for(let s of r)tt(s)&&s.kind==="pattern"&&await Nr(s.pattern,e);let i=n.customPatterns;if(Array.isArray(i))for(let s of i)tt(s)&&await Br(s,"svgContent","svgMarkup",e)}var tc=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function $n(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>ve&&t.push({path:"schemaVersion",message:`schemaVersion ${r.schemaVersion} is newer than supported (${ve})`,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)=>{ac(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)=>{uc(s,`viewboxes[${o}]`,e,t,i)})}if(r.guides!==void 0&&(Array.isArray(r.guides)?r.guides.forEach((i,s)=>{cc(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)=>{dc(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)=>{rc(o,`sceneTree[${a}]`,e,t,i,s)})}if(r.clipMaskGroups!==void 0&&(Array.isArray(r.clipMaskGroups)?r.clipMaskGroups.forEach((i,s)=>{fc(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)=>{sc(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 Ha(n){return n.startsWith("structural:")}function rc(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)&&!Ha(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)&&!Ha(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 ic=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function sc(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"||!ic.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 ac(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"}):tc.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"}):lc(s.state,`${e}.state`,t,r)}var oc=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function ja(n){return typeof n=="number"?isFinite(n):typeof n=="string"?oc.test(n):!1}function lc(n,e,t,r){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)n[o]!==void 0&&!ja(n[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of qt){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}ja(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 uc(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 cc(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 dc(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 fc(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 Gr(n={}){let e={schemaVersion:ve,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 pc(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 vn(n,e,t,r,i){return{id:i??_(),x:n,y:e,width:t,height:r}}var mc=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function Vr(n,e={}){let{indent:t=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=$n(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 mc){let l=n[a];if(l!==void 0)switch(a){case"shapes":s[a]=l.map(c=>gc(ft(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:hc(l).map(nt);break;case"documentMetadata":s[a]=nt(l);break;case"animationTimeline":s[a]=nt(l);break;case"colorGlyphLibrary":s[a]=nt(l);break;default:s[a]=l}}let o=JSON.stringify(s,null,t);return r?o+`
9
- `:o}function Ur(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=Lr(s)),t){let o=$n(s);if(!o.valid){let a=o.errors.map(l=>` ${l.path}: ${l.message}`).join(`
1
+ var Gn=(O=>(O.LINEAR="linear",O.EASE="ease",O.EASE_IN="ease-in",O.EASE_OUT="ease-out",O.EASE_IN_OUT="ease-in-out",O.EASE_IN_QUAD="ease-in-quad",O.EASE_OUT_QUAD="ease-out-quad",O.EASE_IN_OUT_QUAD="ease-in-out-quad",O.EASE_IN_CUBIC="ease-in-cubic",O.EASE_OUT_CUBIC="ease-out-cubic",O.EASE_IN_OUT_CUBIC="ease-in-out-cubic",O.EASE_IN_QUART="ease-in-quart",O.EASE_OUT_QUART="ease-out-quart",O.EASE_IN_OUT_QUART="ease-in-out-quart",O.EASE_IN_SINE="ease-in-sine",O.EASE_OUT_SINE="ease-out-sine",O.EASE_IN_OUT_SINE="ease-in-out-sine",O.EASE_IN_QUINT="ease-in-quint",O.EASE_OUT_QUINT="ease-out-quint",O.EASE_IN_OUT_QUINT="ease-in-out-quint",O.EASE_IN_EXPO="ease-in-expo",O.EASE_OUT_EXPO="ease-out-expo",O.EASE_IN_OUT_EXPO="ease-in-out-expo",O.EASE_IN_CIRC="ease-in-circ",O.EASE_OUT_CIRC="ease-out-circ",O.EASE_IN_OUT_CIRC="ease-in-out-circ",O.EASE_IN_BACK="ease-in-back",O.EASE_OUT_BACK="ease-out-back",O.EASE_IN_OUT_BACK="ease-in-out-back",O.CUSTOM_BEZIER="custom-bezier",O.LINEAR_FUNCTION="linear-function",O.STEPS="steps",O))(Gn||{}),ei={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 TD(t){let e=ei[t];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var hm=(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))(hm||{}),Mx=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(Mx||{});function $D(t){return t==="color"?"live":"stamped"}var ym=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform","ancestorTransform","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","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","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","isHomeView","children","viewLinkedSvgId"],Ct=8;var Sm=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],hs=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],bm={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Rn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ss=Rn.length,Tn=Rn[0],vm=Rn[Ss-1],Im=Rn[Math.floor(Ss/2)],tc=97,Ox=122;function ti(t){let e=Rn.indexOf(t);if(e===-1)throw new Error(`order-key: invalid digit '${t}'`);return e}function Dx(t){let e=t.charCodeAt(0);if(e<tc||e>Ox)throw new Error(`order-key: invalid head '${t}'`);return e-tc+1}function Vn(t){if(t<1||t>26)throw new Error(`order-key: integer length ${t} out of range`);return String.fromCharCode(tc+t-1)}function io(t){let e=Dx(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)ti(i);for(let i of r)ti(i);return{integer:n,fraction:r}}function ys(t){for(let e of t)if(e!==Tn)return!1;return!0}function bs(t){if(t.length===0)return!1;try{let{integer:e,fraction:n}=io(t);return!(n.endsWith(Tn)||ys(e)&&n.length===0||e.length>1&&e[0]===Tn)}catch{return!1}}function xm(t,e){if(!bs(t))throw new Error(`order-key: invalid ${e} '${t}'`)}function vs(t,e){return t<e?-1:t>e?1:0}function zx(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=ti(e[n]);if(r<Ss-1){e[n]=Rn[r+1];for(let i=n+1;i<e.length;i++)e[i]=Tn;return e.join("")}}return null}function nc(t){let{integer:e}=io(t),n=zx(e);if(n!==null)return Vn(e.length)+n;let r="1"+Tn.repeat(e.length);return Vn(r.length)+r}function _x(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=ti(e[n]);if(r>0){e[n]=Rn[r-1];for(let i=n+1;i<e.length;i++)e[i]=vm;return e.join("")}e[n]=vm}throw new Error(`order-key: cannot decrement zero integer '${t}'`)}function Fx(t){let e=0;for(;e<t.length-1&&t[e]===Tn;)e++;return t.slice(e)}function Lx(t){let{integer:e,fraction:n}=io(t);if(!ys(e)){let r=_x(e);if(!ys(r)){let i=Fx(r);return Vn(i.length)+i}return Vn(1)+Tn+Im}return Vn(1)+Tn+oo("",n)}function oo(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]??Tn)===e[i];)i++;if(i>0)return e.slice(0,i)+oo(t.slice(i),e.slice(i))}let n=t.length>0?ti(t[0]):0,r=e!==null?ti(e[0]):Ss;return r-n>1?Rn[Math.floor((n+r)/2)]:Rn[n]+oo(t.slice(1),null)}function so(t,e){if(t!==null&&xm(t,"lower bound"),e!==null&&xm(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 Vn(1)+"1";if(t===null)return Lx(e);if(e===null)return nc(t);let n=io(t),r=io(e),i=Vn(n.integer.length)+n.integer,o=Vn(r.integer.length)+r.integer;if(i===o)return i+oo(n.fraction,r.fraction);let s=nc(i+(ys(n.integer)?Im:""));return vs(s,e)<0?s:i+oo(n.fraction,null)}function rc(t,e,n){if(n<=0)return[];let r=[],i=t;for(let o=0;o<n;o++){let s=so(i,e);r.push(s),i=s}return r}function ic(t){if(t<=0)return[];let e=[],n=so(null,null);e.push(n);for(let r=1;r<t;r++)n=nc(n),e.push(n);return e}var xs=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}},le=t=>Math.max(0,t),ni=t=>Math.max(0,Math.min(1,t)),He=t=>Math.max(0,Math.min(100,t)),Bx=t=>Math.max(1,t),Gx=t=>Math.max(3,Math.min(100,Math.floor(t))),Vx=t=>Math.max(3,Math.min(50,Math.floor(t))),jx=t=>Math.max(3,Math.min(30,Math.floor(t))),Ux=t=>Math.max(1,Math.min(10,t));function Hx(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,{default:n}]))}var Wx=Hx(bm),Ge={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:ni},fillOpacity:{default:1,validate:ni},strokeOpacity:{default:1,validate:ni},...Wx,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:Bx},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}},jt={...Ge,cx:{default:0},cy:{default:0},radius:{default:50,validate:le},cornerRadius:{default:0,validate:le},shiftAngle:{default:0}},ri={...Ge,x:{default:0},y:{default:0},width:{default:100,validate:le},height:{default:60,validate:le}},wm={...Ge,x:{default:0},y:{default:0},width:{default:0,validate:le},height:{default:0,validate:le},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:ni},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:ni},fadeInDuration:{default:0,validate:le},fadeOutDuration:{default:0,validate:le},posterHref:{default:""},sourceRect:{default:null}},se=new xs;se.register("rectangle",{...Ge,x:{default:0},y:{default:0},width:{default:100,validate:le},height:{default:100,validate:le},rx:{default:0,validate:le},ry:{default:0,validate:le},cornerRadius:{default:0,validate:le},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:le},cornerRadiusTR:{default:0,validate:le},cornerRadiusBL:{default:0,validate:le},cornerRadiusBR:{default:0,validate:le},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});se.register("square",{...Ge,x:{default:0},y:{default:0},size:{default:100,validate:le},width:{default:100,validate:le},height:{default:100,validate:le},rx:{default:0,validate:le},ry:{default:0,validate:le},cornerRadius:{default:0,validate:le},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:le},cornerRadiusTR:{default:0,validate:le},cornerRadiusBL:{default:0,validate:le},cornerRadiusBR:{default:0,validate:le},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});se.register("circle",{...Ge,x:{default:0},y:{default:0},radius:{default:50,validate:le}});se.register("ellipse",{...Ge,cx:{default:0},cy:{default:0},rx:{default:50,validate:le},ry:{default:30,validate:le}});se.register("line",{...Ge,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});se.register("text",{...Ge,x:{default:0},y:{default:0},width:{default:0,validate:le},height:{default:0,validate:le},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}});se.register("image",{...Ge,x:{default:0},y:{default:0},width:{default:100,validate:le},height:{default:100,validate:le},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:ni}});se.register("path",{...Ge,x:{default:0},y:{default:0},width:{default:0,validate:le},height:{default:0,validate:le},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});se.register("polyline",{...Ge,x:{default:0},y:{default:0},width:{default:0,validate:le},height:{default:0,validate:le},polylinePoints:{default:[]},polylineClosed:{default:!1}});se.register("triangle",{...jt,sides:{default:3}});se.register("ngon",{...jt,sides:{default:6,validate:Gx}});se.register("star",{...jt,arms:{default:5,validate:Vx},innerRadiusPercent:{default:40,validate:He}});se.register("cross",{...jt,armWidthPercent:{default:30,validate:He}});se.register("ring",{...jt,innerRadiusPercent:{default:50,validate:He}});se.register("spiral",{...jt,turns:{default:3,validate:Ux},thicknessPercent:{default:15,validate:He},spiralDirection:{default:1}});se.register("gear",{...jt,teeth:{default:8,validate:jx},toothDepthPercent:{default:25,validate:He},holeRadiusPercent:{default:20,validate:He}});se.register("arrow",{...jt,headWidthPercent:{default:100,validate:He},headLengthPercent:{default:40,validate:He},shaftWidthPercent:{default:40,validate:He}});se.register("symbol-instance",{...Ge,x:{default:0},y:{default:0},width:{default:100,validate:le},height:{default:100,validate:le},symbolId:{default:""}});se.register("group",{...Ge,groupId:{default:null}});se.register("container",{...Ge,groupId:{default:null}});se.register("cloud",{...jt,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:He}});se.register("heart",{...jt,lobeRadiusPercent:{default:50,validate:He},cleftDepthPercent:{default:25,validate:He}});se.register("lightning",{...jt,boltSegments:{default:3},boltWidthPercent:{default:30,validate:He},boltJaggednessPercent:{default:40,validate:He}});se.register("speechBubble",{...jt,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:He},tailWidthPercent:{default:25,validate:He}});se.register("diamond",{...ri});se.register("parallelogram",{...ri,slantPercent:{default:20,validate:He}});se.register("trapezoid",{...ri,topWidthPercent:{default:70,validate:He}});se.register("terminator",{...ri});se.register("cylinder",{...ri,capHeightPercent:{default:15,validate:He}});se.register("document-shape",{...ri,waveAmplitudePercent:{default:15,validate:He}});se.register("hyperlink",{...Ge,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});se.register("switch",{...Ge,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});se.register("svg",{...Ge});se.register("view",{...Ge,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:le},viewBoxHeight:{default:0,validate:le},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});se.register("shape-reference",{...Ge,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:le},targetHeight:{default:0,validate:le},broken:{default:!1}});se.register("foreign-object",{...Ge,x:{default:0},y:{default:0},width:{default:0,validate:le},height:{default:0,validate:le},rawContent:{default:""}});se.register("video",{...wm,mediaKind:{default:"video"}});se.register("audio",{...wm,mediaKind:{default:"audio"}});se.register("document",{});function Pn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function tn(t,e,n=""){if(!Pn(t))return;e.onShape?.(t,n);let r=t.state;if(!Pn(r))return;let i=r.children;if(Array.isArray(i)&&i.forEach((o,s)=>{tn(o,e,`${n}.state.children[${s}]`)}),e.onState){let o=r.symbolOverrides;if(Pn(o))for(let[s,a]of Object.entries(o))Pn(a)&&e.onState(a,`${n}.state.symbolOverrides[${s}]`);e.onState(r,`${n}.state`)}}function ii(t,e,n){Array.isArray(t)&&t.forEach((r,i)=>tn(r,e,`${n}[${i}]`))}function Nt(t,e,n={}){if(Pn(t)&&(ii(t.shapes,e,"shapes"),Array.isArray(t.library)&&t.library.forEach((r,i)=>{if(Pn(r))if(r.kind==="symbol"){if(ii(r.shapes,e,`library[${i}].shapes`),Pn(r.variants))for(let[o,s]of Object.entries(r.variants))ii(s,e,`library[${i}].variants[${o}]`)}else r.kind==="marker"&&ii(r.shapes,e,`library[${i}].shapes`)}),n.includeDeprecatedSymbols)){let r=t.symbols;Array.isArray(r)&&r.forEach((i,o)=>{if(Pn(i)&&(ii(i.shapes,e,`symbols[${o}].shapes`),Pn(i.variants)))for(let[s,a]of Object.entries(i.variants))ii(a,e,`symbols[${o}].variants[${s}]`)})}}function Kx(){let t=new Set(ym);for(let e of Sm)t.add(e);for(let e of se.typeIds())for(let n of Object.keys(se.getDefaults(e)))t.add(n);return t.delete("scaleAnchor"),t.delete("extra"),t}var km=Kx(),Xx=new Set(["scaleAnchor","displayAttr"]);function Is(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"||km.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 oc(t){return tn(t,{onState:e=>{Is(e)}}),t}function sc(t){return tn(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 oi(t,e,n,r="verbatim"){if(r==="verbatim")return new Ut(t,e,n&&"extra"in n?hr({...n}):n);let i={...se.getDefaults(e),...n},o=se.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 Ut(t,e,i)}var Ut=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}setPropIfWins(e,n,r,i){let o=this._propTimestamps.get(e),s=o?.ts??0,a=o?.clientId??"";return r>s||r===s&&i>a?(this._preservedSerializedState=null,n===null?delete this._props[e]:this._props[e]=n,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)}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 oi(e.id,e.type,structuredClone(e.state),"verbatim")}static create(e,n,r){return oi(e,n,r,"authoring")}};var Yx=5e3,qx=1e4;function Zx(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=oi("__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>qx){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",Zx(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>Yx){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=Ut.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=Ut.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 he=["updatedAt","clientId"];function ae(t,e,n){t.push({path:e,message:n})}function _m(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function fe(t,e,n){return _m(t)?t:(ae(n,e,"must be an object"),null)}function Q(t,e,n,r=[],i,o=!0){let s=new Set([...o?["type"]:[],...n,...r]);for(let a of n)Object.hasOwn(t,a)||ae(i,`${e}.${a}`,"is required");for(let a of Object.keys(t))s.has(a)||ae(i,`${e}.${a}`,"is not allowed")}function j(t,e,n,r=!1){return typeof t!="string"||!r&&t.length===0?(ae(n,e,r?"must be a string":"must be a non-empty string"),!1):!0}function et(t,e,n,r){return typeof t!="number"||!Number.isFinite(t)?(ae(n,e,"must be a finite number"),!1):r!==void 0&&t<r?(ae(n,e,`must be at least ${r}`),!1):!0}function nn(t,e,n,r=0){return et(t,e,n,r)?Number.isInteger(t)?!0:(ae(n,e,"must be an integer"),!1):!1}function si(t,e,n){return typeof t!="boolean"?(ae(n,e,"must be a boolean"),!1):!0}function Me(t,e,n,r,i=!1){t[e]!==void 0&&j(t[e],`${n}.${e}`,r,i)}function Sr(t,e,n,r,i){t[e]!==void 0&&et(t[e],`${n}.${e}`,r,i)}function Qe(t,e,n,r,i=0){t[e]!==void 0&&nn(t[e],`${n}.${e}`,r,i)}function ao(t,e,n,r){t[e]!==void 0&&si(t[e],`${n}.${e}`,r)}function Cn(t,e,n){return Array.isArray(t)?(t.forEach((r,i)=>j(r,`${e}[${i}]`,n)),!0):(ae(n,e,"must be an array"),!1)}function $e(t,e,n,r){return Array.isArray(t)?(t.forEach((i,o)=>r(i,`${e}[${o}]`,n)),!0):(ae(n,e,"must be an array"),!1)}function We(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){ae(n,e,"exceeds the 250000-node validation limit");return}if(o.depth>64){ae(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)||ae(n,o.path,"must be a finite JSON number");continue}if(Array.isArray(s)){s.forEach((a,l)=>r.push({value:a,path:`${o.path}[${l}]`,depth:o.depth+1}));continue}if(_m(s)){for(let[a,l]of Object.entries(s))r.push({value:l,path:`${o.path}.${a}`,depth:o.depth+1});continue}ae(n,o.path,"must be JSON-serializable")}}}function ye(t,e,n){Sr(t,"updatedAt",e,n,0),Me(t,"clientId",e,n)}function ws(t,e,n){let r=fe(t,e,n);if(r)for(let[i,o]of Object.entries(r))j(o,`${e}.${i}`,n,!0)}function lo(t,e,n,r=0){if(r>64){ae(n,e,"exceeds the 64-level shape nesting limit");return}let i=fe(t,e,n);if(!i)return;Q(i,e,["id","type","state"],[],n),j(i.id,`${e}.id`,n),j(i.type,`${e}.type`,n);let o=fe(i.state,`${e}.state`,n);o&&(Object.hasOwn(o,"extra")&&ae(n,`${e}.state.extra`,"is an at-rest field and is not allowed in operations"),We(o,`${e}.state`,n),o.children!==void 0&&$e(o.children,`${e}.state.children`,n,(s,a,l)=>lo(s,a,l,r+1)))}function Jx(t,e,n){let r=fe(t,e,n);r&&(Object.hasOwn(r,"extra")&&ae(n,`${e}.extra`,"is an at-rest field and is not allowed in operations"),We(r,e,n),r.children!==void 0&&$e(r.children,`${e}.children`,n,(i,o,s)=>lo(i,o,s)))}function ac(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),r.parentId!==null&&j(r.parentId,`${e}.parentId`,n),Qe(r,"siblingIndex",e,n),Me(r,"pluginId",e,n),Me(r,"pluginData",e,n,!0),r.attributes!==void 0&&ws(r.attributes,`${e}.attributes`,n),We(r,e,n))}function Rm(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),r.type!=="clip"&&r.type!=="mask"&&ae(n,`${e}.type`,'must be "clip" or "mask"'),r.clipShapeIds!==void 0&&Cn(r.clipShapeIds,`${e}.clipShapeIds`,n),r.clipShapeId!==void 0&&Me(r,"clipShapeId",e,n),r.clipShapeIds===void 0&&r.clipShapeId===void 0&&ae(n,`${e}.clipShapeIds`,"or clipShapeId is required"),Cn(r.contentShapeIds,`${e}.contentShapeIds`,n),r.parentId!==null&&j(r.parentId,`${e}.parentId`,n),Qe(r,"siblingIndex",e,n),We(r,e,n))}function Tm(t,e,n){let r=fe(t,e,n);if(!r)return;j(r.id,`${e}.id`,n);let i=r.orientation==="horizontal"||r.orientation==="vertical",o=r.axis==="x"||r.axis==="y";!i&&!o&&ae(n,`${e}.orientation`,'must be "horizontal" or "vertical" (legacy axis "x" or "y" is also accepted)'),et(r.position,`${e}.position`,n),i&&et(r.controlPointOffset,`${e}.controlPointOffset`,n),Me(r,"color",e,n,!0),Sr(r,"opacity",e,n),We(r,e,n)}function Pm(t,e,n){let r=fe(t,e,n);if(!r)return;j(r.id,`${e}.id`,n);let i=r.type==="distance"||r.type==="angle",o=["startX","startY","endX","endY"].every(s=>typeof r[s]=="number"&&Number.isFinite(r[s]));i?($e(r.points,`${e}.points`,n,(s,a,l)=>{let c=fe(s,a,l);c&&(et(c.x,`${a}.x`,l),et(c.y,`${a}.y`,l))}),si(r.visible,`${e}.visible`,n),nn(r.snapDivisions,`${e}.snapDivisions`,n,1)):o||ae(n,e,"must be a current or legacy measurement payload"),Me(r,"color",e,n,!0),Sr(r,"opacity",e,n),We(r,e,n)}var Cm=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawMetadataAuthoritative","rawDescription","rawHtmlMetadata","descriptiveElements","coordinatePrecision"];function $m(t,e,n,r){let i=fe(t,e,n);if(!i)return;Q(i,e,r?[]:["title","description","author","keywords","license","licenseUrl","language","customMetadata"],r?Cm:Cm.slice(8),n,!1);for(let s of["title","description","author","license","licenseUrl","language"])(!r||i[s]!==void 0)&&j(i[s],`${e}.${s}`,n,!0);(!r||i.keywords!==void 0)&&Cn(i.keywords,`${e}.keywords`,n),(!r||i.customMetadata!==void 0)&&ws(i.customMetadata,`${e}.customMetadata`,n),Me(i,"rawMetadata",e,n,!0),ao(i,"rawMetadataAuthoritative",e,n),Me(i,"rawDescription",e,n,!0),Me(i,"rawHtmlMetadata",e,n,!0),i.descriptiveElements!==void 0&&$e(i.descriptiveElements,`${e}.descriptiveElements`,n,(s,a,l)=>{let c=fe(s,a,l);c&&(Q(c,a,["kind","language","text","rawXml"],[],l,!1),c.kind!=="title"&&c.kind!=="desc"&&ae(l,`${a}.kind`,'must be "title" or "desc"'),c.language!==null&&j(c.language,`${a}.language`,l,!0),j(c.text,`${a}.text`,l,!0),j(c.rawXml,`${a}.rawXml`,l,!0))}),Qe(i,"coordinatePrecision",e,n)}function Em(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),r.source!=="inline"&&r.source!=="external"&&ae(n,`${e}.source`,'must be "inline" or "external"'),j(r.content,`${e}.content`,n,!0),j(r.type,`${e}.type`,n,!0),Me(r,"svgId",e,n,!0),Me(r,"href",e,n,!0),ao(r,"async",e,n),ao(r,"defer",e,n),r.customAttrs!==void 0&&ws(r.customAttrs,`${e}.customAttrs`,n),We(r,e,n))}function Am(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),j(r.css,`${e}.css`,n,!0),si(r.preserved,`${e}.preserved`,n),Me(r,"svgId",e,n,!0),Me(r,"type",e,n,!0),Me(r,"media",e,n,!0),r.customAttrs!==void 0&&ws(r.customAttrs,`${e}.customAttrs`,n),We(r,e,n))}function Nm(t,e,n){let r=fe(t,e,n);if(r){if(j(r.name,`${e}.name`,n),["string","color","number"].includes(String(r.type))||ae(n,`${e}.type`,'must be "string", "color", or "number"'),j(r.defaultValue,`${e}.defaultValue`,n,!0),Me(r,"label",e,n,!0),Me(r,"description",e,n,!0),r.mode!==void 0&&r.mode!=="live"&&r.mode!=="stamped"&&ae(n,`${e}.mode`,'must be "live" or "stamped"'),r.source!==void 0){let i=fe(r.source,`${e}.source`,n);i&&i.kind!=="user"&&ae(n,`${e}.source.kind`,'must be "user"')}We(r,e,n)}}function Mm(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),j(r.filename,`${e}.filename`,n,!0),j(r.format,`${e}.format`,n),We(r,e,n))}function Qx(t,e,n){let r=fe(t,e,n);r&&(nn(r.glyphId,`${e}.glyphId`,n),Array.isArray(r.codepoints)?r.codepoints.forEach((i,o)=>nn(i,`${e}.codepoints[${o}]`,n)):ae(n,`${e}.codepoints`,"must be an array"),j(r.svgDocument,`${e}.svgDocument`,n,!0),Me(r,"glyphName",e,n,!0),Qe(r,"advanceWidth",e,n),Me(r,"sourceFamily",e,n,!0),Qe(r,"sourceGlyphId",e,n),Me(r,"label",e,n,!0),We(r,e,n))}function Om(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),j(r.name,`${e}.name`,n,!0),j(r.svgContent,`${e}.svgContent`,n,!0),et(r.width,`${e}.width`,n,0),et(r.height,`${e}.height`,n,0),We(r,e,n))}function Dm(t,e,n){let r=fe(t,e,n);if(!r)return;j(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"&&ae(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))&&ae(n,`${e}.type`,"is not a supported paint-server type"),j(r.markup,`${e}.markup`,n),r.definitionChildIds!==void 0&&Cn(r.definitionChildIds,`${e}.definitionChildIds`,n),r.sourceDefinitionChildIds!==void 0&&Cn(r.sourceDefinitionChildIds,`${e}.sourceDefinitionChildIds`,n),Array.isArray(r.definitionChildIds)&&Array.isArray(r.sourceDefinitionChildIds)&&r.definitionChildIds.length!==r.sourceDefinitionChildIds.length&&ae(n,e,"definition child id arrays must have equal lengths"),ao(r,"passthrough",e,n),We(r,e,n)}function zm(t,e,n){let r=fe(t,e,n);if(!r)return;j(r.id,`${e}.id`,n),j(r.name,`${e}.name`,n,!0),r.metadata!==void 0&&We(r.metadata,`${e}.metadata`,n);let i=r.kind;if(["symbol","marker","linear-gradient","radial-gradient","pattern","filter"].includes(String(i))||ae(n,`${e}.kind`,"is not a supported library kind"),(i==="symbol"||i==="marker")&&($e(r.shapes,`${e}.shapes`,n,lo),i==="marker"&&r.groups!==void 0&&$e(r.groups,`${e}.groups`,n,ac)),i==="symbol"){for(let o of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])Me(r,o,e,n,!0);if(r.rootAttributes!==void 0){let o=fe(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)&&ae(n,`${e}.rootAttributes.${s}`,"must use its typed symbol field"),j(a,`${e}.rootAttributes.${s}`,n,!0)}for(let o of["wrapperAttrs","groups","overflow"])r[o]!==void 0&&ae(n,`${e}.${o}`,"is schema-v7 migration input only")}if(i==="marker"){Me(r,"viewBox",e,n,!0),Me(r,"preserveAspectRatio",e,n,!0);for(let o of["refX","refY","markerWidth","markerHeight"])et(r[o],`${e}.${o}`,n);if(r.markerUnits!=="strokeWidth"&&r.markerUnits!=="userSpaceOnUse"&&ae(n,`${e}.markerUnits`,'must be "strokeWidth" or "userSpaceOnUse"'),r.orient!=="auto"&&r.orient!=="auto-start-reverse"&&!(typeof r.orient=="number"&&Number.isFinite(r.orient))&&ae(n,`${e}.orient`,"must be an orientation keyword or finite number"),r.authoredGeometry!==void 0){let o=fe(r.authoredGeometry,`${e}.authoredGeometry`,n);if(o)for(let s of["refX","refY","markerWidth","markerHeight","markerUnits","orient"])Me(o,s,`${e}.authoredGeometry`,n,!0)}if(r.rootAttributes!==void 0){let o=fe(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)&&ae(n,`${e}.rootAttributes.${s}`,"must use its typed marker field"),j(a,`${e}.rootAttributes.${s}`,n,!0)}}if(i==="linear-gradient"||i==="radial-gradient"){let o=`${e}.gradient`,s=fe(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 l of a)Sr(s,l,o,n);if(Sr(s,"fr",o,n),s.authoredGeometry!==void 0){let l=`${o}.authoredGeometry`,c=fe(s.authoredGeometry,l,n);if(c){let u=new Set(i==="linear-gradient"?["x1","y1","x2","y2","gradientTransform"]:["cx","cy","fx","fy","r","fr","gradientTransform"]);for(let[d,p]of Object.entries(c))u.has(d)?j(p,`${l}.${d}`,n,!0):ae(n,`${l}.${d}`,"is not allowed")}}if(s.gradientTransform!==void 0){let l=s.gradientTransform;(!Array.isArray(l)||l.length!==6||!l.every(c=>typeof c=="number"&&Number.isFinite(c)))&&ae(n,`${o}.gradientTransform`,"must be a 6-element finite affine matrix")}$e(s.stops,`${o}.stops`,n,(l,c,u)=>{let d=fe(l,c,u);d&&(et(d.offset,`${c}.offset`,u),j(d.color,`${c}.color`,u,!0),Sr(d,"opacity",c,u))})}}if(i==="pattern"){let o=`${e}.pattern`,s=fe(r.pattern,o,n);if(s){for(let a of["x","y","width","height","scale","rotation","opacity"])Sr(s,a,o,n);s.patternUnits!==void 0&&s.patternUnits!=="userSpaceOnUse"&&s.patternUnits!=="objectBoundingBox"&&ae(n,`${o}.patternUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"'),s.patternContentUnits!==void 0&&s.patternContentUnits!=="userSpaceOnUse"&&s.patternContentUnits!=="objectBoundingBox"&&ae(n,`${o}.patternContentUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"');for(let a of["svgContent","patternTransform","viewBox","preserveAspectRatio"])Me(s,a,o,n,!0);if(s.authoredGeometry!==void 0){let a=`${o}.authoredGeometry`,l=fe(s.authoredGeometry,a,n);if(l)for(let[c,u]of Object.entries(l))["x","y","width","height"].includes(c)?j(u,`${a}.${c}`,n,!0):ae(n,`${a}.${c}`,"is not a supported authored pattern field")}}}i==="filter"&&$e(r.filters,`${e}.filters`,n,(o,s,a)=>{fe(o,s,a)}),We(r,e,n)}function eI(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),Me(r,"viewBox",e,n,!0),r.shapes!==void 0&&$e(r.shapes,`${e}.shapes`,n,lo),r.groups!==void 0&&$e(r.groups,`${e}.groups`,n,ac),We(r,e,n))}function Fm(t,e,n,r){let i=fe(t,e,n);i&&((r||i.id!==void 0)&&j(i.id,`${e}.id`,n),et(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)))&&ae(n,`${e}.value`,"must be a string, finite number, or finite number array"),j(i.easing,`${e}.easing`,n),We(i,e,n))}function Lm(t,e,n){let r=fe(t,e,n);r&&(j(r.id,`${e}.id`,n),j(r.shapeId,`${e}.shapeId`,n),j(r.property,`${e}.property`,n),si(r.enabled,`${e}.enabled`,n),ao(r,"locked",e,n),$e(r.keyframes,`${e}.keyframes`,n,(i,o,s)=>Fm(i,o,s,!1)),We(r,e,n))}function tI(t,e,n){let r=fe(t,e,n);r&&(et(r.duration,`${e}.duration`,n,0),si(r.loop,`${e}.loop`,n),et(r.playbackSpeed,`${e}.playbackSpeed`,n,0),$e(r.tracks,`${e}.tracks`,n,Lm))}function nI(t,e,n){let r=fe(t,e,n);if(!r)return;nn(r.start,`${e}.start`,n),nn(r.end,`${e}.end`,n),typeof r.start=="number"&&typeof r.end=="number"&&r.end<=r.start&&ae(n,`${e}.end`,"must be greater than start");let i=fe(r.style,`${e}.style`,n);i&&Object.keys(i).length===0&&ae(n,`${e}.style`,"must not be empty"),We(r,e,n)}function rI(t,e,n){let r=fe(t,e,n);r&&(Q(r,e,["start","deleteCount","insert"],[],n,!1),nn(r.start,`${e}.start`,n),nn(r.deleteCount,`${e}.deleteCount`,n),j(r.insert,`${e}.insert`,n,!0))}var Bm={"shape:add":(t,e,n)=>{Q(t,e,["shape"],[],n),lo(t.shape,`${e}.shape`,n)},"shape:update":(t,e,n)=>{if(Q(t,e,["id","state"],["propTimestamps","clientId","textSplices","baseSeq"],n),j(t.id,`${e}.id`,n),Jx(t.state,`${e}.state`,n),t.propTimestamps!==void 0){let r=fe(t.propTimestamps,`${e}.propTimestamps`,n);if(r)for(let[i,o]of Object.entries(r))et(o,`${e}.propTimestamps.${i}`,n,0)}Me(t,"clientId",e,n),t.textSplices!==void 0&&$e(t.textSplices,`${e}.textSplices`,n,rI),Qe(t,"baseSeq",e,n)},"shape:remove":(t,e,n)=>{Q(t,e,["id"],[],n),j(t.id,`${e}.id`,n)},"text:format":(t,e,n)=>{Q(t,e,["id","ranges"],["baseSeq",...he],n),j(t.id,`${e}.id`,n),$e(t.ranges,`${e}.ranges`,n,nI),Qe(t,"baseSeq",e,n),ye(t,e,n)},"scene:move":(t,e,n)=>{Q(t,e,["id","parentId","index"],he,n),j(t.id,`${e}.id`,n),t.parentId!==null&&j(t.parentId,`${e}.parentId`,n),nn(t.index,`${e}.index`,n),ye(t,e,n)},"scene:place":(t,e,n)=>{Q(t,e,["id","parentId","orderKey"],he,n),j(t.id,`${e}.id`,n),t.parentId!==null&&j(t.parentId,`${e}.parentId`,n),j(t.orderKey,`${e}.orderKey`,n),ye(t,e,n)},"shapes:reorder":(t,e,n)=>{Q(t,e,["ids"],[],n),Cn(t.ids,`${e}.ids`,n)},"groups:set":(t,e,n)=>{Q(t,e,["groups"],[],n),$e(t.groups,`${e}.groups`,n,ac)},"clipmasks:set":(t,e,n)=>{Q(t,e,["clipMaskGroups"],[],n),$e(t.clipMaskGroups,`${e}.clipMaskGroups`,n,Rm)},"clipMask:upsert":(t,e,n)=>{Q(t,e,["clipMaskGroup"],["index",...he],n),Rm(t.clipMaskGroup,`${e}.clipMaskGroup`,n),Qe(t,"index",e,n),ye(t,e,n)},"clipMask:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"guides:set":(t,e,n)=>{Q(t,e,["guides"],[],n),$e(t.guides,`${e}.guides`,n,Tm)},"guide:upsert":(t,e,n)=>{Q(t,e,["guide"],["index",...he],n),Tm(t.guide,`${e}.guide`,n),Qe(t,"index",e,n),ye(t,e,n)},"guide:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"guide:move":(t,e,n)=>{Q(t,e,["id","index"],he,n),j(t.id,`${e}.id`,n),nn(t.index,`${e}.index`,n),ye(t,e,n)},"measurements:set":(t,e,n)=>{Q(t,e,["measurements"],[],n),$e(t.measurements,`${e}.measurements`,n,Pm)},"measurement:upsert":(t,e,n)=>{Q(t,e,["measurement"],["index",...he],n),Pm(t.measurement,`${e}.measurement`,n),Qe(t,"index",e,n),ye(t,e,n)},"measurement:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"measurement:move":(t,e,n)=>{Q(t,e,["id","index"],he,n),j(t.id,`${e}.id`,n),nn(t.index,`${e}.index`,n),ye(t,e,n)},"metadata:set":(t,e,n)=>{Q(t,e,["metadata"],[],n),$m(t.metadata,`${e}.metadata`,n,!1)},"metadata:patch":(t,e,n)=>{Q(t,e,["patch"],["removeKeys",...he],n),$m(t.patch,`${e}.patch`,n,!0),t.removeKeys!==void 0&&Cn(t.removeKeys,`${e}.removeKeys`,n),ye(t,e,n)},"documentScripts:set":(t,e,n)=>{Q(t,e,["documentScripts"],[],n),$e(t.documentScripts,`${e}.documentScripts`,n,Em)},"documentScript:upsert":(t,e,n)=>{Q(t,e,["documentScript"],["index",...he],n),Em(t.documentScript,`${e}.documentScript`,n),Qe(t,"index",e,n),ye(t,e,n)},"documentScript:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"documentStyles:set":(t,e,n)=>{Q(t,e,["documentStyles"],[],n),$e(t.documentStyles,`${e}.documentStyles`,n,Am)},"documentStyle:upsert":(t,e,n)=>{Q(t,e,["documentStyle"],["index",...he],n),Am(t.documentStyle,`${e}.documentStyle`,n),Qe(t,"index",e,n),ye(t,e,n)},"documentStyle:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"templateVariables:set":(t,e,n)=>{Q(t,e,["templateVariables"],he,n),$e(t.templateVariables,`${e}.templateVariables`,n,Nm),ye(t,e,n)},"templateVariable:upsert":(t,e,n)=>{Q(t,e,["templateVariable"],["index",...he],n),Nm(t.templateVariable,`${e}.templateVariable`,n),Qe(t,"index",e,n),ye(t,e,n)},"templateVariable:remove":(t,e,n)=>{Q(t,e,["name"],he,n),j(t.name,`${e}.name`,n),ye(t,e,n)},"exportItems:set":(t,e,n)=>{Q(t,e,["exportItems"],he,n),$e(t.exportItems,`${e}.exportItems`,n,Mm),ye(t,e,n)},"exportItem:upsert":(t,e,n)=>{Q(t,e,["exportItem"],["index",...he],n),Mm(t.exportItem,`${e}.exportItem`,n),Qe(t,"index",e,n),ye(t,e,n)},"exportItem:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"colorGlyphLibrary:set":(t,e,n)=>{if(Q(t,e,["colorGlyphLibrary"],he,n),t.colorGlyphLibrary!==null){let r=fe(t.colorGlyphLibrary,`${e}.colorGlyphLibrary`,n);r&&(r.version!==1&&ae(n,`${e}.colorGlyphLibrary.version`,"must be 1"),$e(r.entries,`${e}.colorGlyphLibrary.entries`,n,Qx),We(r,`${e}.colorGlyphLibrary`,n))}ye(t,e,n)},"animation:set":(t,e,n)=>{Q(t,e,["animationTimeline"],[],n),t.animationTimeline!==void 0&&tI(t.animationTimeline,`${e}.animationTimeline`,n)},"animation:config":(t,e,n)=>{Q(t,e,["config"],he,n);let r=fe(t.config,`${e}.config`,n);r&&(Q(r,`${e}.config`,["duration","loop","playbackSpeed"],[],n,!1),et(r.duration,`${e}.config.duration`,n,0),si(r.loop,`${e}.config.loop`,n),et(r.playbackSpeed,`${e}.config.playbackSpeed`,n,0)),ye(t,e,n)},"animation:clear":(t,e,n)=>{Q(t,e,[],he,n),ye(t,e,n)},"animationTrack:upsert":(t,e,n)=>{Q(t,e,["track"],["index",...he],n),Lm(t.track,`${e}.track`,n),Qe(t,"index",e,n),ye(t,e,n)},"animationTrack:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"animationKeyframe:upsert":(t,e,n)=>{Q(t,e,["trackId","keyframe"],he,n),j(t.trackId,`${e}.trackId`,n),Fm(t.keyframe,`${e}.keyframe`,n,!0),ye(t,e,n)},"animationKeyframe:remove":(t,e,n)=>{Q(t,e,["trackId","keyframeId"],he,n),j(t.trackId,`${e}.trackId`,n),j(t.keyframeId,`${e}.keyframeId`,n),ye(t,e,n)},"symbols:set":(t,e,n)=>{Q(t,e,["symbols"],[],n),$e(t.symbols,`${e}.symbols`,n,eI)},"customPatterns:set":(t,e,n)=>{Q(t,e,["customPatterns"],[],n),$e(t.customPatterns,`${e}.customPatterns`,n,Om)},"customPattern:upsert":(t,e,n)=>{Q(t,e,["customPattern"],["index",...he],n),Om(t.customPattern,`${e}.customPattern`,n),Qe(t,"index",e,n),ye(t,e,n)},"customPattern:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"library:set":(t,e,n)=>{Q(t,e,["library"],[],n),$e(t.library,`${e}.library`,n,zm)},"library:upsert":(t,e,n)=>{Q(t,e,["def"],["index",...he],n),zm(t.def,`${e}.def`,n),Qe(t,"index",e,n),ye(t,e,n)},"library:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"rawPaintServerDefs:set":(t,e,n)=>{Q(t,e,["rawPaintServerDefs"],[],n),Cn(t.rawPaintServerDefs,`${e}.rawPaintServerDefs`,n)},"paintServerDefs:set":(t,e,n)=>{Q(t,e,["paintServerDefs"],[],n),$e(t.paintServerDefs,`${e}.paintServerDefs`,n,Dm)},"paintServerDef:upsert":(t,e,n)=>{Q(t,e,["paintServerDef"],["index",...he],n),Dm(t.paintServerDef,`${e}.paintServerDef`,n),Qe(t,"index",e,n),ye(t,e,n)},"paintServerDef:remove":(t,e,n)=>{Q(t,e,["id"],he,n),j(t.id,`${e}.id`,n),ye(t,e,n)},"presence:cursor":(t,e,n)=>{Q(t,e,["position"],[],n);let r=fe(t.position,`${e}.position`,n);r&&(Q(r,`${e}.position`,["x","y"],[],n,!1),et(r.x,`${e}.position.x`,n),et(r.y,`${e}.position.y`,n))},"presence:selection":(t,e,n)=>{Q(t,e,["shapeIds"],[],n),Cn(t.shapeIds,`${e}.shapeIds`,n)}},iI=new Set(Object.keys(Bm)),Gm=new Set(["presence:cursor","presence:selection"]);function lc(t,e="operation"){let n=[],r=fe(t,e,n);return r?!j(r.type,`${e}.type`,n)||!iI.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&ae(n,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:n}):(Bm[r.type](r,e,n),n.length===0?{valid:!0,value:r}:{valid:!1,issues:n}):{valid:!1,issues:n}}function oI(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)&&ae(n,"ops",`must contain ${r}-${i} operations`);let o=[];return t.forEach((s,a)=>{let l=lc(s,`ops[${a}]`);if(!l.valid){n.push(...l.issues);return}if(Gm.has(l.value.type)){ae(n,`ops[${a}].type`,"presence operations are not document operations");return}o.push(l.value)}),n.length===0?{valid:!0,value:o}:{valid:!1,issues:n}}function sI(t){let e=lc(t,"op");return e.valid?Gm.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function aI(t){return t.slice(0,5).map(({path:e,message:n})=>`${e} ${n}`).join("; ")}function cc(t,e,n,r){let i=e[n],o=typeof i=="string"?i:"",s=(t??[]).filter(l=>l[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 dc(t,e,n){return(t??[]).filter(r=>r[e]!==n)}function ft(t,e,n){return cc(t,e,"id",n)}function mt(t,e){return dc(t,"id",e)}function uc(t,e,n){return cc(t,e,"name",n)}function pc(t,e){return dc(t,"name",e)}function Vm(t,e){return JSON.stringify(t)===JSON.stringify(e)}function co(t,e,n){let r=t?[...t]:[],i=r.find(o=>o.id===e);return i?ft(r,i,n):r}function jm(t,e,n,r,i){let o=[],s=new Map(t.map(c=>[c.id,c])),a=new Set(e.map(c=>c.id)),l=[...t];for(let c of t)a.has(c.id)||(o.push(r(c.id)),l=mt(l,c.id));return e.forEach((c,u)=>{let d=s.get(c.id);(!d||!Vm(d,c))&&(o.push(n(c,u)),l=ft(l,c,u))}),e.forEach((c,u)=>{l[u]?.id!==c.id&&(o.push(i(c.id,u)),l=co(l,c.id,u))}),o}function lI(t,e){return jm(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 cI(t,e){return jm(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 dI(t,e){let n=t??{},r=e??{},i={},o=[];for(let[s,a]of Object.entries(r))Vm(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 ks(t,e){switch(e.type){case"guide:upsert":return ft(t,e.guide,e.index);case"guide:remove":return mt(t,e.id);case"guide:move":return co(t,e.id,e.index)}}function Rs(t,e){switch(e.type){case"measurement:upsert":return ft(t,e.measurement,e.index);case"measurement:remove":return mt(t,e.id);case"measurement:move":return co(t,e.id,e.index)}}function uI(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 pI(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 fI(t,e){return t.slice(0,e.start)+e.insert+t.slice(e.start+e.deleteCount)}function Ts(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 ai=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}),po=Object.keys(ai);function An(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $n(t){return typeof t=="string"?t:void 0}function rt(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 jn(t){return e=>typeof e=="string"&&t.includes(e)?e:void 0}function mI(t){if(t==="normal"||t==="bold")return t;let e=rt(t);return e===400?"normal":e===700?"bold":e}function gI(t){return t==="baseline"||t==="super"||t==="sub"?t:rt(t)}function Hm(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(!An(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 Wm(t){if(!An(t))return;let e={};for(let[n,r]of Object.entries(t)){let i=rt(r);i!==void 0&&(e[n]=i)}return e}var Km={fontFamily:$n,fontSize:rt,fontWeight:mI,fontStyle:jn(["normal","italic","oblique"]),fontVariant:$n,fontVariantLigatures:$n,fontVariantPosition:$n,fontVariantCaps:$n,fontVariantNumeric:$n,fontVariantEastAsian:$n,textTransform:jn(["none","capitalize","uppercase","lowercase"]),baselineShift:gI,dominantBaseline:jn(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:jn(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:jn(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:jn(["ltr","rtl"]),unicodeBidi:jn(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:jn(["start","middle","end"]),letterSpacing:rt,wordSpacing:rt,lineHeight:rt,fill:$n,fillOpacity:rt,stroke:$n,strokeWidth:rt,strokeOpacity:rt};function uo(t,e){return{...t,...e,textDecoration:{...t.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??t.fontVariationSettings}}}function hc(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 Un(t,e){for(let n of po)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(!hc(t.fontVariationSettings,e.fontVariationSettings))return!1}else if(t[n]!==e[n])return!1;return!0}function yc(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 l of a){let c=l;if(o[c]!==s[c])return!1}}else if(i==="fontVariationSettings"){if(!hc(t.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let o=i;if(t[o]!==e[o])return!1}return!0}function fc(t,e){let n={};for(let i of po)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),hc(t.fontVariationSettings,e.fontVariationSettings)||(n.fontVariationSettings={...t.fontVariationSettings}),n}function En(t,e=ai){let n=An(t)?t:{},r={...e};for(let i of po){if(i==="textDecoration"||i==="fontVariationSettings")continue;let o=Km[i](n[i]);o!==void 0&&(r[i]=o)}return r.textDecoration={...e.textDecoration,...Hm(n.textDecoration)??{}},r.fontVariationSettings={...Wm(n.fontVariationSettings)??e.fontVariationSettings},r}function Ps(t){let e=An(t)?t:{},n={};for(let r of po){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=Km[r](e[r]);i!==void 0&&(n[r]=i)}if(e.textDecoration!==void 0){let r=Hm(e.textDecoration);r&&Object.keys(r).length>0&&(n.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=Wm(e.fontVariationSettings);r&&(n.fontVariationSettings=r)}return n}function Xm(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 hI(t,e,n){return t.start===t.end?n&&t.start===e:t.start<=e&&e<t.end}function mc(t,e,n,r){let i=t;for(let o of e)hI(o,n,r)&&(i=uo(i,o.style));return i===t?uo(t,{}):i}function yI(t,e,n={}){let r=En(t.baseStyle),i=typeof t.text=="string"?t.text:"";return mc(r,Sc(t.runs,i.length),e,n.collapsed===!0)}function li(t,e=ai){let n=An(t)?t:{},r=En(n.baseStyle,e),i=typeof n.text=="string"?n.text:"";return{text:i,runs:Sc(n.runs,i.length),baseStyle:r,lineHeight:rt(n.lineHeight)??r.lineHeight}}function Sc(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!An(r))continue;let i=rt(r.start),o=rt(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:Ps(r.style)})}return n}function Hn(t){let e=typeof t.text=="string"?t.text:"",n=En(t.baseStyle),r=Sc(t.runs,e.length),i=rt(t.lineHeight)??n.lineHeight;return{lines:Xm(e).map(s=>{if(s.text.length===0)return{segments:[{text:"",style:mc(n,r,s.start,!0)}]};let a=new Set([s.start,s.end]);for(let u of r)u.start!==u.end&&(u.start>s.start&&u.start<s.end&&a.add(u.start),u.end>s.start&&u.end<s.end&&a.add(u.end));let l=[...a].sort((u,d)=>u-d),c=[];for(let u=0;u<l.length-1;u++){let d=l[u],p=l[u+1],f=mc(n,r,d,!1),g=c[c.length-1];g&&Un(g.style,f)?g.text+=e.slice(d,p):c.push({text:e.slice(d,p),style:f})}return{segments:c}}),baseStyle:n,lineHeight:i}}function ci(t){let e=En(t?.baseStyle),n=rt(t?.lineHeight)??e.lineHeight,r=Array.isArray(t?.lines)?t.lines:[],i=r.length>0?r:[{segments:[]}],o=[],s=[],a=0;for(let u=0;u<i.length;u++){u>0&&(o.push(`
3
+ `),a+=1);let d=i[u]?.segments,p=Array.isArray(d)?d:[],f=a;for(let g of p){let m=typeof g?.text=="string"?g.text:"";if(m.length===0)continue;let h=En(g?.style,e),b=fc(h,e);Object.keys(b).length>0&&s.push({start:a,end:a+m.length,style:b}),o.push(m),a+=m.length}if(a===f){let g=En(p[0]?.style,e),m=fc(g,e);Object.keys(m).length>0&&s.push({start:f,end:f,style:m})}}let l=o.join(""),c=[];for(let u of s){let d=c[c.length-1];d!==void 0&&d.start!==d.end&&u.start!==u.end&&(d.end===u.start||d.end+1===u.start&&l.charAt(d.end)===`
4
+ `)&&yc(d.style,u.style)&&d?d.end=u.end:c.push({start:u.start,end:u.end,style:u.style})}return{text:l,runs:c,baseStyle:e,lineHeight:n}}function di(t){let e=t.richTextRuns;if(An(e))return li(e);let n=t.richTextData;return An(n)&&Array.isArray(n.lines)&&n.lines.length>0?ci(n):null}function gc(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 SI(t,e){if(t.start===t.end||e.start>=e.end||t.start<e.start||t.end>e.end)return!1;let n=gc(e.style);for(let r of gc(t.style))if(!n.has(r))return!1;return!0}function Cs(t,e){let n=[...t];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(n=n.filter(i=>!SI(i,r)),n.push({start:r.start,end:r.end,style:r.style}));return n}function bc(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!An(r))continue;let i=rt(r.start),o=rt(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 l=Ps(r.style);Object.keys(l).length!==0&&n.push({start:s,end:a,style:l})}return n}function bI(t,e){let n=[];for(let r of t){let i=Ts({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 Um(t,e){return t.start===e.start&&t.end===e.end&&yc(t.style,e.style)}function vI(t,e){if(t.text!==e.text||t.lineHeight!==e.lineHeight||!Un(En(t.baseStyle),En(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 l=-1;for(let c=i;c<n.length;c++)if(Um(n[c],r[o])){l=c;break}if(l===-1)break;i=l+1,o++}let s=r.slice(o);if(s.length===0)return null;for(let l of s)if(l.start>=l.end||Object.keys(l.style).length===0)return null;let a=Cs(n,s);if(a.length!==r.length)return null;for(let l=0;l<a.length;l++)if(!Um(a[l],r[l]))return null;return s.map(l=>({start:l.start,end:l.end,style:Ps(l.style)}))}function xI(t,e){let n=e===0||t.charAt(e-1)===`
5
+ `,r=e===t.length||t.charAt(e)===`
6
+ `;return n&&r}function II(t,e,n){let r=[];for(let i of t){let o=i.start===i.end,s=Ts({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=s.start,l=s.start+s.deleteCount;a===l&&(!o||!xI(n,a))||r.push({start:a,end:l,style:i.style})}return r}function Wn(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 $s(t){if(t.builtIn)return!1;let e=t.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function Ym(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 fo(t){if(!$s(t))return null;let{width:e,height:n}=Ym(t.pattern);return{id:t.id,name:t.name,svgContent:t.pattern.svgContent??"",width:e,height:n}}function it(t){let e=[...t].sort((i,o)=>i.index-o.index);if(!e.some(i=>i.orderKey))return e;let n=ic(e.length),r=new Map;return e.forEach((i,o)=>{r.set(i.id,i.orderKey??n[o])}),e.sort((i,o)=>{let s=vs(r.get(i.id)??"",r.get(o.id)??"");return s!==0?s:i.id<o.id?-1:i.id>o.id?1:0})}function kt(t){return t.definitionId??`${t.type}-${t.id}`}function vc(t){return t.rawDefinition!==void 0?!0:t.clipShapeIds&&t.clipShapeIds.length>0?!1:!t.clipShapeId}function xc(t){let e=vc(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 ui(t,e,n){let{clipPathUnits:r,clipRule:i,maskUnits:o,maskContentUnits:s,maskType:a,maskBounds:l,rawDefinition:c,...u}=structuredClone(t),d=e.rawDefinition!==void 0||vc(t);return t.type==="clip"?{...u,type:"clip",...e.clipPathUnits!==void 0?{clipPathUnits:e.clipPathUnits}:{},...!d&&e.clipRule!==void 0?{clipRule:e.clipRule}:{},...d&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}:{...u,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)}:{},...d&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}}function Nn(t){let e=new Map;for(let n of t??[]){let r=kt(n),i=xc(n),o=e.get(r);i.rawDefinition===void 0&&o?.rawDefinition!==void 0&&(i.rawDefinition=o.rawDefinition),e.set(r,i)}return e}function Ht(t){let e=structuredClone(t??[]),n=Nn(e),r=new Set;return e.map(i=>{let o=kt(i),s=n.get(o)??xc(i),a=s.rawDefinition!==void 0&&!r.has(o);a&&r.add(o);let l=ui(i,s,a);return Array.isArray(l.clipShapeIds)&&delete l.clipShapeId,l})}function br(t,e){let n=structuredClone(t??[]);if(e.type==="clipMask:remove"){let l=n.find(f=>f.id===e.id);if(!l)return Ht(n);let c=kt(l),u=Nn(n).get(c),d=n.filter(f=>f.id!==e.id),p=d.findIndex(f=>kt(f)===c);return u&&p>=0&&(d[p]=ui(d[p],u,!0)),Ht(d)}let r=n.findIndex(l=>l.id===e.clipMaskGroup.id),i=r>=0?n[r]:void 0,o=i?Nn(n).get(kt(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&&kt(i)===kt(a)&&(a=ui(a,o,!0)),n.splice(s,0,a),Ht(n)}function Ic(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?ui({...o,definitionId:n},r,r.rawDefinition!==void 0):kt(o)!==n?structuredClone(o):ui(o,r,!1));return Ht(i)}var wI=/^structural:(clip|mask):(.+):(group|path|content)$/;function qm(t,e){let n=`structural:${t}:${e}`;return{group:`${n}:group`,path:`${n}:path`,content:`${n}:content`}}function Zm(t,e){for(let n of t){e.add(n.id);let r=n.state.children;Array.isArray(r)&&Zm(r,e)}}function Jm(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(...Jm(o,r.id))}),n}function vr(t){let e=t.sceneTree&&t.sceneTree.length>0?t.sceneTree:Jm(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,it(x));let i=I=>wI.test(I),o=new Set(e.filter(I=>!i(I.id)).map(I=>I.id)),s=new Set;Zm(t.shapes,s);let a=new Map,l=new Set,c=(I,x)=>{let P=[];for(let T of r.get(I)??[]){if(!i(T.id)){l.has(T.id)||(l.add(T.id),P.push(T.id));continue}if(x.has(T.id))continue;let k=new Set(x);k.add(T.id),P.push(...c(T.id,k))}return P},u=[null,...o];for(let I of u){let x=c(I,new Set);x.length>0&&a.set(I,x)}for(let I of o){if(l.has(I))continue;let x=n.get(I)?.parentId??null,P=x!==null&&o.has(x)?x:null,T=a.get(P)??[];T.push(I),a.set(P,T),l.add(I)}let d=I=>{for(let[x,P]of a){let T=P.indexOf(I);if(T>=0)return{parentId:x,index:T}}return null},p=I=>{for(let x of a.values()){let P=x.indexOf(I);P>=0&&x.splice(P,1)}},f=t.clipMaskGroups??[],g=Nn(f),m=new Map(f.map(I=>[qm(I.type,I.id).content,I])),h=(I,x=new Set)=>{if(x.has(I.id))return Number.MAX_SAFE_INTEGER;let P=I.parentId?m.get(I.parentId):void 0;if(!P)return 0;let T=new Set(x);return T.add(I.id),1+h(P,T)},b=[...f].sort((I,x)=>h(I)-h(x)||(I.siblingIndex??0)-(x.siblingIndex??0)),S=new Map;for(let I of b){let x=(I.clipShapeIds.length>0?I.clipShapeIds:I.clipShapeId?[I.clipShapeId]:[]).filter(O=>s.has(O)),P=I.contentShapeIds.filter(O=>s.has(O)),T=g.get(kt(I));if(P.length===0||x.length===0&&!T?.rawDefinition)continue;let k=[...P,...x].map(d).filter(O=>O!==null),w=k[0]?.parentId??null,$=k.length>0?Math.min(...k.map(O=>O.index)):void 0,R=I.parentId===null||o.has(I.parentId)||m.has(I.parentId)?I.parentId:w;for(let O of[...x,...P])p(O);let C=qm(I.type,I.id),A=a.get(R)??[],D=I.siblingIndex??$??A.length,_=Math.min(Math.max(0,D),A.length);A.splice(_,0,C.group),a.set(R,A),a.set(C.group,[C.path,C.content]),a.set(C.path,[...x]),a.set(C.content,[...P]),S.set(C.group,{id:C.group,parentId:R,index:0}),S.set(C.path,{id:C.path,parentId:C.group,index:0}),S.set(C.content,{id:C.content,parentId:C.group,index:1})}let v=[];for(let[I,x]of a)x.forEach((P,T)=>{let k=S.get(P);if(k){v.push({...k,parentId:I,index:T});return}let w=n.get(P);w&&w.parentId===I?v.push({...w,index:T}):v.push({id:P,parentId:I,index:T})});t.sceneTree=v}function Mt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function wc(t){return Mt(t)&&typeof t.updatedAt=="number"&&Number.isSafeInteger(t.updatedAt)&&t.updatedAt>=0&&typeof t.clientId=="string"}function xr(t,e){return{updatedAt:typeof t=="number"&&Number.isSafeInteger(t)&&t>=0?t:0,clientId:e??""}}function mo(t,e){return wc(e)?t.updatedAt>e.updatedAt||t.updatedAt===e.updatedAt&&t.clientId>=e.clientId:!0}function Qm(t){return Mt(t.collaborationState)||(t.collaborationState={}),t.collaborationState}function eg(t,e){let n=Qm(t);Mt(n.shapeProps)||(n.shapeProps={});let r=n.shapeProps;return Mt(r[e])||(r[e]={}),r[e]}function go(t,e){let n=t.collaborationState?.shapeProps;if(!Mt(n))return{};let r=n[e];return Mt(r)?r:{}}function tg(t,e,n,r){if(n.length===0)return;let i=eg(t,e);for(let o of n)mo(r,i[o])&&(i[o]=r)}function kc(t,e){let n=t.collaborationState?.shapeProps;if(Mt(n)){for(let r of e)delete n[r];kI(t)}}function kI(t){let e=t.collaborationState;if(Mt(e)){for(let n of["shapeProps","resources"]){let r=e[n];Mt(r)&&Object.keys(r).length===0&&delete e[n]}Object.keys(e).length===0&&delete t.collaborationState}}function ng(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"customPattern:upsert":return`customPattern:${t.customPattern.id}`;case"customPattern:remove":return`customPattern:${t.id}`;case"paintServerDef:upsert":return`paintServerDef:${t.paintServerDef.id}`;case"paintServerDef:remove":return`paintServerDef:${t.id}`;default:return null}}function rg(t,e,n){if(e.type==="shape:update"&&e.propTimestamps){if(!n)return null;let a=go(t,e.id),l={},c={},u=[];for(let[p,f]of Object.entries(e.state)){let g=xr(e.propTimestamps[p],e.clientId);mo(g,a[p])&&(l[p]=f,c[p]=g.updatedAt,u.push([p,g]))}if(u.length===0)return null;let d=eg(t,e.id);for(let[p,f]of u)d[p]=f;return{...e,state:l,propTimestamps:c}}let r=ng(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=xr(e.updatedAt,e.clientId),o=Qm(t);Mt(o.resources)||(o.resources={});let s=o.resources;return mo(i,s[r])?(s[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function RI(t){let e=0,n=t.collaborationState?.shapeProps;if(Mt(n)){for(let i of Object.values(n))if(Mt(i))for(let o of Object.values(i))wc(o)&&(e=Math.max(e,o.updatedAt))}let r=t.collaborationState?.resources;if(Mt(r))for(let i of Object.values(r))wc(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 TI(t,e){let n=Object.keys(e.state);if(n.length===0)return;let r=go(t,e.id),i=0;for(let s of n){let a=xr(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 Ir(t){t.symbols!==void 0&&(t.symbols=(t.library??[]).filter(e=>e.kind==="symbol").map(({kind:e,...n})=>n)),t.customPatterns!==void 0&&(t.customPatterns=(t.library??[]).filter(e=>e.kind==="pattern").map(e=>fo(e)).filter(e=>e!==null))}function cg(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(...cg(o,r.id))}),n}function Wt(t,e){if(t===e)return!0;let n=t??ig,r=e??ig;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 ig=[];function ho(t){return t.sceneTree&&t.sceneTree.length>0?t.sceneTree:cg(t.shapes)}function PI(t,e){let n=t,r=new Set(t.map(s=>s.id)),i=(s,a,l)=>{r.has(s.id)||(n=Rc(n,{id:s.id,parentId:a,index:l}),r.add(s.id)),pi(s)?.forEach((u,d)=>i(u,s.id,d))},o=n.filter(s=>s.parentId===null).length;return i(e,null,o),n}function dg(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())it(r).forEach((i,o)=>n.push({...i,index:o}));return n}function Ns(t,e){let n=t.filter(l=>l.parentId===e);if(n.every(l=>l.orderKey))return t;let r=it(n),i=new Map,o=[],s=null,a=l=>{if(o.length===0)return;let c=rc(s,l,o.length);o.forEach((u,d)=>i.set(u.id,c[d])),o=[]};for(let l of r)l.orderKey?(a(l.orderKey),s=l.orderKey):o.push(l);return a(null),t.map(l=>i.has(l.id)?{...l,orderKey:i.get(l.id)}:l)}function Rc(t,e){let n,r=[],i=[],o=!1;for(let l of t){if(l.id===e.id){if(n=l,!Tc(e,n))return t;continue}l.parentId===e.parentId?(r.push(l),l.orderKey&&(o=!0)):i.push(l)}if(o){let l=Ns([...i,...r],e.parentId),c=it(l.filter(g=>g.parentId===e.parentId)),u=Math.min(Math.max(0,e.index),c.length),d=u>0?c[u-1].orderKey??null:null,p=u<c.length?c[u].orderKey??null:null,f=d!==null&&p!==null&&d>=p?d:so(d,p);return[...i,...c,{...e,orderKey:f}]}let s=r.sort((l,c)=>l.index-c.index).map((l,c)=>({...l,index:c})),a=Math.min(Math.max(0,e.index),s.length);return[...i,...s,{...e,index:a-.5}]}function CI(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 ug(t,e){let n=t.keyframes.findIndex(r=>r.id===e.id);n>=0?t.keyframes[n]=e:t.keyframes.push(e),CI(t)}function pg(t,e){t.keyframes=t.keyframes.filter(n=>n.id!==e)}function og(t,e){let n=t.animationTimeline?.tracks;return Array.isArray(n)?n.find(r=>r.id===e)??null:null}function Tc(t,e){let n=t.updatedAt??0,r=e.updatedAt??0;return n!==r?n>r:(t.clientId??"")>=(e.clientId??"")}function pi(t){let e=t.state.children;return Array.isArray(e)?e:void 0}var Es=new Set(["group","hyperlink","switch","container","svg"]);function fg(t,e,n,r){for(let i of t){n.set(i.id,e),r.set(i.id,i);let o=pi(i);o&&fg(o,i.id,n,r)}}function fi(t){let e=t.sceneTree;if(!e||e.length===0)return;let n=new Map,r=new Map;if(fg(t.shapes,null,n,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 o=new Map,s=(d,p)=>{let f=o.get(d);f?f.push(p):o.set(d,[p])},a=new Set,l=new Set,c=(d,p)=>{for(let f of it(i.get(d)??[])){if(l.has(f.id))continue;l.add(f.id);let g=r.get(f.id);if(!g){c(f.id,p);continue}s(p,g),a.add(g.id),Es.has(g.type)&&c(f.id,g.id)}};if(c(null,null),a.size===0)return;let u=d=>{let p=n.get(d)??null,f=new Set;for(;p!==null&&!f.has(p);){f.add(p);let g=r.get(p);if(g&&Es.has(g.type))return p;p=n.get(p)??null}return null};for(let[d,p]of r)a.has(d)||s(u(d),p);for(let[d,p]of r){if(!Es.has(p.type))continue;let f=p.state,g=o.get(d);g&&g.length>0?f.children=g:"children"in f&&delete f.children}t.shapes=o.get(null)??[]}function $I(t){let e=`structural:${t.type}:${t.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function yo(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 l=i.get(a.parentId);l?l.push(a):i.set(a.parentId,[a])}let o=a=>it(i.get(a)??[]).map(l=>l.id).filter(l=>!l.startsWith("structural:")),s=new Map(n.map(a=>[a.id,a]));t.clipMaskGroups=e.map(a=>{let l=$I(a);if(!r.has(l.group))return a;let c=r.has(l.path)?o(l.path):a.clipShapeIds,u=r.has(l.content)?o(l.content):a.contentShapeIds,d=s.get(l.group),p=a.parentId,f=a.siblingIndex;if(d){p=d.parentId;let m=d.parentId===null?n.filter(b=>b.parentId===null):i.get(d.parentId)??[],h=it(m).findIndex(b=>b.id===l.group);f=h>=0?h:d.index}if(sg(c,a.clipShapeIds)&&sg(u,a.contentShapeIds)&&p===a.parentId&&f===a.siblingIndex)return a;let g={...a,clipShapeIds:c,contentShapeIds:u,parentId:p,siblingIndex:f};return g.clipShapeId!==void 0&&(g.clipShapeId=c[0]),g})}function sg(t,e){return!e||t.length!==e.length?!1:t.every((n,r)=>n===e[r])}function Cc(t,e){e.add(t.id);let n=pi(t);if(n)for(let r of n)Cc(r,e)}function Pc(t,e){for(let n of t){e.set(n.id,n);let r=pi(n);r&&Pc(r,e)}}var As=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,Pc(this.snapshot.shapes,this.shapeIndex)),n=this.shapeIndex.get(e)??null):n=mi(this.snapshot.shapes,e),this.memoId=e,this.memoShape=n,n}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&Pc([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=dg(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,fi(this.snapshot))}};function mi(t,e){for(let n of t){if(n.id===e)return n;let r=pi(n);if(!r)continue;let i=mi(r,e);if(i)return i}return null}function wr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function EI(t){let e=t.richTextRuns;return!wr(e)||typeof e.text!="string"?null:li(e)}function AI(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 mg(t,e,n){let r=[];for(let i of t){if(i.id===e){Cc(i,n);continue}let o=pi(i);if(o){let s=mg(o,e,n),a=i.state;s.length>0?a.children=s:delete a.children}r.push(i)}return r}function gg(t,e){let n=t.snapshot,r=n,i=rg(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 l=ho(r),c=sc(structuredClone(o.shape));r.shapes.push(c),r.sceneTree=PI(l,c),t.noteShapesAdded(c),t.requestSceneTreeNormalize(),t.requestInlineProjection();let u=new Set;Cc(c,u),kc(n,u)}break}case"shape:update":{let a=t.findShape(o.id);if(!a)return null;AI(a,o.state);break}case"text:format":{let a=t.findShape(o.id);if(!a)return null;let l=a.state;"extra"in l&&hr(l);let c=EI(l);if(!c)return null;let u=bc(o.ranges,c.text.length);if(u.length===0)return null;let d={...c,runs:Cs(c.runs,u)};l.richTextRuns=d;let p=["richTextRuns"];if(wr(l.richTextData)&&(l.richTextData=Hn(d),p.push("richTextData")),o.updatedAt!==void 0){let f=xr(o.updatedAt,o.clientId),g=go(n,o.id);if(p.some(h=>!mo(f,g?.[h]))){let h=Math.max(0,...p.map(b=>g?.[b]?.updatedAt??0));f={updatedAt:Math.max(f.updatedAt,h)+1,clientId:f.clientId},s={...o,updatedAt:f.updatedAt,clientId:f.clientId}}tg(n,o.id,p,f)}break}case"shape:remove":{let a=new Set,l=mg(r.shapes,o.id,a),c=a.size>0;c||a.add(o.id);let u=ho(r),d=u.filter(p=>!a.has(p.id));if(!c&&d.length===u.length)return null;r.shapes=l,r.sceneTree=d,t.noteShapesRemoved(),kc(n,a),yo(r);break}case"scene:move":{let a=ho(r),l=a.find(d=>d.id===o.id),c=o.updatedAt===void 0?void 0:xr(o.updatedAt,o.clientId),u={id:o.id,parentId:o.parentId,index:o.index,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!Tc(u,l))return null;r.sceneTree=Rc(a,u),t.requestSceneTreeNormalize(),c&&(s={...o,...c}),t.requestInlineProjection(),yo(r);break}case"scene:place":{if(!bs(o.orderKey))return null;let a=ho(r),l=a.find(p=>p.id===o.id),c=o.updatedAt===void 0?void 0:xr(o.updatedAt,o.clientId),u={id:o.id,parentId:o.parentId,index:l?.index??Number.MAX_SAFE_INTEGER,orderKey:o.orderKey,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!Tc(u,l))return null;let d=Ns(a,o.parentId);r.sceneTree=[...d.filter(p=>p.id!==o.id),u],t.requestSceneTreeNormalize(),t.requestInlineProjection(),yo(r),c&&(s={...o,...c});break}case"shapes:reorder":{let a=ho(r);o.ids.forEach((l,c)=>{a.some(u=>u.id===l&&u.parentId===null)&&(a=Rc(a,{id:l,parentId:null,index:c}))}),r.sceneTree=a,t.requestSceneTreeNormalize(),t.requestInlineProjection(),yo(r);break}case"groups:set":r.groups=o.groups;break;case"clipmasks:set":r.clipMaskGroups=Ht(o.clipMaskGroups),vr(r);break;case"clipMask:upsert":r.clipMaskGroups=br(r.clipMaskGroups,o),vr(r);break;case"clipMask:remove":{if(!(r.clipMaskGroups??[]).some(l=>l.id===o.id))return null;let a=br(r.clipMaskGroups,o);r.clipMaskGroups=a,vr(r);break}case"guides:set":r.guides=o.guides;break;case"guide:upsert":r.guides=ks(r.guides,o);break;case"guide:remove":case"guide:move":{let a=ks(r.guides,o);if(Wt(r.guides,a))return null;r.guides=a;break}case"measurements:set":r.measurements=o.measurements;break;case"measurement:upsert":r.measurements=Rs(r.measurements,o);break;case"measurement:remove":case"measurement:move":{let a=Rs(r.measurements,o);if(Wt(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(([l])=>!(o.removeKeys??[]).includes(l)));r.documentMetadata=a;break}case"documentScripts:set":r.documentScripts=o.documentScripts;break;case"documentScript:upsert":r.documentScripts=ft(r.documentScripts,o.documentScript,o.index);break;case"documentScript:remove":{let a=mt(r.documentScripts,o.id);if(Wt(r.documentScripts,a))return null;r.documentScripts=a;break}case"documentStyles:set":r.documentStyles=o.documentStyles;break;case"documentStyle:upsert":r.documentStyles=ft(r.documentStyles,o.documentStyle,o.index);break;case"documentStyle:remove":{let a=mt(r.documentStyles,o.id);if(Wt(r.documentStyles,a))return null;r.documentStyles=a;break}case"templateVariables:set":r.templateVariables=o.templateVariables;break;case"templateVariable:upsert":r.templateVariables=uc(r.templateVariables,o.templateVariable,o.index);break;case"templateVariable:remove":{let a=pc(r.templateVariables,o.name);if(Wt(r.templateVariables,a))return null;r.templateVariables=a;break}case"exportItems:set":r.exportItems=o.exportItems;break;case"exportItem:upsert":r.exportItems=ft(r.exportItems,o.exportItem,o.index);break;case"exportItem:remove":{let a=mt(r.exportItems,o.id);if(Wt(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:ft(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:[],l=mt(a,o.id);if(Wt(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=og(r,o.trackId);if(!a)return null;ug(a,structuredClone(o.keyframe));break}case"animationKeyframe:remove":{let a=og(r,o.trackId);if(!a)return null;let l=a.keyframes;if(pg(a,o.keyframeId),Wt(l,a.keyframes))return null;break}case"symbols:set":{r.symbols=o.symbols;let a=o.symbols.map(c=>({...c,kind:"symbol"})),l=(r.library??[]).filter(c=>c.kind!=="symbol");r.library=[...a,...l],Ir(r);break}case"customPatterns:set":r.customPatterns=o.customPatterns;{let a=new Set(o.customPatterns.map(c=>c.id)),l=(r.library??[]).filter(c=>!a.has(c.id)&&(c.kind!=="pattern"||!$s(c)));r.library=[...l,...o.customPatterns.map(c=>Wn(c))]}Ir(r);break;case"customPattern:upsert":{r.customPatterns=ft(r.customPatterns,o.customPattern,o.index);let a=Wn(o.customPattern),l=[...r.library??[]],c=l.findIndex(u=>u.id===a.id);c>=0?l[c]=a:l.push(a),r.library=l,Ir(r);break}case"customPattern:remove":{let a=mt(r.customPatterns,o.id),l=mt(r.library,o.id);if(Wt(r.customPatterns,a)&&Wt(r.library,l))return null;r.customPatterns=a,r.library=l,Ir(r);break}case"library:set":r.library=o.library,Ir(r);break;case"library:upsert":r.library=ft(r.library,o.def,o.index),Ir(r);break;case"library:remove":{let a=mt(r.library,o.id);if(Wt(r.library,a))return null;r.library=a,Ir(r);break}case"rawPaintServerDefs:set":r.rawPaintServerDefs=o.rawPaintServerDefs,delete r.paintServerDefs;break;case"paintServerDefs:set":r.paintServerDefs=o.paintServerDefs,r.rawPaintServerDefs=o.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:upsert":r.paintServerDefs=ft(r.paintServerDefs,o.paintServerDef,o.index),r.rawPaintServerDefs=r.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:remove":{let a=mt(r.paintServerDefs,o.id);if(Wt(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=o;return null}}return s}function NI(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 ag(t,e.id,i)}if(e.type==="text:format"&&n?.type==="text:format"){if(!(n.updatedAt!==e.updatedAt||n.clientId!==e.clientId))return[];let i=mi(t.shapes,e.id)?.state,o=i&&wr(hg(i,"richTextData"))?["richTextRuns","richTextData"]:["richTextRuns"];return ag(t,e.id,o)}return[]}function hg(t,e){if(e in t)return t[e];let n=t.extra;return wr(n)?n[e]:void 0}function MI(t,e){if(e in t)return!0;let n=t.extra;return wr(n)&&e in n}function ag(t,e,n){if(n.length===0)return[];let r=mi(t.shapes,e);if(!r)return[];let i=r.state,o=go(t,e),s=new Map;for(let l of n){let c=o[l];if(!c)continue;let u=s.get(c.clientId);u?u.push(l):s.set(c.clientId,[l])}let a=[];for(let[l,c]of s){let u={},d={};for(let p of c)u[p]=MI(i,p)?structuredClone(hg(i,p)):null,d[p]=o[p].updatedAt;a.push({type:"shape:update",id:e,state:u,propTimestamps:d,clientId:l})}return a}function $c(t,e){let n=new As(t,!1),r=gg(n,e);return n.settle(),r}function yg(t,e){let n=new As(t,e.length>1),r=[];for(let i of e){let o=gg(n,i);o&&r.push(o)}return n.settle(),r}function Sg(t,e){let n=structuredClone(t);return{snapshot:n,acceptedOps:yg(n,e)}}function OI(t,e){return Sg(t,e).snapshot}function DI(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=Ns(e,n);return dg(e)}function zI(t,e){if(!t.some(r=>r.type==="scene:place"))return t;let n=new Map((e??[]).map(r=>[r.id,r]));return t.map(r=>{if(r.type!=="scene:place")return r;let i=n.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 _I(t,e){if(!t.some(i=>i.type==="animationKeyframe:upsert"||i.type==="animationKeyframe:remove"))return t;let n=Array.isArray(e?.tracks)?e.tracks:[],r=[];for(let i of t){if(i.type!=="animationKeyframe:upsert"&&i.type!=="animationKeyframe:remove"){r.push(i);continue}let o=n.findIndex(s=>s.id===i.trackId);o!==-1&&r.push({type:"animationTrack:upsert",track:structuredClone(n[o]),index:o,updatedAt:i.updatedAt,clientId:i.clientId})}return r}function FI(t,e){if(!t.some(r=>r.type==="text:format"))return t;let n=[];for(let r of t){if(r.type!=="text:format"){n.push(r);continue}let i=mi(e,r.id);if(!i)continue;let o=i.state.richTextRuns;if(!wr(o))continue;let s={richTextRuns:structuredClone(o)},a=i.state.richTextData;wr(a)&&(s.richTextData=structuredClone(a)),n.push({type:"shape:update",id:r.id,state:s,...typeof r.updatedAt=="number"?{propTimestamps:Object.fromEntries(Object.keys(s).map(l=>[l,r.updatedAt]))}:{},...r.clientId!==void 0?{clientId:r.clientId}:{}})}return n}function LI(t,e){if(!t.some(r=>r.type==="guide:move"||r.type==="measurement:move"))return t;let n=[];for(let r of t)if(r.type==="guide:move"){let i=e.guides??[],o=i.findIndex(s=>s.id===r.id);if(o===-1)continue;n.push({type:"guide:upsert",guide:structuredClone(i[o]),index:o,updatedAt:r.updatedAt,clientId:r.clientId})}else if(r.type==="measurement:move"){let i=e.measurements??[],o=i.findIndex(s=>s.id===r.id);if(o===-1)continue;n.push({type:"measurement:upsert",measurement:structuredClone(i[o]),index:o,updatedAt:r.updatedAt,clientId:r.clientId})}else n.push(r);return n}var BI=6,lg=new Set(["templateVariables:set","templateVariable:upsert","templateVariable:remove","exportItems:set","exportItem:upsert","exportItem:remove","colorGlyphLibrary:set"]);function GI(t){return t.some(e=>lg.has(e.type))?t.filter(e=>!lg.has(e.type)):t}function VI(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 l of it(s)){if(!e.hasNode(l.id))continue;let c=a++;(e.getParentId(l.id)!==o||e.getSiblingIndex(l.id)!==c)&&e.move(l.id,o,c),i(l.id)}};i(null);for(let o of n.keys())o!==null&&i(o)}var So="data-svgsketch-passthrough",jI=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]),UI=/^<([A-Za-z][\w:-]*)\b[^>]*>/;function bg(t){return UI.exec(t.trimStart())}function bo(t){let e=bg(t);if(!e)return null;let n=/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(e[0]);return n?n[1]??n[2]:null}function HI(t){let e=bg(t);if(!e)return null;let n=e[1],r=n.lastIndexOf(":");return r>=0?n.slice(r+1):n}var WI=new RegExp(`\\s+${So}\\s*=\\s*(?:"[^"]*"|'[^']*')`);function Ms(t){let e=t.markup.indexOf(">");if(e<0)return t;let n=t.markup.slice(0,e+1),r=WI.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 Os(t){let e=[];for(let n of t){if(typeof n!="string")continue;let r=bo(n);if(!r)continue;let i=HI(n),o=i&&jI.has(i)?i:"mask";e.push(Ms({id:r,type:o,markup:n}))}return e}var Ec={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."},groups:{kind:"retired",note:"Legacy hierarchy sidecar, emitted empty; parentage rides sceneTree."},clipMaskGroups:{kind:"aggregate"},documentMetadata:{kind:"aggregate"},documentScripts:{kind:"aggregate"},documentStyles:{kind:"aggregate"},templateVariables:{kind:"aggregate"},animationTimeline:{kind:"aggregate"},library:{kind:"aggregate"},rawPaintServerDefs:{kind:"stamped",note:"Derived projection stamped at serialize time: paintServerDefs.map(def => def.markup), emitted beside the typed section for legacy readers. No live state of its own; inbound-only as the legacy fallback the typed form wins over (paintServerDefsFromRawFragments lifts it)."},paintServerDefs:{kind:"aggregate"},customPatterns:{kind:"retired",note:"Deprecated v1 field, read-only inbound."},symbols:{kind:"retired",note:"Deprecated v1 field, read-only inbound."},markers:{kind:"retired",note:"Deprecated v1 field, read-only inbound."},colorGlyphLibrary:{kind:"aggregate"},exportItems:{kind:"aggregate"},unknownFields:{kind:"aggregate"}},vg=Object.keys(Ec).filter(t=>Ec[t].kind==="aggregate");function Mn(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Nc(){return{title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"",customMetadata:{}}}function xg(t){return{...Nc(),...t??{}}}function Ds(t){let e=t.paintServerDefs&&t.paintServerDefs.length>0?t.paintServerDefs:Os(t.rawPaintServerDefs??[]);return{guides:structuredClone(t.guides??[]),measurements:structuredClone(t.measurements??[]),clipMaskGroups:Ht(t.clipMaskGroups??[]),documentMetadata:structuredClone(xg(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(e),unknownFields:structuredClone(t.unknownFields??{})}}var Ac=["symbol","marker","linear-gradient","radial-gradient","pattern","filter"];function Ig(t){let e=t.filter(i=>i.builtIn!==!0),n=Ac.map(()=>[]),r=[];for(let i of e){let o=Ac.indexOf(i.kind);o>=0?n[o].push(i):r.push(i)}return[...n.flat(),...r]}var kr=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?this.sections.clipMaskGroups.filter(s=>!(s.type===r[1]&&s.id===r[2])):this.sections.clipMaskGroups;i=i.map(s=>{let a=`structural:${s.type}:${s.id}`,l=this.graph.getNode(`${a}:group`);if(!l)return s;let c=this.graph.getNode(`${a}:path`),u=this.graph.getNode(`${a}:content`),d=c?this.graph.getChildren(c.id).filter(m=>m.getProp("structural")!==!0).map(m=>m.id):s.clipShapeIds,p=u?this.graph.getChildren(u.id).filter(m=>m.getProp("structural")!==!0).map(m=>m.id):s.contentShapeIds,f=this.graph.getSiblingIndex(l.id),g={...s,clipShapeIds:d,contentShapeIds:p,parentId:this.graph.getParentId(l.id),...f>=0?{siblingIndex:f}:{}};return s.clipShapeId!==void 0&&(g.clipShapeId=d[0]),g});let o=Ht(i);Mn(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(xg(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=ft(this.sections.library,structuredClone(e),i);Mn(this.sections.library,o)||(this.sections.library=o,this.notify("library"))}removeLibraryDef(e){let n=mt(this.sections.library,e);Mn(this.sections.library,n)||(this.sections.library=n,this.notify("library"))}assembleLibrary(){return Ig(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=Ht(e),this.notify("clipMaskGroups")}getClipMaskDefinition(e){let n=Nn(this.sections.clipMaskGroups).get(e);return n?structuredClone(n):null}getClipMaskDefinitions(){return structuredClone(Object.fromEntries(Nn(this.sections.clipMaskGroups)))}upsertClipMaskDefinition(e,n,r){let i=Ic(this.sections.clipMaskGroups,e,n,r);Mn(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=br(this.sections.clipMaskGroups,{type:"clipMask:upsert",clipMaskGroup:e,...n>=0?{index:n}:{}});Mn(this.sections.clipMaskGroups,r)||(this.sections.clipMaskGroups=r,this.notify("clipMaskGroups"))}unbindClipMaskGroup(e){let n=br(this.sections.clipMaskGroups,{type:"clipMask:remove",id:e});Mn(this.sections.clipMaskGroups,n)||(this.sections.clipMaskGroups=n,this.notify("clipMaskGroups"))}removeClipMaskDefinition(e){let n=Ht(this.sections.clipMaskGroups.filter(r=>kt(r)!==e));Mn(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=Ds(e),i=vg.filter(o=>!Mn(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:Ct,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,rawPaintServerDefs:e.map(n=>n.markup),unknownFields:structuredClone(this.sections.unknownFields)}}applyOps(e){let n=this.snapshotForReducer(),r=[],i=new Set;for(let o of e){let s=Ds(n);$c(n,o);let a=Ds(n);for(let l of vg)i.has(l)||Mn(s[l],a[l])||(i.add(l),r.push(l))}this.sections=Ds(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&&e.paintServerDefs.length>0?e.paintServerDefs:Os(e.rawPaintServerDefs??[])),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 KI=1;function Mc(){return`canonical-document-${KI++}`}var gi=class t{constructor(e,n){this.model=e;this.identity=n}model;identity;disposed=!1;static empty(e=Mc()){return new t(new kr,e)}static own(e,n=Mc()){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=Mc()){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())}},Oc=class{constructor(e=gi.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 l=[a];try{n.rollback?.(o)}catch(c){l.push(c)}try{e.dispose()}catch(c){l.push(c)}throw this.replacing=!1,l.length>1?new AggregateError(l,"Document replacement rejection cleanup failed.",{cause:a}):a}let s=[];for(let a of[...this.listeners])try{a(o)}catch(l){s.push(l)}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 wg=Object.freeze({linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"});function XI(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(ei))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 Dc(t,e,n,r){let i=XI(t,e,n,r);return i===null?{easing:"custom-bezier",customBezier:[t,e,n,r]}:{easing:i}}function YI(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 qI(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 ZI(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 l=0;l<i-n;l++)e[n+l].position=o+(s-o)*(l+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 hi(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 wg)return{kind:"keyword",easing:wg[e]};let n=/^cubic-bezier\s*\(([^)]*)\)$/u.exec(e);if(n){let l=n[1].split(",").map(f=>Number(f.trim()));if(l.length!==4||l.some(f=>!Number.isFinite(f)))return null;let[c,u,d,p]=l;return c<0||c>1||d<0||d>1?null:{kind:"cubic-bezier",points:[c,u,d,p]}}let r=/^steps\s*\(([^)]*)\)$/u.exec(e);if(r){let l=r[1].split(",").map(d=>d.trim());if(l.length<1||l.length>2||!/^\d+$/u.test(l[0]))return null;let c=Number(l[0]);if(!Number.isInteger(c)||c<1)return null;let u=qI(l[1]??"jump-end");return!u||u==="jump-none"&&c<2?null:{kind:"steps",count:c,position:u}}let i=/^linear\s*\(([\s\S]*)\)$/u.exec(e);if(!i)return null;let o=YI(i[1]);if(o.length===0)return null;let s=[];for(let l of o){let c=l.split(/\s+/u).filter(Boolean);if(c.length===0)return null;let u=Number(c[0]);if(!Number.isFinite(u))return null;let d=[];for(let p of c.slice(1)){if(!p.endsWith("%"))return null;let f=Number(p.slice(0,-1));if(!Number.isFinite(f))return null;d.push(f/100)}if(d.length>2)return null;s.push({value:u,positions:d})}let a=ZI(s);return a&&a.length>=2?{kind:"linear",points:a}:null}function Tg(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=Dc(...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 kg(t,e,n){let r=1-t;return 3*r*r*t*e+3*r*t*t*n+t*t*t}function Rg(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=kg(o,e[0],e[2]);if(Math.abs(a-n)<=1e-8)break;a<n?r=o:i=o,o=(r+i)/2}return kg(o,e[1],e[3])}function Pg(t,e){let n=Math.max(0,Math.min(1,e));if(!t)return n;switch(t.kind){case"keyword":{let r=ei[t.easing];return r?Rg(n,r):n}case"cubic-bezier":return Rg(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 Kn(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 Cg(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 $g(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 Eg(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 Ag(t){if(t.cycleInfinite)return null;let e=Eg(t);return e===null?null:e+$g(t)*Math.max(0,t.cycleRepeats??1)}function zs(t,e,n,r,i){return t+(Cg(n,r)?e-i:i)}function d_(t,e){let n=t.keyframes[0]?.time??0,r=Eg(t);if(r===null)return null;let i=$g(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?zs(n,i,o,0,0):null;let a=Math.max(0,t.cycleRepeats??1),l=t.cycleInfinite??!1,c=l?1/0:i*a;if(!l&&s>=c){if(t.fill==="remove")return null;if(a<=0)return zs(n,i,o,0,0);let p=Math.floor(a),f=a-p,g=f>Number.EPSILON?p:p-1,m=f>Number.EPSILON?f*i:i;return zs(n,i,o,g,m)}let u=Math.floor(s/i),d=s-u*i;return zs(n,i,o,u,d)}function Ng(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=Cg(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 JI=new Set(["ease","ease-in","ease-out","ease-in-out","linear","step-start","step-end"]),QI=new Set(["normal","reverse","alternate","alternate-reverse"]),ew=new Set(["none","forwards","backwards","both"]),tw=new Set(["running","paused"]),zc="(?:\\d+(?:\\.\\d+)?|\\.\\d+)",Og=`[+-]?${zc}`,nw=new RegExp(`^${zc}(?:s|ms)$`,"u"),rw=new RegExp(`^${Og}(?:s|ms)$`,"u"),iw=new RegExp(`^${zc}$`,"u");function Dg(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 _s(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 Fs(t,e){let n=_s(t);return n.length===0?"":n[e%n.length]}function _c(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",l="1",c="none",u="",d=!1,p=!1;for(let f of n){if(!d&&nw.test(f)){r=f.endsWith("ms")?Number(f.slice(0,-2))/1e3:Number(f.slice(0,-1)),d=!0;continue}if(d&&!p&&rw.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)||JI.has(f)){let g=hi(f);g&&(s=g,o=Dg(g));continue}if(QI.has(f)){a=f;continue}if(f==="infinite"){l=f;continue}if(iw.test(f)){l=f;continue}if(ew.has(f)){c=f;continue}tw.has(f)||u||(u=f)}return!u||r<=0?null:{name:u,duration:r,delay:i,easing:o,parsedEasing:s,direction:a,iterationCount:l,fillMode:c}}function Mg(t){let e=new RegExp(`^(${Og})\\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 zg(t,e,n){let r=d=>Fs(e[d],n),i=Mg(r("animation-delay"));i!==null&&(t.delay=i);let o=Mg(r("animation-duration"));o!==null&&o>0&&(t.duration=o);let s=hi(r("animation-timing-function"));s&&(t.parsedEasing=s,t.easing=Dg(s));let a=r("animation-direction");a&&(t.direction=a);let l=r("animation-iteration-count");l&&(t.iterationCount=l);let c=r("animation-fill-mode");c&&(t.fillMode=c);let u=r("animation-name");u&&u!=="none"&&(t.name=u)}function _g(t){let e=_s(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=>Fs(t[s],i)).filter(Boolean);return o.push(r),o.join(" ")}).join(", ")}function Fg(t){let e=t.fillMode==="forwards"||t.fillMode==="both",n=t.fillMode==="backwards"||t.fillMode==="both";return{...e?{}:{fill:"remove"},...n?{fillBackwards:!0}:{}}}function Bs(t){return/[\t\n\f\r ]/u.test(t??"")}function vo(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function Ls(t,e){let n=e;for(;n<t.length;){if(Bs(t[n])){n++;continue}let r=vo(t,n);if(r===n)break;n=r}return n}function xo(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];Bs(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 On(t,e,n=!1){let r=[],i=0,o=null,s=!1,a=0;for(let l=0;l<t.length;l++){let c=t[l];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==="/"&&t[l+1]==="*"){l=Math.max(l,vo(t,l)-1);continue}if(c==='"'||c==="'"){o=c;continue}if(c==="("||c==="["||c==="{")a++;else if(c===")"||c==="]"||c==="}")a=Math.max(0,a-1);else if(c===e&&a===0&&(r.push(Object.freeze({start:i,end:l})),i=l+1,n))break}return r.push(Object.freeze({start:i,end:t.length})),r}function yi(t,e){return On(t,e,e===":").map(n=>t.slice(n.start,n.end))}function ow(t){return!!(t&&(/[-_a-z]/iu.test(t)||t==="\\"))}function sw(t){return!!(t&&(/[-_a-z0-9]/iu.test(t)||t==="\\"))}function aw(t,e){let n=e;for(;n<t.length;){let r=t[n];if(r!=="\\"){if(!sw(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++;Bs(t[n])&&n++}return n}function mn(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,vo(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!ow(o))continue;let s=i,a=aw(t,i);if(t[a]!=="("){i=a-1;continue}let l=a+1,c=1,u=null,d=!1,p=l;for(;p<t.length;p++){let f=t[p];if(u){d?d=!1:f==="\\"?d=!0:f===u&&(u=null);continue}if(f==="/"&&t[p+1]==="*"){p=Math.max(p,vo(t,p)-1);continue}if(f==='"'||f==="'"){u=f;continue}if(f==="(")c++;else if(f===")"&&--c===0)break}if(c!==0){i=a;continue}e.push(Object.freeze({name:xo(t.slice(s,a))?.toLowerCase()??t.slice(s,a).toLowerCase(),tokenStart:s,tokenEnd:p+1,argumentsStart:l,argumentsEnd:p})),i=p}return Object.freeze(e)}function lw(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 Dn(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,vo(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!lw(t,i))continue;let s=i,a=Ls(t,i+4),l=t[a]==='"'||t[a]==="'"?t[a++]:null;if(a=Ls(t,a),t[a]!=="#")continue;a++;let c=a,u=a,d=!1,p=!1;for(;a<t.length;a++){let g=t[a];if(p){p=!1,u=a+1;continue}if(g==="\\"){p=!0,u=a+1;continue}if(l){if(g===l){a=Ls(t,a+1),d=t[a]===")";break}u=a+1;continue}if(g===")"){d=!0;break}if(Bs(g)||g==="/"&&t[a+1]==="*"){a=Ls(t,a),d=t[a]===")";break}u=a+1}if(!d||u<=c)continue;let f=xo(t.slice(c,u));f&&(e.push(Object.freeze({targetAuthoredId:f,tokenStart:s,tokenEnd:a+1,targetStart:c,targetEnd:u})),i=a)}return Object.freeze(e)}var Bg=String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?`,Gg="px|pt|pc|in|cm|mm|q|em|rem|%|ex|ch|vw|vh|vmin|vmax",cw=new RegExp(String.raw`^(${Bg})\s*(${Gg})?$`,"i"),Lg=new RegExp(`(${Bg})(${Gg})?`,"gi");function ot(t){if(t===null||t.trim().length===0)return null;let e=cw.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 Fc(t){if(!t)return Object.freeze([]);Lg.lastIndex=0;let e=[],n;for(;(n=Lg.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 Xn(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 Se(t,e){let n=ot(t);return n?Xn(n,e):void 0}function Ot(t){let e=ot(t);if(!(!e||["em","rem","%","ex","ch","vw","vh","vmin","vmax"].includes(e.unit)))return Xn(e,{})}var Oe=Object.freeze([1,0,0,1,0,0]);function st(t,e,n,r,i,o){return[t,e,n,r,i,o]}function Vs(t){return st(t[0]??1,t[1]??0,t[2]??0,t[3]??1,t[4]??0,t[5]??0)}function at(t){return[t[0],t[1],t[2],t[3],t[4],t[5]]}function Yn(t){return Array.isArray(t)&&t.length>=6&&t.slice(0,6).every(Number.isFinite)}function Kt(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 y_(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 de(t,e){return st(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 S_(t){let e=t[0]*t[3]-t[2]*t[1];if(Math.abs(e)<1e-10)return null;let n=1/e;return st(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 Be(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 Lc(t,e){return{x:t[0]*e.x+t[2]*e.y,y:t[1]*e.x+t[3]*e.y}}function _e(t,e=0){return st(1,0,0,1,t,e)}function bi(t,e=t){return st(t,0,0,e,0,0)}function wo(t){let e=t*Math.PI/180,n=Math.cos(e),r=Math.sin(e);return st(n,r,-r,n,0,0)}function js(t){return st(1,0,Math.tan(t*Math.PI/180),1,0,0)}function Us(t){return st(1,Math.tan(t*Math.PI/180),0,1,0,0)}function Hg(t,e){return de(de(_e(t.x,t.y),e),_e(-t.x,-t.y))}var dw=9,uw=10,pw=12,fw=13,mw=32,Vg=43,gw=44,jg=45,hw=46,yw=48,Sw=57,bw=40,vw=41,xw=69,Iw=101,ww=0,kw=1,Wg=2,Rw=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function Tw(t){return t===mw||t===dw||t===uw||t===fw||t===pw}function Gs(t){return t>=yw&&t<=Sw}function Pw(t){let e=t>=65&&t<=90,n=t>=97&&t<=122;return e||n||Gs(t)}function Si(t){for(;t.pos<t.src.length&&Tw(t.src.charCodeAt(t.pos));)t.pos++}function Kg(t){let e=t.pos;return Si(t),t.src.charCodeAt(t.pos)===gw?(t.pos++,Si(t),Wg):t.pos>e?kw:ww}function Ug(t){let e=t.src,n=t.pos,r=n,i=e.charCodeAt(r);(i===Vg||i===jg)&&r++;let o=!1;for(;r<e.length&&Gs(e.charCodeAt(r));)r++,o=!0;if(e.charCodeAt(r)===hw){let l=r+1;for(;l<e.length&&Gs(e.charCodeAt(l));)l++;l>r+1&&(r=l,o=!0)}if(!o)return null;let s=e.charCodeAt(r);if(s===Iw||s===xw){let l=r+1,c=e.charCodeAt(l);(c===Vg||c===jg)&&l++;let u=l;for(;u<e.length&&Gs(e.charCodeAt(u));)u++;u>l&&(r=u)}let a=Number(e.slice(n,r));return Number.isFinite(a)?(t.pos=r,a):null}function Cw(t,e){switch(t){case"matrix":return Vs(e);case"translate":return _e(e[0],e[1]??0);case"scale":return bi(e[0],e[1]??e[0]);case"rotate":return e.length===3?Hg({x:e[1],y:e[2]},wo(e[0])):wo(e[0]);case"skewX":return js(e[0]);case"skewY":return Us(e[0]);default:return null}}function $w(t){let e=t.src,n=t.pos;for(;t.pos<e.length&&Pw(e.charCodeAt(t.pos));)t.pos++;if(t.pos===n)return null;let r=e.slice(n,t.pos),i=Rw.get(r);if(!i||(Si(t),e.charCodeAt(t.pos)!==bw))return null;t.pos++,Si(t);let o=i[i.length-1],s=Ug(t);if(s===null)return null;let a=[s];for(;;){let l=t.pos;Kg(t);let c=Ug(t);if(c===null){t.pos=l;break}if(a.push(c),a.length>o)return null}return Si(t),e.charCodeAt(t.pos)!==vw||(t.pos++,!i.includes(a.length))?null:Cw(r,a)}function Ew(t){let e={src:t,pos:0};if(Si(e),e.pos>=t.length)return Oe;let n=Oe;for(;;){let r=$w(e);if(r===null)return null;n=de(n,r);let i=Kg(e);if(e.pos>=t.length)return i===Wg?null:n}}var Aw=2048,Io=new Map;function Xt(t){if(!t)return Oe;let e=Io.get(t);if(e!==void 0)return e;let n=Ew(t),r=n===null?null:Object.freeze(n);if(Io.size>=Aw){let i=Io.keys().next().value;i!==void 0&&Io.delete(i)}return Io.set(t,r),r}function Dt(t){return Xt(t)??Oe}function Hs(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),l=(e*i-n*r)/o,c=l!==0?(e*r+n*i)/(o*o):0,u=Math.atan(c),d=180/Math.PI;return{rotation:s*d,scaleX:o,scaleY:l,skewX:u*d}}function Ws(t){return!Yn(t)||Kt(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,l=t.scaleX??1,c=t.scaleY??1,u=_e(n,r);if(i)return de(u,Dt(i));if(o===0&&s===0&&a===0&&l===1&&c===1)return u;let d=t.customPivot??e;if(!d)return u;let p=de(de(de(wo(o),bi(l,c)),js(s)),Us(a));return de(u,Hg(d,p))}function gt(t,e){return Ws(rn(t,e))}function rn(t,e){let n=t.transformMatrix;return Yn(n)&&!Kt(n)?Vs(n):Ks(t,e)}function Xg(t,e){let n=t.ancestorTransform;if(!Yn(n)){delete t.ancestorTransform;return}if(Kt(n)){delete t.ancestorTransform;return}let r=Yn(t.transformMatrix)?Vs(t.transformMatrix):Ks(t,e);t.transformMatrix=at(de(Vs(n),r)),delete t.ancestorTransform}function Yg(t,e,n){let r=gt(t,{x:e,y:n});return r?`${r} translate(${e}, ${n})`:`translate(${e}, ${n})`}var Nw=Object.freeze({left:0,center:50,right:100}),Mw=Object.freeze({top:0,center:50,bottom:100});function Zn(t,e,n){let r=ot(t);return!r||r.unit===""&&r.value!==0?null:Xn(r,{...n,percentBasis:e==="x"?n.boxWidth:e==="y"?n.boxHeight:void 0})??null}function qg(t,e,n){let r=t.trim().toLowerCase(),i=e==="horizontal"?Nw:Mw;if(Object.hasOwn(i,r))return{kind:"percentage",value:i[r]};let o=ot(r);if(!o||o.unit===""&&o.value!==0)return null;if(o.unit==="%")return{kind:"percentage",value:o.value};let s=Xn(o,n);return s===void 0?null:{kind:"length",value:s}}function Zg(t,e,n){return t.kind==="length"?e+t.value:n===void 0?null:e+t.value*n/100}function oh(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 u=Zn(n[2],"z",e);if(u===null||n[2].includes("%"))return null;r=u}let i,o;if(n.length===1){let u=n[0].toLowerCase();u==="top"||u==="bottom"?(i="center",o=n[0]):(i=n[0],o="center")}else{i=n[0],o=n[1];let u=i.toLowerCase(),d=o.toLowerCase(),p=u==="top"||u==="bottom",f=d==="left"||d==="right";p&&(f||d==="center")?[i,o]=[o,i]:u==="center"&&f&&([i,o]=[o,i])}let s=qg(i,"horizontal",e),a=qg(o,"vertical",e);if(!s||!a)return null;let l=Zg(s,e.boxX??0,e.boxWidth),c=Zg(a,e.boxY??0,e.boxHeight);return l===null||c===null?null:Object.freeze(r===0?{x:l,y:c}:{x:l,y:c,z:r})}var Zs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ow=new Set(["matrix3d","perspective","rotate3d","rotatex","rotatey","rotatez","scale3d","scalez","translate3d","translatez"]),Dw=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(deg|grad|rad|turn)?$/iu;function Jg(t){return t.replace(/\/\*[\s\S]*?\*\//gu,"").trim()===""}function zw(t){let e=[],n="",r=0,i=null,o=!1,s=!1,a=()=>{let l=n.trim();return n="",l?(e.push(l),!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(i){n+=c,o?o=!1:c==="\\"?o=!0:c===i&&(i=null);continue}if(c==='"'||c==="'"){i=c,n+=c;continue}if(c==="/"&&t[l+1]==="*"){let u=t.indexOf("*/",l+2);if(u<0)return null;n+=" ",l=u+1;continue}if(c==="("){r++,n+=c;continue}if(c===")"){if(r===0)return null;r--,n+=c;continue}if(r===0&&c===","){if(!a())return null;s=!0;continue}if(r===0&&/\s/u.test(c)&&!s){n.trim()&&a();continue}n+=c}return r!==0||i||n.trim()===""&&s||n.trim()&&!a()?null:Object.freeze(e)}function sh(t){if(t.trim().toLowerCase()==="none")return Object.freeze([]);let e=mn(t);if(e.length===0)return null;let n=[],r=0;for(let i of e){if(!Jg(t.slice(r,i.tokenStart)))return null;let o=zw(t.slice(i.argumentsStart,i.argumentsEnd));if(!o)return null;n.push(Object.freeze({name:i.name,args:o})),r=i.tokenEnd}return Jg(t.slice(r))?Object.freeze(n):null}function on(t){if(t===void 0||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Yt(t){if(t===void 0)return null;let e=Dw.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 Tr(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 Pr(t,e,n){return[1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1]}function ko(t,e,n){return[t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1]}function Jn(t,e,n,r){let i=Math.hypot(t,e,n);if(i===0)return r===0?Zs: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 zt(t,...e){return e.includes(t.length)}function Js(t,e){let n=t.args;switch(t.name){case"translate":{if(!zt(n,1,2))return null;let r=Zn(n[0],"x",e),i=Zn(n[1]??"0","y",e);return r===null||i===null?null:Pr(r,i,0)}case"translatex":case"translatey":case"translatez":{if(!zt(n,1))return null;let r=t.name.at(-1),i=Zn(n[0],r,e);return i===null?null:Pr(r==="x"?i:0,r==="y"?i:0,r==="z"?i:0)}case"translate3d":{if(!zt(n,3))return null;let r=Zn(n[0],"x",e),i=Zn(n[1],"y",e),o=Zn(n[2],"z",e);return r===null||i===null||o===null?null:Pr(r,i,o)}case"scale":{if(!zt(n,1,2))return null;let r=on(n[0]),i=n.length===1?r:on(n[1]);return r===null||i===null?null:ko(r,i,1)}case"scalex":case"scaley":case"scalez":{if(!zt(n,1))return null;let r=on(n[0]);return r===null?null:ko(t.name==="scalex"?r:1,t.name==="scaley"?r:1,t.name==="scalez"?r:1)}case"scale3d":{if(!zt(n,3))return null;let r=n.map(on);return r.some(i=>i===null)?null:ko(r[0],r[1],r[2])}case"rotate":case"rotatex":case"rotatey":case"rotatez":{if(!zt(n,1))return null;let r=Yt(n[0]);return r===null?null:t.name==="rotatex"?Jn(1,0,0,r):t.name==="rotatey"?Jn(0,1,0,r):Jn(0,0,1,r)}case"rotate3d":{if(!zt(n,4))return null;let r=on(n[0]),i=on(n[1]),o=on(n[2]),s=Yt(n[3]);return r===null||i===null||o===null||s===null?null:Jn(r,i,o,s)}case"skew":{if(!zt(n,1,2))return null;let r=Yt(n[0]),i=Yt(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(!zt(n,1))return null;let r=Yt(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(!zt(n,6))return null;let r=n.map(on);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(!zt(n,16))return null;let r=n.map(on);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 zt(n,1)&&Zn(n[0],"z",e)!==null?"perspective":null;default:return null}}function ah(t,e){let n=Zs;for(let r of t){let i=Js(r,e);if(!i||i==="perspective")return i;n=Tr(n,i)}return n}function lh(t){let e=sh(t);if(!e)return"invalid";let n=ah(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 Ys(t){return t.startsWith("translate")?"translate":t.startsWith("scale")?"scale":t.startsWith("rotate")?"rotate":t.startsWith("skew")?"skew":"matrix"}function Qg(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(Zs.map(String))}):null}function _w(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=Qg(r[o]);if(!s)return null;n[o]=s}if(!r[o]&&n[o]){let s=Qg(n[o]);if(!s)return null;r[o]=s}}return[n,r]}function eh(t,e){let n=Js(t,e);return!n||n==="perspective"?null:[n[3],n[7],n[11]]}function th(t){let e=Js(t,{});return!e||e==="perspective"?null:[e[0],e[5],e[10]]}function Ke(t,e,n){return t+(e-t)*n}function Fw(t,e,n,r){let i=Ys(t.name);if(i!==Ys(e.name))return null;if(i==="translate"){let o=eh(t,r),s=eh(e,r);return o&&s?Pr(Ke(o[0],s[0],n),Ke(o[1],s[1],n),Ke(o[2],s[2],n)):null}if(i==="scale"){let o=th(t),s=th(e);return o&&s?ko(Ke(o[0],s[0],n),Ke(o[1],s[1],n),Ke(o[2],s[2],n)):null}if(i==="rotate"&&t.name===e.name){if(t.name==="rotate3d"){let l=t.args.slice(0,3).map(on),c=e.args.slice(0,3).map(on),u=Yt(t.args[3]),d=Yt(e.args[3]);if(l.some(b=>b===null)||c.some(b=>b===null)||u===null||d===null)return null;let p=Math.hypot(l[0],l[1],l[2]),f=Math.hypot(c[0],c[1],c[2]);if(p===0||f===0)return null;let g=[l[0]/p,l[1]/p,l[2]/p],m=[c[0]/f,c[1]/f,c[2]/f],h=g[0]*m[0]+g[1]*m[1]+g[2]*m[2];return Math.abs(Math.abs(h)-1)>1e-10?null:Jn(g[0],g[1],g[2],Ke(u,h<0?-d:d,n))}let o=Yt(t.args[0]),s=Yt(e.args[0]);if(o===null||s===null)return null;let a=Ke(o,s,n);return t.name==="rotatex"?Jn(1,0,0,a):t.name==="rotatey"?Jn(0,1,0,a):Jn(0,0,1,a)}if(i==="skew"&&t.name===e.name&&t.args.length===e.args.length){let o=t.args.map(Yt),s=e.args.map(Yt);return o.some(a=>a===null)||s.some(a=>a===null)?null:Js({name:t.name,args:o.map((a,l)=>`${Ke(a,s[l],n)}rad`)},r)}return null}function Lw(t,e,n,r){let i=_w(t,e);if(!i)return null;let o=Zs;for(let s=0;s<i[0].length;s++){let a=Fw(i[0][s],i[1][s],n,r);if(!a)return null;o=Tr(o,a)}return o}function qs(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:st(t[0],t[4],t[1],t[5],t[3],t[7])}function Bw(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 Xs(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Bc(t){return Math.hypot(t[0],t[1],t[2])}function Rr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Gc(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Gw(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 Vw(t,e,n){let r=t[0],i=e[0],o=n[0],s=t[1],a=e[1],l=n[1],c=t[2],u=e[2],d=n[2],p=r+a+d,f,g,m,h;if(p>0){let S=Math.sqrt(p+1)*2;h=S/4,f=(u-l)/S,g=(o-c)/S,m=(s-i)/S}else if(r>a&&r>d){let S=Math.sqrt(1+r-a-d)*2;h=(u-l)/S,f=S/4,g=(i+s)/S,m=(o+c)/S}else if(a>d){let S=Math.sqrt(1+a-r-d)*2;h=(o-c)/S,f=(i+s)/S,g=S/4,m=(l+u)/S}else{let S=Math.sqrt(1+d-r-a)*2;h=(s-i)/S,f=(o+c)/S,g=(l+u)/S,m=S/4}let b=Math.hypot(f,g,m,h);return[f/b,g/b,m/b,h/b]}function nh(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=Bc(e);if(i<1e-12)return null;e=Rr(e,1/i);let o=Xs(e,n);n=Gc(n,Rr(e,o));let s=Bc(n);if(s<1e-12)return null;n=Rr(n,1/s),o/=s;let a=Xs(e,r);r=Gc(r,Rr(e,a));let l=Xs(n,r);r=Gc(r,Rr(n,l));let c=Bc(r);return c<1e-12?null:(r=Rr(r,1/c),a/=c,l/=c,Xs(e,Gw(n,r))<0&&(i=-i,e=Rr(e,-1)),{translate:[t[3],t[7],t[11]],scale:[i,s,c],skew:[o,a,l],quaternion:Vw(e,n,r)})}function jw(t,e,n){let r=[...e],i=t.reduce((c,u,d)=>c+u*r[d],0);if(i<0&&(r=r.map(c=>-c),i=-i),i>.9995){let c=t.map((d,p)=>Ke(d,r[p],n)),u=Math.hypot(...c);return c.map(d=>d/u)}let o=Math.acos(Math.max(-1,Math.min(1,i))),s=Math.sin(o),a=Math.sin((1-n)*o)/s,l=Math.sin(n*o)/s;return t.map((c,u)=>c*a+r[u]*l)}function Uw(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 Hw(t,e,n){let r=nh(t),i=nh(e);if(!r||!i)return null;let o=r.translate.map((u,d)=>Ke(u,i.translate[d],n)),s=r.scale.map((u,d)=>Ke(u,i.scale[d],n)),a=r.skew.map((u,d)=>Ke(u,i.skew[d],n)),l=Uw(jw(r.quaternion,i.quaternion,n)),c=[1,a[0],a[1],0,0,1,a[2],0,0,0,1,0,0,0,0,1];return Tr(Tr(Pr(o[0],o[1],o[2]),Tr(l,c)),ko(s[0],s[1],s[2]))}function rh(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 Ww(t,e,n){let r=qs(t),i=qs(e);if(!r||!i)return null;let o=Hs(r),s=Hs(i),a=s.rotation;for(;a-o.rotation>180;)a-=360;for(;a-o.rotation<-180;)a+=360;let l=Ke(o.rotation,a,n)*Math.PI/180,c=Ke(o.skewX,s.skewX,n)*Math.PI/180,u=Ke(o.scaleX,s.scaleX,n),d=Ke(o.scaleY,s.scaleY,n),p=Math.cos(l),f=Math.sin(l),g=Math.tan(c);return Bw(st(p*u,f*u,p*u*g-f*d,f*u*g+p*d,Ke(r[4],i[4],n),Ke(r[5],i[5],n)))}function Kw(t,e,n,r,i,o){let s=Lw(t,e,i,o);return s||(rh(n)&&rh(r)?Ww(n,r,i):Hw(n,r,i))}function ih(t,e){return Tr(Tr(Pr(e.x,e.y,e.z??0),t),Pr(-e.x,-e.y,-(e.z??0)))}function qn(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?0:Number(t.toFixed(10))}function Xw(t){return t.every(e=>e.length===1&&(e[0].name==="rotate"||e[0].name==="rotatez"))}function Yw(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 ch(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(m=>sh(m.transform));if(r.some(m=>m===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let i=r.map(m=>ah(m,e));if(i.some(m=>m==="perspective"))return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});if(i.some(m=>m===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let o=r,s=i,a=e.transformOrigin,l=Xw(o),c=e.retainPureRotationOrigin===!0&&l,u=l?o.map(m=>Yt(m[0].args[0])*180/Math.PI):null,d=o.some(m=>m.some(h=>Ow.has(h.name)))||a!==void 0&&!c&&l||o.some((m,h)=>h>0&&m.length!==o[h-1].length)||o.some((m,h)=>h>0&&m.some((b,S)=>Ys(b.name)!==Ys(o[h-1][S]?.name??"matrix"))),p=[];for(let m=0;m<t.length;m++){let h=a&&!c?ih(s[m],a):s[m],b=qs(h);if(!b)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[m].offset,matrix:b,...u?{rotation:u[m]}:{}});let S=t[m+1];if(!(!S||!d))for(let v=1;v<n;v++){let I=v/n,x=Math.max(0,Math.min(1,e.progressForInterval?.(m,I)??I)),P=Kw(o[m],o[m+1],s[m],s[m+1],x,e);if(!P)return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let T=a&&!c?ih(P,a):P,k=qs(T);if(!k)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[m].offset+(S.offset-t[m].offset)*I,matrix:k,...u?{rotation:Ke(u[m],u[m+1],x)}:{}})}}let f=null,g=p.sort((m,h)=>m.offset-h.offset).map(({offset:m,matrix:h,rotation:b})=>{let S=Hs(h),v=b??S.rotation;if(b===void 0&&f!==null){for(;v-f>180;)v-=360;for(;v-f<-180;)v+=360}f=v;let I=st(...h.map(qn));return Object.freeze({offset:qn(m),matrix:I,translateX:qn(I[4]),translateY:qn(I[5]),rotation:qn(v),scaleX:qn(S.scaleX),scaleY:qn(S.scaleY),skewX:qn(S.skewX),skewY:0})});return Object.freeze({status:"projected",stops:Object.freeze(g),sampled:d,pureRotation:c,channels:Yw(o,d,g)})}function ea(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 Uc(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 l=s+a*Math.PI/t,c=a%2===0?e:o;i.push({x:c*Math.cos(l),y:c*Math.sin(l)})}return i}function Hc(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 Wc(t,e,n,r,i=-90){let s=t*2*(n/100),a=t*(e/100),l=a*(r/100),c=[{x:t,y:0},{x:t-s,y:-a/2},{x:t-s,y:-l/2},{x:-t,y:-l/2},{x:-t,y:l/2},{x:t-s,y:l/2},{x:t-s,y:a/2}];if(i===0)return c;let u=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180);return c.map(p=>({x:p.x*u-p.y*d,y:p.x*d+p.y*u}))}function Kc(t,e,n,r,i=0){let o=t,s=o*(n/100),a=o*(r/100),l=a/2,c=e*Math.PI/180,u=Math.cos(c),d=Math.sin(c),p=Math.abs(u),f=Math.abs(d),g=Math.max(p,f)||1,m={x:u*(o/g),y:d*(o/g)},h={x:m.x+u*s,y:m.y+d*s},b=Math.min(a,o-l),S=-o+l+b,v=o-l-b,I={x:-o,y:-o},x={x:o,y:-o},P={x:o,y:o},T={x:-o,y:o},k;if(p>=f&&u>0){let R=Math.max(S,Math.min(v,m.y)),C={x:o,y:R-l},A={x:o,y:R+l};k=[I,x,C,h,A,P,T]}else if(p>=f&&u<=0){let R=Math.max(S,Math.min(v,m.y)),C={x:-o,y:R+l},A={x:-o,y:R-l};k=[I,x,P,T,C,h,A]}else if(d<0){let R=Math.max(S,Math.min(v,m.x)),C={x:R-l,y:-o},A={x:R+l,y:-o};k=[I,C,h,A,x,P,T]}else{let R=Math.max(S,Math.min(v,m.x)),C={x:R+l,y:o},A={x:R-l,y:o};k=[I,x,P,C,h,A,T]}if(i===0)return k;let w=Math.cos(i*Math.PI/180),$=Math.sin(i*Math.PI/180);return k.map(R=>({x:R.x*w-R.y*$,y:R.x*$+R.y*w}))}function Xc(t,e,n,r,i=0){let o=Math.max(2,Math.round(e)),s=t*(n/100),a=t*(r/100)/2,l=o+1,c=[];for(let m=0;m<l;m++){let h=m/(l-1),b=-t+h*2*t,S=0;m>0&&m<l-1&&(S=m%2===1?s:-s),c.push({x:S,y:b})}let u=[],d=[];for(let m=0;m<l;m++){if(m===0||m===l-1){u.push({...c[m]}),d.push({...c[m]});continue}let h=c[m-1],b=c[m],S=c[m+1],v=b.x-h.x,I=b.y-h.y,x=Math.hypot(v,I)||1,P=v/x,T=I/x,k=S.x-b.x,w=S.y-b.y,$=Math.hypot(k,w)||1,R=k/$,C=w/$,A=(P+R)/2,D=(T+C)/2,_=Math.hypot(A,D),O,L;_<1e-6?(O=-T,L=P):(O=-D/_,L=A/_),u.push({x:b.x-O*a,y:b.y-L*a}),d.push({x:b.x+O*a,y:b.y+L*a})}let p=[];p.push(u[0]);for(let m=1;m<l-1;m++)p.push(d[m]);p.push(u[l-1]);for(let m=l-2;m>=1;m--)p.push(u[m]);if(i===0)return p;let f=Math.cos(i*Math.PI/180),g=Math.sin(i*Math.PI/180);return p.map(m=>({x:m.x*f-m.y*g,y:m.x*g+m.y*f}))}function Yc(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},l={x:0,y:s},c={x:-i*o,y:i*.4},u={x:-i*o,y:-i},d={x:i*o,y:-i},p={x:i*o,y:i*.4},f=[a,c,u,l,d,p,a],g=r===0?f:(()=>{let x=Math.cos(r*Math.PI/180),P=Math.sin(r*Math.PI/180);return f.map(T=>({x:T.x*x-T.y*P,y:T.x*P+T.y*x}))})(),[m,h,b,S,v,I]=g;return`M ${m.x} ${m.y} C ${h.x} ${h.y} ${b.x} ${b.y} ${S.x} ${S.y} C ${v.x} ${v.y} ${I.x} ${I.y} ${m.x} ${m.y} Z`}function qc(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,l=s*1.15,c=[];for(let T=0;T<i;T++){let w=(90+T/i*360)*Math.PI/180;c.push({x:a/2*Math.cos(w),y:-(l/2)*Math.sin(w)})}let u=.15,d=0;for(let T=0;T<i;T++){let k=c[T],w=c[(T+1)%i];d=Math.max(d,Math.hypot(w.x-k.x,w.y-k.y))}let p=d/(2*(1-u))+.001,f=Math.max(p,d*(.68+o*.35)),g=c.map(T=>{let k=T.y/(l/2);return f*(1-u*k)});function m(T){let k=c[T],w=c[(T+1)%i],$=g[T],R=g[(T+1)%i],C=w.x-k.x,A=w.y-k.y,D=Math.hypot(C,A)||1,_=($*$-R*R+D*D)/(2*D),O=Math.sqrt(Math.max(0,$*$-_*_)),L=k.x+_/D*C,re=k.y+_/D*A,ee=-A/D,F=C/D,V={x:L+ee*O,y:re+F*O},H={x:L-ee*O,y:re-F*O};return V.x*V.x+V.y*V.y>H.x*H.x+H.y*H.y?V:H}let h=[];for(let T=0;T<i;T++)h.push(m(T));let b=14,S=[];for(let T=0;T<i;T++){let k=c[T],w=g[T],$=h[(T-1+i)%i],R=h[T],C=Math.atan2($.y-k.y,$.x-k.x),D=Math.atan2(R.y-k.y,R.x-k.x)-C;D<=0&&(D+=2*Math.PI);let _=2*Math.PI-D,O=C+D/2,L=C-_/2,re={x:k.x+w*Math.cos(O),y:k.y+w*Math.sin(O)},ee={x:k.x+w*Math.cos(L),y:k.y+w*Math.sin(L)},V=re.x*re.x+re.y*re.y>ee.x*ee.x+ee.y*ee.y?D:-_;for(let H=0;H<b;H++){let X=H/b,z=C+X*V;S.push({x:k.x+w*Math.cos(z),y:k.y+w*Math.sin(z)})}}let v=0;for(let T of S){let k=Math.max(Math.abs(T.x),Math.abs(T.y));k>v&&(v=k)}if(v>0&&v!==s){let T=s/v;for(let k of S)k.x*=T,k.y*=T}let I=T=>{if(r===0)return T;let k=Math.cos(r*Math.PI/180),w=Math.sin(r*Math.PI/180);return{x:T.x*k-T.y*w,y:T.x*w+T.y*k}},x=S.map(I),P=`M ${x[0].x} ${x[0].y}`;for(let T=1;T<x.length;T++)P+=` L ${x[T].x} ${x[T].y}`;return P+=" Z",P}function gn(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],l=t[(o+1)%t.length],c={x:s.x-a.x,y:s.y-a.y},u=Math.hypot(c.x,c.y);c.x/=u,c.y/=u;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 f=Math.min(r,u/2),g=Math.min(r,p/2),m={x:a.x+c.x*f,y:a.y+c.y*f},h={x:a.x+d.x*g,y:a.y+d.y*g};i+=o===0?`M${m.x},${m.y}`:` L${m.x},${m.y}`,i+=` Q${a.x},${a.y} ${h.x},${h.y}`}return i+" Z"}function Zc(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 Jc(t,e,n,r=1,i=0){let o=t*(n/100),a=Math.round(e*36),l=e*2*Math.PI,c=(t-o/2)/l,u=i*Math.PI/180,d=[],p=[];for(let m=0;m<=a;m++){let h=m/a,b=h*l*r+u,S=c*(h*l)+o/2,v=o/2;d.push({x:(S+v*.3)*Math.cos(b),y:(S+v*.3)*Math.sin(b)}),p.push({x:Math.max(0,S-v*.3)*Math.cos(b),y:Math.max(0,S-v*.3)*Math.sin(b)})}let f=`M ${d[0].x} ${d[0].y}`;for(let m=1;m<d.length;m++)f+=` L ${d[m].x} ${d[m].y}`;let g=p[p.length-1];f+=` L ${g.x} ${g.y}`;for(let m=p.length-2;m>=0;m--)f+=` L ${p[m].x} ${p[m].y}`;return f+=" Z",f}var qw=.2;function dh(t,e,n,r=0){let i=e*(n/100),o=e,s=e-i,a=2*Math.PI/t,l=a*qw/2,c=a/4,u=r*Math.PI/180,d=[];for(let p=0;p<t;p++){let f=u+p*a;d.push({x:s*Math.cos(f),y:s*Math.sin(f)}),d.push({x:o*Math.cos(f+c-l),y:o*Math.sin(f+c-l)}),d.push({x:o*Math.cos(f+c+l),y:o*Math.sin(f+c+l)}),d.push({x:s*Math.cos(f+a/2),y:s*Math.sin(f+a/2)})}return d}function Qc(t,e,n,r=0,i=0,o="evenodd",s=0){let a=dh(t,e,n,s),l=Math.min(r,e*.1),c=gn(a,l,e);if(i>0){let u=e*(i/100),d=o==="nonzero"?1:0;c+=` M ${u} 0 A ${u} ${u} 0 1 ${d} ${-u} 0 A ${u} ${u} 0 1 ${d} ${u} 0 Z`}return c}function ed(t,e,n,r,i,o="round",s="uniform",a){let l=Math.min(n,r)/2,c,u,d,p,f,g,m,h;if(s==="non-uniform"&&a?(c=Math.min(a.radiusTL??i,l),u=Math.min(a.radiusTR??i,l),d=Math.min(a.radiusBR??i,l),p=Math.min(a.radiusBL??i,l),f=a.shapeTL??o,g=a.shapeTR??o,m=a.shapeBR??o,h=a.shapeBL??o):(c=u=d=p=Math.min(i,l),f=g=m=h=o),!(o!=="round"||s==="non-uniform"||c>0&&f!=="round"||u>0&&g!=="round"||d>0&&m!=="round"||p>0&&h!=="round")&&c===u&&u===d&&d===p)return null;let S=`M${t+c},${e}`;return S+=` L${t+n-u},${e}`,S+=Qs(g,u,t+n,e,"tr"),S+=` L${t+n},${e+r-d}`,S+=Qs(m,d,t+n,e+r,"br"),S+=` L${t+p},${e+r}`,S+=Qs(h,p,t,e+r,"bl"),S+=` L${t},${e+c}`,S+=Qs(f,c,t,e,"tl"),S+=" Z",S}function Qs(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 td(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 l=(o.slantPercent??20)/100*r;return`M${e+l},${n} L${e+r},${n} L${e+r-l},${n+i} L${e},${n+i} Z`}case"trapezoid":{let l=(o.topWidthPercent??70)/100*r,c=(r-l)/2;return`M${e+c},${n} L${e+c+l},${n} L${e+r},${n+i} L${e},${n+i} Z`}case"terminator":{let l=i/2;return`M${e+l},${n} L${e+r-l},${n} A${l},${l} 0 0 1 ${e+r-l},${n+i} L${e+l},${n+i} A${l},${l} 0 0 1 ${e+l},${n} Z`}case"cylinder":{let l=r/2,c=Math.min((o.capHeightPercent??15)/100*i,i/2);return`M${e},${n+c} A${l},${c} 0 0 1 ${e+r},${n+c} A${l},${c} 0 0 1 ${e},${n+c} L${e},${n+i-c} A${l},${c} 0 0 0 ${e+r},${n+i-c} L${e+r},${n+c} M${s-l},${n+c} A${l},${c} 0 0 0 ${s+l},${n+c}`}case"document-shape":{let l=(o.waveAmplitudePercent??15)/100*i;return`M${e},${n} L${e+r},${n} L${e+r},${n+i} C${e+r*.75},${n+i-l*2} ${s+r*.25},${n+i+l} ${s},${n+i} C${s-r*.25},${n+i-l} ${e+r*.25},${n+i+l*.5} ${e},${n+i} Z`}}}function Cr(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 ek(t,n,r);case"BASIS":case"basis":return tk(t,n);case"ARC":case"arc":return i&&i.length>0?Zw(t,n,i):Ro(t,n,"CUBIC");case"LINEAR":case"linear":return Ro(t,n,"LINEAR");case"QUADRATIC":case"quadratic":return Ro(t,n,"QUADRATIC");case"CUBIC":case"cubic":return Ro(t,n,"CUBIC");default:return Ro(t,n)}}function Zw(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 c=t[i],u=n?.[s]??o;r+=` A ${u.rx} ${u.ry} ${u.rotation} ${u.largeArc?1:0} ${u.sweep?1:0} ${c.x} ${c.y} Z`}r+=` M ${a.x} ${a.y}`,i=s+1;continue}let l=n?.[s]??o;r+=` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.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 Ro(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 l=t[a],c=t[a+1];if(c.isSubpathStart){if(e&&a-i>=1){let d=t[i];r+=Vc(l,d,d.segmentType,o,s,n),r+=" Z"}r+=` M ${c.x} ${c.y}`,i=a+1,o=null,s=null;continue}r+=Vc(l,c,c.segmentType,o,s,n);let u=Qw(c.segmentType??n,l,c);o=u,u==="quad"?s=l.handleOut??null:s=null}if(e&&t.length-i>1){let a=t[t.length-1],l=t[i],c=(l.segmentType??n??(a.handleOut||l.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(r+=Vc(a,l,l.segmentType,o,s,n)),r+=" Z"}return r}var Jw=.001;function vi(t,e){return Math.abs(t-e)<Jw}function Qw(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 Vc(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")&&vi(t.y,e.y)?` H ${e.x}`:(s==="VERTICAL"||s==="LINEAR")&&vi(t.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(s==="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(s==="QUADRATIC"||s==="SMOOTH_QUADRATIC"){let c=t.handleOut??{x:(t.x+e.x)/2,y:(t.y+e.y)/2};return r==="quad"&&i&&vi(c.x,2*t.x-i.x)&&vi(c.y,2*t.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let a=t.handleOut??{x:t.x,y:t.y},l=e.handleIn??{x:e.x,y:e.y};return r==="cubic"&&t.handleIn&&t.handleOut&&vi(t.handleOut.x,2*t.x-t.handleIn.x)&&vi(t.handleOut.y,2*t.y-t.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 ek(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 l=i[a],c=i[a+1],u=i[a+2],d=i[a+3],p=Math.hypot(u.x-c.x,u.y-c.y),f=Math.hypot(c.x-l.x,c.y-l.y),g=Math.hypot(d.x-u.x,d.y-u.y),m=Math.pow(f,r),h=Math.pow(p,r),b=Math.pow(g,r),S=Math.pow(f,2*r),v=Math.pow(p,2*r),I=Math.pow(g,2*r),x,P,T,k;f<1e-8?(x=c.x,P=c.y):(x=(S*u.x-v*l.x+(2*S+3*m*h+v)*c.x)/(3*m*(m+h)),P=(S*u.y-v*l.y+(2*S+3*m*h+v)*c.y)/(3*m*(m+h))),g<1e-8?(T=u.x,k=u.y):(T=(I*c.x-v*d.x+(2*I+3*b*h+v)*u.x)/(3*b*(b+h)),k=(I*c.y-v*d.y+(2*I+3*b*h+v)*u.y)/(3*b*(b+h))),o+=` C ${x} ${P} ${T} ${k} ${u.x} ${u.y}`}return e&&(o+=" Z"),o}function tk(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 l=0;l<n;l++){let c=t[(l+1)%n],u=t[(l+2)%n],d=t[(l+3)%n];a+=jc(c,u,d)}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+=jc(r[o],r[o+1],r[o+2]);return i+=jc(r[n-2],r[n-1],r[n-1]),i+=` L ${r[n-1].x} ${r[n-1].y}`,i}function jc(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 nd(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 nk={bearing:!0,catmullRom:!0},uh={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:[]},rk=new Set(Object.keys(uh));function ik(t){return t===32||t===9||t===10||t===12||t===13}function na(t){return t>=48&&t<=57}function ph(t){return t>=65&&t<=90||t>=97&&t<=122}var id=class{constructor(e){this.source=e}source;position=0;get length(){return this.source.length}skipWhitespace(){for(;this.position<this.length&&ik(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&&na(this.source.charCodeAt(n));)n++,i++;if(this.source.charCodeAt(n)===46){let a=n;n++;let l=0;for(;n<this.length&&na(this.source.charCodeAt(n));)n++,l++;if(l===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 l=this.source.charCodeAt(n);(l===43||l===45)&&n++;let c=0;for(;n<this.length&&na(this.source.charCodeAt(n));)n++,c++;c===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 fh(t,e){return rk.has(t)||(t==="B"||t==="b")&&e.bearing?!0:(t==="R"||t==="r")&&e.catmullRom===!0}function ok(t){if(!t)return!1;let e=t.charCodeAt(0);return na(e)||t==="+"||t==="-"||t==="."||t===","}function sk(t,e,n,r){return{code:t,offset:e.position,command:n,message:r}}function rd(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 ta(t,e){if(t.skipWhitespace(),t.position>=t.length)return"end";let n=t.source[t.position];return fh(n,e)?"command":ok(n)?"parameter":ph(n.charCodeAt(0))?"unsupported-command":"unexpected"}function Qn(t,e={}){let n=new id(t),r=e.extensions??{},i=[],o=!0,s=(a,l,c)=>({commands:i,error:sk(a,n,l,c)});for(;;){if(n.skipWhitespace(),n.position>=n.length)return{commands:i,error:null};let a=n.position,l=n.source[n.position];if(!fh(l,r)){let f=ph(l.charCodeAt(0))?"unsupported-command":"unexpected-content";return s(f,null,`Unexpected path content '${l}'`)}n.position++;let c=l;if(o&&c!=="M"&&c!=="m")return s("initial-moveto-required",c,"Path data must begin with moveto");if(o=!1,c==="Z"||c==="z"){i.push({type:c,params:[],offset:a});let f=ta(n,r);if(f==="end"||f==="command")continue;return s(f==="unsupported-command"?"unsupported-command":"unexpected-content",c,"Closepath cannot be implicitly repeated")}if(c==="B"||c==="b"){let f=[];for(;;){let g=rd(n,["number"],f.length>0);if(!g){if(f.length===0)return s("missing-parameter",c,"Bearing requires at least one angle");break}f.push(g[0]);let m=ta(n,r);if(m!=="parameter"){if(m==="end"||m==="command")break;return i.push({type:c,params:f,offset:a}),s(m==="unsupported-command"?"unsupported-command":"unexpected-content",c,"Invalid bearing command content")}}i.push({type:c,params:f,offset:a});continue}if(c==="R"||c==="r"){let f=[];for(;;){let g=rd(n,["number","number"],f.length>0);if(!g)return s("missing-parameter",c,"Catmull-Rom requires complete coordinate pairs");f.push(...g);let m=ta(n,r);if(m!=="parameter"){if(m==="end"||m==="command")break;return s(m==="unsupported-command"?"unsupported-command":"unexpected-content",c,"Invalid Catmull-Rom command content")}}if(f.length<6)return s("missing-parameter",c,`R/r: needs at least 3 coordinate pairs, got ${f.length/2}`);i.push({type:c,params:f,offset:a});continue}let d=uh[c],p=0;for(;;){let f=rd(n,d,p>0);if(!f)return s("missing-parameter",c,`Incomplete ${c} command parameters`);let g=p>0&&(c==="M"||c==="m")?c==="M"?"L":"l":c;i.push({type:g,params:f,offset:a}),p++;let m=ta(n,r);if(m==="end"||m==="command")break;if(m!=="parameter")return s(m==="unsupported-command"?"unsupported-command":"unexpected-content",c,`Unexpected content in ${c} command`)}}}function od(t){return t.map(e=>e.params.length===0?e.type:`${e.type} ${e.params.join(" ")}`).join(" ")}function ak(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 lk(t,e,n){let r=Qn(t);return r.error?null:od(r.commands.map((i,o)=>{let s=ak(i,e,n);return o===0&&i.type==="m"&&(s[0]+=e,s[1]+=n),{...i,params:s}}))}function ck(t,e){let n=Qn(t);if(n.error)return null;let[r,i,o,s,a,l]=e,c=[],u=0,d=0,p=0,f=0,g=(h,b)=>[r*h+o*b+a,i*h+s*b+l],m=(h,b,S)=>{c.push({type:h,params:b,offset:S})};for(let h of n.commands){let b=h.type===h.type.toLowerCase(),S=h.type.toUpperCase(),v=h.params,I=u,x=d;if(S==="A")return null;if(S==="Z"){m("Z",[],h.offset),u=p,d=f;continue}if(S==="H"){u=b?u+v[0]:v[0],m("L",g(u,d),h.offset);continue}if(S==="V"){d=b?d+v[0]:v[0],m("L",g(u,d),h.offset);continue}let P=T=>[(b?I:0)+v[T],(b?x:0)+v[T+1]];switch(S){case"M":case"L":case"T":{let T=P(0);u=T[0],d=T[1],S==="M"&&(p=u,f=d),m(S,g(u,d),h.offset);break}case"C":{let T=g(...P(0)),k=g(...P(2)),w=P(4);u=w[0],d=w[1],m("C",[...T,...k,...g(...w)],h.offset);break}case"S":case"Q":{let T=g(...P(0)),k=P(2);u=k[0],d=k[1],m(S,[...T,...g(...k)],h.offset);break}}}return od(c)}var xi=Math.PI*2;function dk(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 uk(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 pk(t,e,n,r){let i=1-r;return i*i*t+2*i*r*e+r*r*n}function sd(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),l=e-t,c=[];dk(s,a,l,c);for(let u of c){let d=uk(t,e,n,r,u);d<i&&(i=d),d>o&&(o=d)}return{min:i,max:o}}function ad(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=pk(t,e,n,s);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function mh(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 yh(t,e,n,r,i,o,s,a,l){if(t===a&&e===l||n===0||r===0)return null;let c=Math.abs(n),u=Math.abs(r),d=i%360*Math.PI/180,p=Math.cos(d),f=Math.sin(d),g=(t-a)/2,m=(e-l)/2,h=p*g+f*m,b=-f*g+p*m,S=h*h,v=b*b,I=c*c,x=u*u,P=S/I+v/x;if(P>1){let F=Math.sqrt(P);c*=F,u*=F,I=c*c,x=u*u}let T=I*v+x*S;if(T===0)return null;let k=(I*x-T)/T;k<0&&(k=0);let w=Math.sqrt(k);o===s&&(w=-w);let $=w*(c*b/u),R=w*(-(u*h)/c),C=p*$-f*R+(t+a)/2,A=f*$+p*R+(e+l)/2,D=(h-$)/c,_=(b-R)/u,O=(-h-$)/c,L=(-b-R)/u,re=mh(1,0,D,_),ee=mh(D,_,O,L);return!s&&ee>0?ee-=xi:s&&ee<0&&(ee+=xi),{cx:C,cy:A,rx:c,ry:u,phi:d,theta1:re,deltaTheta:ee}}function fk(t,e){let n=Math.cos(t.phi),r=Math.sin(t.phi),i=e?Be(e,{x:t.cx,y:t.cy}):{x:t.cx,y:t.cy},o=e?Lc(e,{x:t.rx*n,y:t.rx*r}):{x:t.rx*n,y:t.rx*r},s=e?Lc(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 mk(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 gk(t,e,n){if(n>=0){let i=(t-e)%xi;return i<0&&(i+=xi),i<=n}let r=(e-t)%xi;return r<0&&(r+=xi),r<=-n}function Sh(t,e,n,r,i,o,s,a,l,c){let u=c?Be(c,{x:t,y:e}):{x:t,y:e},d=c?Be(c,{x:a,y:l}):{x:a,y:l},p={minX:Math.min(u.x,d.x),minY:Math.min(u.y,d.y),maxX:Math.max(u.x,d.x),maxY:Math.max(u.y,d.y)},f=yh(t,e,n,r,i,o,s,a,l);if(!f)return p;let g=fk(f,c),m=Math.atan2(g.vx,g.ux),h=Math.atan2(g.vy,g.uy),b=[m,m+Math.PI,h,h+Math.PI];for(let S of b){if(!gk(S,f.theta1,f.deltaTheta))continue;let v=mk(g,S);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 ld=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 ra(t,e,n,r){let i=r?Be(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 cd(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 gh(t,e,n,r,i,o,s,a,l,c){let u=c?Be(c,{x:e,y:n}):{x:e,y:n},d=c?Be(c,{x:r,y:i}):{x:r,y:i},p=c?Be(c,{x:o,y:s}):{x:o,y:s},f=c?Be(c,{x:a,y:l}):{x:a,y:l},g=sd(u.x,d.x,p.x,f.x),m=sd(u.y,d.y,p.y,f.y);cd(t,{minX:g.min,maxX:g.max,minY:m.min,maxY:m.max})}function hh(t,e,n,r,i,o,s,a){let l=a?Be(a,{x:e,y:n}):{x:e,y:n},c=a?Be(a,{x:r,y:i}):{x:r,y:i},u=a?Be(a,{x:o,y:s}):{x:o,y:s},d=ad(l.x,c.x,u.x),p=ad(l.y,c.y,u.y);cd(t,{minX:d.min,maxX:d.max,minY:p.min,maxY:p.max})}function sn(t,e){if(!t)return null;let n=Qn(t),r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},i=0,o=0,s=0,a=0,l=0,c=0,u=null,d="",p=()=>r.any?{minX:r.minX,minY:r.minY,maxX:r.maxX,maxY:r.maxY}:null;for(let f of n.commands){d=f.type;let g=new ld(f.params),m=d>="a"&&d<="z";switch(d){case"M":case"m":{let h=g.readNumber(),b=g.readNumber();if(h===null||b===null)return p();i=m?i+h:h,o=m?o+b:b,s=i,a=o,ra(r,i,o,e),u=null,d=m?"l":"L";break}case"L":case"l":{let h=g.readNumber(),b=g.readNumber();if(h===null||b===null)return p();i=m?i+h:h,o=m?o+b:b,ra(r,i,o,e),u=null;break}case"H":case"h":{let h=g.readNumber();if(h===null)return p();i=m?i+h:h,ra(r,i,o,e),u=null;break}case"V":case"v":{let h=g.readNumber();if(h===null)return p();o=m?o+h:h,ra(r,i,o,e),u=null;break}case"C":case"c":{let h=g.readNumber(),b=g.readNumber(),S=g.readNumber(),v=g.readNumber(),I=g.readNumber(),x=g.readNumber();if(h===null||b===null||S===null||v===null||I===null||x===null)return p();let P=m?i+h:h,T=m?o+b:b,k=m?i+S:S,w=m?o+v:v,$=m?i+I:I,R=m?o+x:x;gh(r,i,o,P,T,k,w,$,R,e),l=k,c=w,u="cubic",i=$,o=R;break}case"S":case"s":{let h=g.readNumber(),b=g.readNumber(),S=g.readNumber(),v=g.readNumber();if(h===null||b===null||S===null||v===null)return p();let I=u==="cubic"?2*i-l:i,x=u==="cubic"?2*o-c:o,P=m?i+h:h,T=m?o+b:b,k=m?i+S:S,w=m?o+v:v;gh(r,i,o,I,x,P,T,k,w,e),l=P,c=T,u="cubic",i=k,o=w;break}case"Q":case"q":{let h=g.readNumber(),b=g.readNumber(),S=g.readNumber(),v=g.readNumber();if(h===null||b===null||S===null||v===null)return p();let I=m?i+h:h,x=m?o+b:b,P=m?i+S:S,T=m?o+v:v;hh(r,i,o,I,x,P,T,e),l=I,c=x,u="quad",i=P,o=T;break}case"T":case"t":{let h=g.readNumber(),b=g.readNumber();if(h===null||b===null)return p();let S=u==="quad"?2*i-l:i,v=u==="quad"?2*o-c:o,I=m?i+h:h,x=m?o+b:b;hh(r,i,o,S,v,I,x,e),l=S,c=v,u="quad",i=I,o=x;break}case"A":case"a":{let h=g.readNumber(),b=g.readNumber(),S=g.readNumber(),v=g.readFlag(),I=g.readFlag(),x=g.readNumber(),P=g.readNumber();if(h===null||b===null||S===null||v===null||I===null||x===null||P===null)return p();let T=m?i+x:x,k=m?o+P:P;cd(r,Sh(i,o,h,b,S,v,I,T,k,e)),i=T,o=k,u=null;break}case"Z":case"z":{i=s,o=a,u=null;break}default:return p()}}return p()}function hk(t,e,n=!1,r=.5,i,o){return t.length===0?null:sn(Cr(t,e,n,r,i),o)}function bh(t){return t.replace(/[^a-zA-Z0-9_-]/g,"_")}function yk(t){let e=t.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function dd(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(dd).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${dd(n)}`).join(",")}}`}function Sk(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 vh(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=vh(s,e,n)),i!==void 0||o.children!==r.state.children?{...r,state:o}:r})}function Ii(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??{},l=Object.entries(a),c=o;if(l.length>0){let f=Sk(o),g=new Set;for(let[m]of l){let h=f.get(m)??0;h===1?g.add(m):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 ${m} is ambiguous in ${t.id}.`:`Symbol instance ${e.id} override target ${m} is absent from ${t.id}.`})}c=vh(o,a,g)}let u=i!==""||l.length>0,d=l.length>0?`${t.id}--ovr-${e.id}`:i?`${t.id}--${bh(i)}`:t.id,p=`${t.id}\0${i}\0${dd(a)}`;return{shapes:c,requestedVariantKey:n,effectiveVariantKey:i,candidateTargetId:d,materializationKey:p,materialized:u,diagnostics:s}}function To(t,e=!1){let n=t.state.symbolId??"",r=t.state.variantKey??"";return e||yk(t)?`${n}--ovr-${t.id}`:r?`${n}--${bh(r)}`:n}function bk(t,e){return[...Ii(t,e).shapes]}function me(t,e,n){return Object.freeze({type:t,renderer:e,resolve:n})}function vk(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 xk(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 xh(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,l=e.cornerRadius??0,c=e.rx,u=e.ry,d=c!==void 0&&c>=0?c:void 0,p=u!==void 0&&u>=0?u:void 0,f=Math.max(0,l),g=d??p??f,m=d??g,h=p??g,b=Math.min(Math.max(0,m),Math.max(0,s)/2),S=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=ed(r,i,s,a,l,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:b,ry:S,pathData:x,defaultPivot:{x:r+s/2,y:i+a/2}}}function Ik(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 wk(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 kk(t){let e=t.state,n=e.pathPoints??[],r=Cr(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 Rk(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 ia(t,e,n,r){let i=t.state,o=i.x??0,s=i.y??0,a=i.width??n,l=i.height??r;return{kind:"positioning-rect",shapeType:t.type,role:e,x:o,y:s,width:a,height:l,defaultPivot:{x:o+a/2,y:s+l/2}}}function qt(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 wi(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:td(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 oa(t,e){return{kind:"container",shapeType:t.type,role:e,boundsPolicy:"children",defaultPivot:null}}function Tk(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 Pk(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 Ck(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 $k(t){let e=t.state;return{kind:"symbol-instance",shapeType:"symbol-instance",symbolId:e.symbolId??"",targetId:To(t),x:e.x??0,y:e.y??0,width:e.width??100,height:e.height??100,boundsPolicy:"symbol",defaultPivot:null}}var wh=Object.freeze({rectangle:me("rectangle","rectangle",xh),square:me("square","rectangle",xh),circle:me("circle","circle",vk),ellipse:me("ellipse","ellipse",xk),line:me("line","line",Ik),text:me("text","text",wk),image:me("image","image",t=>ia(t,"image",100,100)),path:me("path","path",kk),polyline:me("polyline","polyline",Rk),triangle:me("triangle","polygon",t=>qt(t,(e,n)=>gn(ea(3,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),ngon:me("ngon","polygon",t=>qt(t,(e,n)=>gn(ea(e.sides??6,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),star:me("star","polygon",t=>qt(t,(e,n)=>gn(Uc(e.arms??5,n.radius,e.innerRadiusPercent??50,n.shiftAngle),n.cornerRadius,n.radius))),cross:me("cross","polygon",t=>qt(t,(e,n)=>gn(Hc(n.radius,e.armWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),ring:me("ring","polygon",t=>qt(t,(e,n)=>Zc(n.radius,e.innerRadiusPercent??50,n.fillRule),!0)),spiral:me("spiral","polygon",t=>qt(t,(e,n)=>Jc(n.radius,e.turns??3,e.thicknessPercent??20,e.spiralDirection??1,n.shiftAngle))),gear:me("gear","polygon",t=>qt(t,(e,n)=>Qc(e.teeth??8,n.radius,e.toothDepthPercent??30,n.cornerRadius,e.holeRadiusPercent??0,n.fillRule,n.shiftAngle),!0)),arrow:me("arrow","polygon",t=>qt(t,(e,n)=>gn(Wc(n.radius,e.headWidthPercent??100,e.headLengthPercent??30,e.shaftWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),"symbol-instance":me("symbol-instance","symbol-instance",$k),group:me("group","container",t=>oa(t,"group")),container:me("container","container",t=>oa(t,"group")),cloud:me("cloud","polygon",t=>qt(t,(e,n)=>qc(n.radius,e.cloudBumps??5,e.cloudPuffinessPercent??60,n.shiftAngle))),heart:me("heart","polygon",t=>qt(t,(e,n)=>Yc(n.radius,e.lobeRadiusPercent??50,e.cleftDepthPercent??25,n.shiftAngle))),lightning:me("lightning","polygon",t=>qt(t,(e,n)=>gn(Xc(n.radius,e.boltSegments??3,e.boltJaggednessPercent??40,e.boltWidthPercent??30,n.shiftAngle),n.cornerRadius,n.radius))),speechBubble:me("speechBubble","polygon",t=>qt(t,(e,n)=>gn(Kc(n.radius,e.tailAngleDeg??45,e.tailLengthPercent??40,e.tailWidthPercent??25,n.shiftAngle),n.cornerRadius,n.radius))),diamond:me("diamond","flowchart",t=>wi(t,"diamond")),parallelogram:me("parallelogram","flowchart",t=>wi(t,"parallelogram")),trapezoid:me("trapezoid","flowchart",t=>wi(t,"trapezoid")),terminator:me("terminator","flowchart",t=>wi(t,"terminator")),cylinder:me("cylinder","flowchart",t=>wi(t,"cylinder")),"document-shape":me("document-shape","flowchart",t=>wi(t,"document-shape")),hyperlink:me("hyperlink","hyperlink",t=>oa(t,"hyperlink")),switch:me("switch","switch",t=>oa(t,"switch")),svg:me("svg","svg",Tk),view:me("view","view",Pk),"shape-reference":me("shape-reference","shape-reference",Ck),video:me("video","media",t=>ia(t,"video",320,180)),audio:me("audio","media",t=>ia(t,"audio",320,180)),"foreign-object":me("foreign-object","foreign-object",t=>ia(t,"foreign-object",100,100))}),Ek=Object.freeze(Object.keys(wh));function Ak(){return Ek}function Po(t){return wh[t]}function Zt(t){return Po(t.type)?.resolve(t)??null}function Ih(t,e,n,r){return n<0||r<0?null:{minX:t,minY:e,maxX:t+n,maxY:e+r}}function Nk(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 sa(t,e){let n=Zt(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?sn(n.pathData):Ih(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 sn(n.d,n.placement?_e(n.placement.x,n.placement.y):void 0);case"polyline":return Nk(n.points);case"positioning-rect":return Ih(n.x,n.y,n.width,n.height);case"container":case"embedded-svg":case"view":case"shape-reference":case"symbol-instance":return null}}function ud(t,e){let n=sa(t,e);return n?{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2}:null}var kh=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u,Mk=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function la(t){return(t.match(Mk)??[]).map(Number).filter(Number.isFinite)}function Ok(t){let e=la(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 aa(t,e){let n=la(t),r=la(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 pd(t){return t.additive==="sum"||t.values==null&&t.from==null&&t.to==null&&t.by!=null?"sum":"replace"}function $r(t,e,n="number"){if(n==="points"){let r=a=>Ok(a.trim()),i=pd(t)==="sum",o=e===void 0?void 0:r(e),s=a=>{if(!i||o===void 0)return[...a];let l=a.map(c=>aa(o,c));return l.every(c=>c!==null)?l:null};if(t.values){let a=t.values.split(";").map(l=>l.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),l=aa(a,r(t.by));return l===null?null:s([a,l])}if(t.to!=null&&o!==void 0){let a=r(t.to);if(!i)return[o,a];let l=aa(o,a);return l===null?null:[o,l]}if(t.by!=null&&o!==void 0){let a=aa(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 fd(t){let e=t.dur?.trim();return!e||e==="indefinite"||e==="media"?0:Kn(e)}function er(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=>kh.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 tr(t){return t.keySplines?t.keySplines.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let n=la(e);return[n[0]??0,n[1]??0,n[2]??0,n[3]??0]}):[]}function Rh(t){if(t.repeatCount==="indefinite")return{cycleInfinite:!0};if(t.repeatCount&&kh.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=Kn(t.repeatDur),n=fd(t);if(e>0&&n>0){let r=Math.max(1,Math.ceil(e/n));if(r>1)return{cycleRepeats:r}}}return{}}function Th(t){return t.fill==="freeze"?{}:{fill:"remove"}}function hn(t,e,n,r,i,o){let s=[];for(let a=0;a<t.length&&a<e.length;a++){let l=t[a].trim(),c=o==="color"||o==="path"||o==="points"||o==="numberList"||o==="discrete",u=Number(l),d={time:e[a]*r,value:c||!Number.isFinite(u)?l:u,easing:"linear"};if(a>0&&i==="spline"&&n[a-1]){let p=Dc(...n[a-1]);d.easing=p.easing,p.customBezier&&(d.customBezier=p.customBezier)}else a>0&&i==="discrete"&&(d.easing="steps",d.stepsParams={count:1,position:"jump-end"});s.push(d)}return s}var Dk=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:h|min|s|ms)?$/iu,zk=/^([A-Za-z_][\w.-]*)\.repeat\((\d+)\)\s*([+-]\s*\S+)?$/u,_k=/^([A-Za-z_][\w.-]*)\.(begin|end)\s*([+-]\s*\S+)?$/u,md=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(l=>l.trim()).filter(Boolean),i=r.flatMap(l=>{let c=this.resolveEntry(l);return c!==null&&Number.isFinite(c)?[{entry:l,time:c}]:[]}),o=new Map;for(let l of i)o.set(l.time,l.entry);let a=r.length>1&&e.kind!=="discard"&&e.additive!=="sum"&&o.size>1?[...o.keys()].sort((l,c)=>l-c):i.length>0?[i[0].time]:[null];return Object.freeze(a.map(l=>{let c=Object.freeze({...e.attributes,...l!==null?{begin:`${l}s`}:{}}),u=e.duration;if(e.attributes.values?.split(";").map(p=>p.trim()).filter(Boolean)?.length===1&&l!==null&&e.attributes.end){let p=this.resolveEntry(e.attributes.end.split(";")[0].trim());p!==null&&Number.isFinite(p)&&p>=l&&(u=p-l)}return Object.freeze({...e,attributes:c,duration:u})}))}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(Dk.test(e))return Kn(e);let n=e.match(zk);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(_k);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?Kn(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=Kn(r);Number.isFinite(s)&&s>=0&&(i=o?Math.min(i,s):s)}return i}},yn=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"}}),Fk=Object.freeze({...yn,"font-size":{property:"fontSize",valueType:"number",stateKey:"fontSize"}}),Lk=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function $h(t){return(t.match(Lk)??[]).map(Number).filter(Number.isFinite)}function gd(t,e){let n=t?.[e];if(n!=null)return Array.isArray(n)?n.join(" "):String(n)}function Eh(t){switch(t.property){case"visibility":return"visible";case"display":return"inline";case"opacity":case"fillOpacity":case"strokeOpacity":return"1";default:return}}function an(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:Kn(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 Er(t){let e=Rh(t.attributes),n=an(t);return{enabled:!0,cycleBehavior:"restart",...t.duration>0?{cycleDuration:t.duration}:{},...t.additive==="sum"?{additive:"sum"}:{},...e,...Th(t.attributes),...n.beginTrigger?{beginTrigger:n.beginTrigger}:{}}}function ki(t,e){return t.map(n=>({...n,time:n.time+e}))}function Ah(t,e,n,r,i){let o=t.attributeName?.toLowerCase();if(!o)return null;let s=i?.projection??yn[o]??{property:o,valueType:"discrete",stateKey:o},a=t.attributes,l=i?.underlying??gd(n,s.stateKey)??Eh(s),c=$r(a,l,s.valueType);if(!c||c.length===0)return null;let u=t.kind==="set"?"discrete":a.calcMode??"linear",d=t.duration,p=an(t);if(t.kind==="set"){let h=[{time:p.offset,value:c.at(-1),easing:"linear"}];return d>0&&t.fill==="remove"&&l!==void 0&&h.push({time:p.offset+d,value:l,easing:"linear"}),{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...d>0?{cycleDuration:d}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"set",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:h}}if(c.length===1){let h=hn(c,[0],[],d,"discrete",s.valueType)[0]?.value;if(h===void 0)return null;let b=[{time:p.offset,value:h,easing:"linear"}];if(d>0&&t.fill==="remove"&&l!==void 0){let S=hn([l],[0],[],d,"discrete",s.valueType)[0]?.value;S!==void 0&&b.push({time:p.offset+d,value:S,easing:"linear"})}return{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...d>0?{cycleDuration:d}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:b}}let f=er(a,c.length,u),g=tr(a),m=ki(hn(c,f,g,d,u,s.valueType),p.offset);return m.length<2?null:{id:`svg-animation-${r}`,shapeId:e,property:s.property,...Er(t),...u!=="linear"?{calcMode:u}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:m}}var Bk=Object.freeze({"stop-color":{suffix:"Color",valueType:"color"},"stop-opacity":{suffix:"Opacity",valueType:"number"},offset:{suffix:"Offset",valueType:"number"}});function Gk(t,e){return e==="stop-color"?t.color:String(e==="stop-opacity"?t.opacity:t.offset)}function Vk(t,e,n,r){let i=t.attributeName?.toLowerCase(),o=t.targetSourceNodeId;if(!e||!i||!o)return[];let s=Bk[i];if(!s||t.kind!=="animate"&&t.kind!=="set")return[];let a=[],l=new Set;for(let c of e.candidates)c.stops.forEach((u,d)=>{if(!(u.sourceNodeId!==o&&u.correspondingSourceNodeId!==o)){for(let p of e.bindings)if(!(p.gradientSourceNodeId!==c.sourceNodeId||p.propertyName!=="fill"&&p.propertyName!=="stroke"))for(let f of Nh(p.occurrenceId,n)){let g=`${p.propertyName}GradientStop${d}${s.suffix}`,m=`${f.shapeId}|${g}`;if(l.has(m))continue;l.add(m);let h=Ah(t,f.shapeId,f.state,r+a.length,{projection:{property:g,valueType:s.valueType,stateKey:g},underlying:Gk(u,i)});h&&a.push(h)}}});return a}function Nh(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 jk=new Set(["clip-path","display","fill","mask","opacity","visibility"]);function Uk(t,e){if(t.targetStatus!=="resolved"||!t.targetOccurrenceId)return[];let n=Nh(t.targetOccurrenceId,e);if(!n.some(i=>i.shapeType==="group")||t.kind==="animateTransform"||t.kind==="animateMotion"||t.kind==="discard"||jk.has(t.attributeName?.toLowerCase()??""))return n;let r=e.descendantShapeBindingsForOccurrence?.(t.targetOccurrenceId);return r&&r.length>0?r:n}function Hk(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=$r(t.attributes,void 0,"numberList");if(!i||i.length<2)return[];let o=i.map($h);if(o.some(u=>u.length<4))return[];let s=t.attributes.calcMode??"linear",a=er(t.attributes,o.length,s),l=tr(t.attributes),c=an(t);return["X","Y","Width","Height"].map((u,d)=>({id:`svg-animation-${n+d}`,shapeId:e.shapeId,property:`${r}${u}`,...Er(t),...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:ki(hn(o.map(p=>String(p[d])),a,l,t.duration,s,"number"),c.offset)}))}var Wk=Object.freeze([{cssProperty:"fill",projection:yn.fill},{cssProperty:"stroke",projection:yn.stroke},{cssProperty:"stroke-width",projection:yn["stroke-width"]},{cssProperty:"fill-opacity",projection:yn["fill-opacity"]},{cssProperty:"stroke-opacity",projection:yn["stroke-opacity"]},{cssProperty:"opacity",projection:yn.opacity},{cssProperty:"visibility",projection:yn.visibility},{cssProperty:"display",projection:yn.display}]);function Ph(t,e){if(e==="number"){let n=Number.parseFloat(t);if(Number.isFinite(n))return String(n)}return t.trim().toLowerCase()}function Kk(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]:$r(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=er(t.attributes,i.length,"discrete"),a=tr(t.attributes),l=an(t),c=i.map(d=>n.stylesheetValuesWithClass(t.targetOccurrenceId,d)),u=[];for(let{cssProperty:d,projection:p}of Wk){let f=gd(e.state,p.stateKey)??Eh(p)??"",g=c.map(h=>h[d]??f),m=Ph(f,p.valueType);g.every(h=>Ph(h,p.valueType)===m)||u.push({id:`svg-animation-${r+u.length}`,shapeId:e.shapeId,property:p.property,...Er(t),calcMode:"discrete",sourceSmilElement:t.kind==="set"?"set":"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:ki(hn(g,s,a,o,"discrete",p.valueType),l.offset)})}return u}function Xk(t,e,n){let r=t.attributes.type?.trim().toLowerCase();if(!r)return[];let i=t.attributes,o=$r(i,void 0,"numberList");if(!o||o.length<2)return[];let s=i.calcMode??"linear",a=er(i,o.length,s),l=tr(i),c=an(t),u=Er(t),d=o.map($h),p=(f,g,m,h)=>{let b=hn(o.map((S,v)=>{let I=g(d[v]);return Array.isArray(I)?I.join(" "):String(I)}),a,l,t.duration,s,f==="transformMatrix"?"numberList":"number").map((S,v)=>({...S,time:S.time+c.offset,value:f==="transformMatrix"?d[v].slice(0,6):S.value}));return{id:`svg-animation-${n+m}`,shapeId:e,property:f,...u,additive:t.additive,...t.additive==="replace"&&t.replacesCarrierBase?{replacesCarrierBase:!0}:{},...h?{transformOrigin:h}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:b}};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=d.find(g=>g.length>=3);return[p("rotation",g=>g[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"&&d.every(f=>f.length>=6)?[p("transformMatrix",f=>f.slice(0,6),0)]:[]}function Mh(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=er(t.attributes,o.length,s),l=tr(t.attributes),c=an(t),u=t.attributes.rotate?.trim(),d=u===void 0?Number.NaN:Number(u),p=t.motionPathSourceNodeId?n.shapeIdForSourceNode(t.motionPathSourceNodeId):null;return{id:`svg-animation-${r}`,shapeId:e,property:"pathMotion",...Er(t),motionPath:t.motionPathData,...p?{motionPathRef:{shapeId:p,mode:"curveTemplate"}}:{},...u==="auto"||u==="auto-reverse"?{motionRotate:u}:Number.isFinite(d)?{motionRotate:d}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...s!=="linear"&&s!=="paced"?{calcMode:s}:{},keyframes:ki(hn(o.map(String),a,l,t.duration,s,"number"),c.offset)}}var Yk=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"]),qk=new Set(["fill","stroke","stop-color","flood-color","lighting-color"]);function Co(t){return{shapeId:t.shapeId,domTargetSelector:t.selector}}function Zk(t,e,n,r){let i=Mh(t,e.shapeId,n,r);return i?{...i,property:"domTransformStack",additive:t.additive,...Co(e),transformFunction:"translate",transformStackIndex:0,transformBaseValue:e.baseTransform}:null}function Jk(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=$r(t.attributes,void 0,"discrete");if(!o||o.length<2||t.duration<=0)return null;let s=t.attributes.calcMode??"linear",a=er(t.attributes,o.length,s),l=tr(t.attributes),c=an(t);return{id:`svg-animation-${n}`,...Co(e),property:"domTransformStack",...Er(t),additive:t.additive,...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animateTransform",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},transformFunction:i,transformStackIndex:r,transformBaseValue:e.baseTransform,keyframes:ki(hn(o,a,l,t.duration,s,"discrete"),c.offset)}}function Qk(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":Yk.has(i)?"number":qk.has(i)?"color":"string";if(t.kind==="set"){let m=t.attributes.to?.trim();if(m===void 0)return null;let h=an(t),b=[{time:h.offset,value:m,easing:"linear"}];return t.duration>0&&t.fill==="remove"&&b.push({time:h.offset+t.duration,value:o,easing:"linear"}),{id:`svg-animation-${n}`,...Co(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:b}}let l=s||a==="string"?"discrete":a,c=$r(t.attributes,o,l);if(!c||c.length===0||t.duration<=0)return null;let u=s?"discrete":t.attributes.calcMode??"linear",d=er(t.attributes,c.length,u),p=tr(t.attributes),f=an(t),g=s?i==="display"?"domDisplay":"domVisibility":"domAttribute";return{id:`svg-animation-${n}`,...Co(e),property:g,...Er(t),calcMode:u,sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...g==="domAttribute"?{domAttribute:r,domAttributeValueType:a}:{},transformBaseValue:o,keyframes:ki(hn(c,d,p,t.duration,u,l),f.offset)}}function e0(t,e,n,r,i){if(t.kind==="animateMotion")return Zk(t,e,n,r);if(t.kind==="animateTransform")return Jk(t,e,r,i);if(t.kind==="discard"){let o=an(t);return{id:`svg-animation-${r}`,...Co(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 Qk(t,e,r)}function t0(t,e,n,r,i){let o=Uk(t,n);if(o.length===0&&t.targetOccurrenceId){let a=n.domTargetForOccurrence?.(t.targetOccurrenceId),l=a?e0(t,a,n,r,i):null;return l?[l]:[]}let s=[];for(let a of o){if(t.kind==="animateTransform"){s.push(...Xk(t,a.shapeId,r+s.length));continue}if(t.kind==="animateMotion"){let d=Mh(t,a.shapeId,n,r+s.length);d&&s.push(d);continue}if(t.kind==="discard"){let d=an(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:d.offset,value:1,easing:"linear"}]});continue}let l=Hk(t,a,r+s.length);if(l.length>0){s.push(...l);continue}let c=Kk(t,a,e,r+s.length);if(c.length>0){s.push(...c);continue}let u=Ah(t,a.shapeId,a.state,r+s.length);u&&s.push(u)}return s}function Oh(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}:{},...Fg(t)}}var n0=Object.freeze([["translateX",0],["translateY",0],["scaleX",1],["scaleY",1],["rotation",0],["skewX",0],["skewY",0]]);function r0(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId);if(!i)return[];let o=e.value(t.occurrenceId,"transform-box")??"view-box",s=n.cssTransformContextForOccurrence?.(t.occurrenceId,o),a=n.shapeBindingsForOccurrence?.(t.occurrenceId)[0],l=(o==="fill-box"||o==="content-box")&&a?.state?sa({id:a.shapeId,type:a.shapeType,state:a.state}):null,c={...l?{boxX:l.minX,boxY:l.minY,boxWidth:l.maxX-l.minX,boxHeight:l.maxY-l.minY}:{},...s??{}},u=t.keyframes.stops.flatMap(v=>{let I=v.properties.transform??v.properties["-webkit-transform"]??v.properties["-moz-transform"];return I===void 0?[]:[{offset:v.offset,raw:I,timing:v.properties["animation-timing-function"]}]});if(u.length===0)return[];let d=e.value(t.occurrenceId,"transform")??"none";u[0].offset>0&&u.unshift({offset:0,raw:d,timing:void 0}),u.at(-1).offset<1&&u.push({offset:1,raw:d,timing:void 0});let f=e.style(t.occurrenceId)?.cascadedValues["transform-origin"]?e.value(t.occurrenceId,"transform-origin")??"0 0":"0 0",g=oh(f,c),m=ch(u.map(({offset:v,raw:I})=>({offset:v,transform:I})),{...c,...g?{transformOrigin:g}:{},retainPureRotationOrigin:!0,progressForInterval:(v,I)=>{let x=u[v]?.timing;return Pg(x?hi(x):t.animation.parsedEasing,I)}});if(m.status!=="projected")return[];let h=m.stops.map(v=>({offset:v.offset,channels:v})),b=new Set(m.channels),S=[];for(let[v,I]of n0){if(!b.has(v))continue;let x=h.flatMap(({offset:P,channels:T})=>{if(!T)return[];let k=T[v]??I,w=u.findLastIndex($=>$.offset<P);return[Dh(P,k,t.animation,m.sampled?"linear":u[Math.max(0,w)]?.timing)]});x.length<2||S.push({id:`svg-animation-${r+S.length}`,shapeId:i,property:v,...Oh(t.animation),additive:v==="translateX"||v==="translateY"?"sum":"replace",replacesCarrierBase:!0,...v==="rotation"&&g&&(m.pureRotation||g.x===0&&g.y===0&&(g.z??0)===0)?{transformOrigin:{x:g.x,y:g.y}}:{},template:{name:t.animation.name},keyframes:x})}return S}function Ch(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 Dh(t,e,n,r){let i={time:t*n.duration+n.delay,value:e,easing:n.easing},o=r?hi(r):n.parsedEasing;return o&&Tg(i,o),i}function i0(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 o0(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId);if(!i)return[];let o=n.shapeStateForOccurrence(t.occurrenceId),s=new Set(t.keyframes.stops.flatMap(l=>Object.keys(l.properties)));s.delete("animation-timing-function"),s.delete("transform"),s.delete("-webkit-transform"),s.delete("-moz-transform");let a=[];for(let l of s){let c=Fk[l];if(!c)continue;let u=t.keyframes.stops.flatMap(p=>{let f=p.properties[l];if(f===void 0)return[];let g=Ch(f,c.valueType);return g===null?[]:[{offset:p.offset,value:g,timing:p.properties["animation-timing-function"]}]}),d=e.value(t.occurrenceId,l)??gd(o,c.stateKey);i0(u,()=>{if(d==null)return null;let p=Ch(d,c.valueType);return p===null?null:{offset:0,value:p,timing:void 0}}),!(u.length<2)&&a.push({id:`svg-animation-${r+a.length}`,shapeId:i,property:c.property,...Oh(t.animation),template:{name:t.animation.name},keyframes:u.map((p,f)=>Dh(p.offset,p.value,t.animation,f===0?void 0:u[f-1].timing))})}return a}function s0(t){let e=Math.max(0,...t.keyframes.map(n=>n.time));return Ag(t)??e}function zh(t,e,n,r){let i=new md(t.smil),o=[],s=[],a=[],l=[],c=[],u=new Map,d=new Map;for(let m of t.smil){let h=0;if(m.kind==="animateTransform"&&m.targetOccurrenceId){let b=`${m.targetOccurrenceId}|${m.sourceNodeId}`,S=u.get(b);S!==void 0?h=S:(h=d.get(m.targetOccurrenceId)??0,u.set(b,h),d.set(m.targetOccurrenceId,h+1))}for(let b of i.activations(m)){let S=Vk(b,r,n,1),v=S.length>0?S:t0(b,e,n,1,h);m.kind==="animateTransform"?o.push(...v):m.kind==="animateMotion"?s.push(...v):m.kind==="set"?l.push(...v):m.kind==="discard"?c.push(...v):a.push(...v)}}let p=[],f=[];for(let m of t.css)p.push(...r0(m,e,n,1)),f.push(...o0(m,e,n,1));let g=[...o,...s,...a,...l,...c,...p,...f].map((m,h)=>({...m,id:`svg-animation-${h+1}`}));return g.length===0?null:{duration:Math.max(...g.map(s0)),loop:g.some(m=>m.cycleInfinite===!0),playbackSpeed:1,tracks:g}}function hd(t,e){return zh(t.animations,t.styles,e,t.gradients)}var a0=["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"],$o=["native-document-open","full-snapshot-restore","svg-document-import","external-svg-paste","internal-clipboard-paste","plugin-svg-fragment","pattern-fragment","vectorized-svg-fragment"];var da=["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"],zn=t=>({status:"supported",by:t}),Eo=(t,e)=>({status:"diagnosed-unsupported",by:t,reason:e}),_h=(t,e)=>({status:"diagnosed-lossy",by:t,reason:e}),nr=t=>({status:"exempt",reason:t}),l0="plugin SVG result diagnostic collector",Sd="pattern fragment diagnostic collector",bd="vectorized SVG result diagnostic collector";function Te(t,e={}){return{"native-document-open":zn("native snapshot parse and canonical restore"),"full-snapshot-restore":zn("canonical full-snapshot restore"),"svg-document-import":zn(t),"external-svg-paste":zn(t),"internal-clipboard-paste":zn("closed clipboard subgraph materializer"),"plugin-svg-fragment":e.plugin??zn("plugin fragment plan materializer"),"pattern-fragment":e.pattern??Eo(Sd,"Pattern fragments retain only capabilities enrolled by the pattern tile contract."),"vectorized-svg-fragment":e.vectorized??Eo(bd,"Vectorized ingestion intentionally accepts path-oriented geometry only.")}}var ca=t=>Eo(l0,t),rr=t=>Eo(Sd,t),Fh=t=>Eo(bd,t),_t=t=>zn(t),yd=t=>zn(t),vd={geometry:Te("SVG shape element parser",{pattern:_t("fragment-scoped pattern shape parser"),vectorized:yd("vectorized path geometry parser")}),containers:Te("SVG structural container planner",{pattern:_t("fragment-scoped pattern hierarchy parser")}),"source-order":Te("source document order index and SceneGraph placement",{pattern:_t("pattern source-order materializer"),vectorized:yd("vectorized path document-order traversal")}),hierarchy:Te("source DOM hierarchy planner and SceneGraph placement",{pattern:_t("fragment-scoped pattern hierarchy materializer")}),"root-viewport-frame":Te("root SVG frame parser and application policy",{plugin:nr("Plugin fragment framing is consumed only for bounds scaling."),pattern:nr("Pattern fragments use the explicit tile width and height as their local frame."),vectorized:_h(bd,"Vectorized source framing is consumed only to scale path geometry into target bounds.")}),"common-presentation":Te("shared SVG presentation parser",{pattern:_t("pattern shape presentation parser"),vectorized:yd("vectorized path presentation parser")}),"conditional-processing":Te("SVG switch and conditional-processing attribute parser",{pattern:_t("pattern shape conditional-processing parser"),vectorized:Fh("Vectorized ingestion does not preserve SVG conditional-processing branches.")}),"authored-attributes":Te("authored-attribute preservation parser",{pattern:_t("pattern authored-attribute preservation parser")}),gradients:Te("gradient parser and library reference materializer",{pattern:_t("fragment-scoped pattern gradient resolver")}),patterns:Te("pattern parser and library reference materializer",{pattern:_t("fragment-scoped nested-pattern resolver")}),filters:Te("filter parser and reference materializer"),"paint-server-definitions":Te("paint-server definition collector and materializer",{pattern:_t("fragment-scoped pattern paint-server collector")}),markers:Te("marker definition parser and reference materializer"),symbols:Te("symbol definition and instance materializer"),"use-and-linked-references":Te("use resolver and stable reference-edge materializer",{pattern:_t("fragment-scoped linked-reference resolver")}),"clip-definitions":Te("clip definition parser and materializer",{pattern:rr("Pattern editing omits document clip definitions.")}),"mask-definitions":Te("mask definition parser and materializer",{pattern:rr("Pattern editing omits document mask definitions.")}),"clip-mask-membership":Te("clip and mask membership materializer",{pattern:rr("Pattern editing omits document clip and mask membership.")}),"smil-animation":Te("SMIL parser and animation-track materializer",{pattern:rr("Pattern editing materializes a static tile without SMIL tracks.")}),"css-animation":Te("CSS keyframe parser and animation-track materializer",{pattern:rr("Pattern editing materializes a static tile without CSS animation tracks.")}),metadata:Te("document metadata parser and field policy",{plugin:ca("Plugin fragments preserve host document metadata."),pattern:nr("Pattern fragments have no document metadata scope."),vectorized:nr("Vectorized fragments have no document metadata scope.")}),scripts:Te("inert script partitioner and document script materializer",{plugin:zn("inert plugin fragment script data materializer"),pattern:rr("Pattern fragments do not execute or adopt scripts."),vectorized:Fh("Vectorized fragments do not execute or adopt scripts.")}),styles:Te("preserved CSS style collector and materializer",{pattern:_t("fragment-scoped pattern style resolver")}),"custom-properties":Te("CSS custom-property collector and materializer",{pattern:_t("fragment-scoped pattern variable resolver")}),views:Te("SVG view parser and SceneGraph materializer",{plugin:ca("Plugin fragments do not alter document navigation views."),pattern:nr("Pattern fragments have no document navigation view scope."),vectorized:nr("Vectorized fragments have no document navigation view scope.")}),"embedded-svg":Te("embedded SVG container parser and materializer",{pattern:_h(Sd,"Pattern editing flattens nested SVG content into the local tile frame.")}),fonts:Te("declared font-consent effect and approved loader",{plugin:ca("Plugin fragments do not start an implicit external font consent flow."),pattern:rr("Pattern fragments do not start an implicit font consent flow."),vectorized:nr("Path-only vectorized fragments do not consume font resources.")}),"external-assets":Te("declared external-asset resolver with proxy policy",{plugin:ca("Plugin fragments diagnose assets outside the enrolled security policy."),pattern:rr("Pattern fragments diagnose external assets instead of fetching them."),vectorized:nr("Path-only vectorized fragments do not consume external assets.")})};function c0(t,e){return vd[t][e]}function d0(t=da,e=$o,n=vd){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 xd=1,ua="document-root:0";function u0(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 p0(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 f0(t){if(t instanceof Map)return t;let e=new Map;for(let n of t)e.set(n.id,n);return e}function m0(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 Lh(t,e,n,r){let i=f0(n),o=new Set,s=[],a=[],l=d=>{if(typeof d!="string"||!d||o.has(d))return;let p=i.get(d);p&&(p.kind!=="symbol"&&p.kind!=="marker"||(o.add(d),s.push(p)))},c=d=>{a.push(d)},u=d=>{let p=d.state;if(!p)return;l(p.symbolId),l(p.markerStart),l(p.markerMid),l(p.markerEnd);let f=p.children;if(Array.isArray(f))for(let m of f)c(m);let g=p.symbolOverrides;if(g&&typeof g=="object"&&!Array.isArray(g))for(let[m,h]of Object.entries(g))!h||typeof h!="object"||Array.isArray(h)||c({id:m,type:"symbol-override",state:h})};for(let d of t)c(d);for(let d of e)l(d);for(;;){let d=a.shift();if(d){r(d),u(d);continue}let p=s.shift();if(!p)break;for(let f of m0(p))c(f)}}var g0=[],h0=[];function fa(t,e,n){Lh(t,h0,e,n)}function Id(t,e,n){Lh(g0,t,e,n)}function y0(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(pa(s));let a=n.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(pa(a))}function pa(t){return`line-marker-${t}`}var Bh=new Set(["fillLibraryId","strokeLibraryId","markerStart","markerMid","markerEnd","symbolId"]);function S0(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 Ri(t,e=[]){let n=new Set,r=new Set;return fa(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 b0(t,e){let{ids:n,legacyEndpoints:r}=Ri(t,e);for(let i of r)n.add(pa(i));return n}var v0=["validate","allocate-identities","document-fields","canonical-nodes","projections","references","commit","external-effects"];function x0(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,l)=>a.node.sourceOrder-l.node.sourceOrder||a.index-l.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 ma=class extends Error{diagnostics;constructor(e,n,r){super(e,{cause:r}),this.name="IngestApplicationError",this.diagnostics=n}};function I0(t,e){let n=o=>o==="id"||/(?:Id|Ids)$/.test(o)||o==="shapeInsideRef"||Bh.has(o),r=(o,s=!1)=>{if(s){let c=e.get(o);if(c)return c}if(o.startsWith("#")){let c=e.get(o.slice(1));if(c)return`#${c}`}let a=o.replace(/url\(\s*(['"]?)#([^'"\s)]+)\1\s*\)/g,(c,u,d)=>{let p=e.get(d);return p?`url(${u}#${p}${u})`:c});if(!a.includes("<"))return a;let l=a;for(let[c,u]of e){let d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p="(?:&quot;|&apos;|&#34;|&#39;|&#x22;|&#x27;)";l=l.replace(new RegExp(`(\\bid\\s*=\\s*["'])${d}(["'])`,"g"),`$1${u}$2`).replace(new RegExp(`(\\b(?:href|xlink:href)\\s*=\\s*["']#)${d}(["'])`,"g"),`$1${u}$2`).replace(new RegExp(`([uU][rR][lL]\\(\\s*(?:${p})?#)${d}((?:${p})?\\s*\\))`,"gu"),`$1${u}$2`)}return l},i=(o,s=!1)=>{if(Array.isArray(o)){for(let a=0;a<o.length;a++){let l=typeof o[a]=="string"?r(o[a],s):void 0;l!==void 0?o[a]=l:i(o[a],s)}return}if(!(o===null||typeof o!="object"))for(let[a,l]of Object.entries(o)){let c=n(a),u=typeof l=="string"?r(l,c):void 0;u!==void 0?o[a]=u:i(l,c)}};for(let o of t.nodes)i(o.serialized),i(o.groupPath,!0);i(t.documentFields),i(t.referenceEdges),i(t.clipMaskGroups)}function ir(t,e){if(e.injectFailureAfterStage===t)throw new Error(`Injected ingestion failure after ${t}.`)}function w0(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 k0(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(d=>d.severity==="error"))throw new Error("Ingestion plan contains an error diagnostic.");if(n.warningPolicy==="reject"&&t.diagnostics.some(d=>d.severity==="warning"))throw new Error("Ingestion warnings were rejected by caller policy.");ir("validate",n),o="allocate-identities";let s=structuredClone(t),a=new Map,l=e.resolvePlanIdentity?.(ua);l&&a.set(ua,l);for(let d of s.nodes){if(a.has(d.planNodeId))throw new Error(`Duplicate plan node id ${d.planNodeId}.`);a.set(d.planNodeId,s.identityMode==="preserve"?d.planNodeId:e.allocateId(d.planNodeId,d.serialized.type))}for(let[d,p]of w0(s))a.has(d)||a.set(d,s.identityMode==="preserve"?d:e.allocateId(d,p));I0(s,a);let c={idMap:a,addDiagnostic:d=>i.push(structuredClone(d))};e.preparePlan?.(s,c),ir("allocate-identities",n),o="document-fields";for(let[d,p]of Object.entries(s.documentFields)){let f=ga(d,s.intent);f.action==="preserve-host"||f.action==="derived"||f.action==="exempt"||e.applyDocumentField(d,f,structuredClone(p),c)}ir("document-fields",n);let u=x0(s.nodes.map(d=>({planNodeId:d.planNodeId,id:a.get(d.planNodeId),type:d.serialized.type,state:structuredClone(d.serialized.state),parentId:d.parentPlanNodeId?a.get(d.parentPlanNodeId)??null:null,sourceOrder:d.sourceOrder})));o="canonical-nodes";for(let d of u)e.createCanonicalNode(d,c);if(ir("canonical-nodes",n),o="projections",e.hydrateProjection)for(let d of u)e.hydrateProjection(d,c);return ir("projections",n),o="references",e.applyReferences?.(s,c),ir("references",n),o="commit",e.commit?.(c),ir("commit",n),o="external-effects",n.authorizeExternalEffects&&e.executeExternalEffects?.(s,c),ir("external-effects",n),{value:{createdIds:u.map(d=>d.id),idMap:Object.freeze(Object.fromEntries(a))},diagnostics:i}}catch(s){o!=="validate"&&e.restoreRollbackState(r);let a={severity:"error",code:"application-rolled-back",source:t.source.kind,entrypoint:t.intent,message:`Ingestion rolled back after ${o}: ${s instanceof Error?s.message:String(s)}`};throw i.push(a),new ma(a.message,i,s)}}import{SaxesParser as R0}from"saxes";var W="http://www.w3.org/2000/svg",Ao=class extends Error{constructor(n,r,i){super(r);this.hostId=n;this.name="SvgXmlParserHostError",this.cause=i}hostId;cause};function wd(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 jh(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 m=t.indexOf("-->",s+4);if(m<0)break;e=m+3;continue}if(t.startsWith("<![CDATA[",s)){let m=t.indexOf("]]>",s+9);if(m<0)break;e=m+3;continue}if(t.startsWith("<?",s)){let m=t.indexOf("?>",s+2);if(m<0)break;e=m+2;continue}let a=wd(t,s+1),c=/^<\s*([^\s/>]+)/.exec(t.slice(s,a))?.[1]??"";if(c.split(":").at(-1)?.toLowerCase()!=="style"||t.slice(s,a).startsWith("</")){e=a;continue}let d=`</${c.toLowerCase()}`,p=n.indexOf(d,a);if(p<0)break;let f=t.slice(a,p);if(!f.includes("<")||f.includes("<![CDATA[")){e=wd(t,p+2);continue}let g=`<![CDATA[${f.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;r.push({start:a,end:p,value:g}),e=wd(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 T0=256,P0=64*1024,C0=32*1024*1024,Td=String.raw`[\p{L}_:][\p{L}\p{N}\p{M}_.:\-]*`,$0=new RegExp(`^${Td}$`,"u"),E0="http://www.w3.org/1999/xlink",A0=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu,N0=/(?:^|;)\s*([^\s;]+?)\.(?:begin|end|repeat\(\d+\))/gu,M0=new Set(["aria-labelledby","aria-describedby"]),O0=new RegExp(String.raw`<!ENTITY\s+(?!%)(${Td})\s+(?:"([^"]*)"|'([^']*)')\s*>`,"gu"),Gh=new RegExp(String.raw`&(#x[0-9A-Fa-f]+|#[0-9]+|${Td});`,"gu"),D0=Object.freeze({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});function z0(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 _0(t,e,n){let r=new Map;for(let a of e.matchAll(O0)){if(r.size>=T0)return;r.set(a[1],a[2]??a[3]??"")}let i=new Map,o=(a,l)=>{let c=D0[a];if(c!==void 0)return c;let u=i.get(a);if(u!==void 0)return u;let d=r.get(a);if(d===void 0||l.has(a))return null;let p=new Set(l);p.add(a);let f=!0,g=d.replace(Gh,(m,h)=>{let b=h.startsWith("#")?z0(h):o(h,p);return b===null?(f=!1,""):b});return!f||g.length>P0?null:(i.set(a,g),g)};for(let a of r.keys())o(a,new Set);let s=0;for(let a of n.matchAll(Gh)){let l=i.get(a[1]);if(l!==void 0&&(s+=l.length,s>C0))return}for(let[a,l]of i)t.ENTITIES[a]=l}function Uh(t){return t&&t.length>0?t:null}function F0(t,e){return{name:t.name,localName:t.local,prefix:t.prefix.length>0?t.prefix:null,namespaceUri:Uh(t.uri),value:t.value,span:e}}var Hh={id:"saxes",parse(t){let e=[],n=[],r=[],i=0,o=[],s=0,a=0,l=new R0({xmlns:!0,position:!0}),c=d=>{let p=n.at(-1);p?p.children.push(d):e.push(d)};l.on("error",d=>{r.push(d.message)}),l.on("opentagstart",()=>{i=t.lastIndexOf("<",Math.max(0,l.position-1)),o=[],s=l.position;let d=n.at(-1);d?d.contentOffset=i:a=i}),l.on("attribute",d=>{let p=t.indexOf(d.name,s),f=p>=0&&p<l.position?p:s;o.push({start:f,end:l.position}),s=l.position}),l.on("opentag",d=>{let p=Object.values(d.attributes).map((g,m)=>F0(g,o[m]??{start:i,end:l.position})),f={kind:"element",name:d.name,localName:d.local,prefix:d.prefix.length>0?d.prefix:null,namespaceUri:Uh(d.uri),attributes:p,children:[],span:{start:i,end:l.position},startOffset:i,contentOffset:l.position};c(f),n.push(f)}),l.on("closetag",()=>{let d=n.pop();if(!d)return;d.rawXml=t.slice(d.startOffset,l.position),d.span.end=l.position;let p=n.at(-1);p?p.contentOffset=l.position:a=l.position});let u=(d,p,f,g)=>{c({kind:d,value:p,span:{start:f,end:g}});let m=n.at(-1);m?m.contentOffset=g:a=g};l.on("text",d=>{let p=n.at(-1)?.contentOffset??a,f=t.lastIndexOf("<",Math.max(0,l.position-1)),g=f>=p?f:l.position;u("text",d,p,g)}),l.on("comment",d=>{let p=t.lastIndexOf("<!--",l.position),f=t.indexOf("-->",Math.max(0,p));u("comment",d,Math.max(0,p),f>=0?f+3:l.position)}),l.on("cdata",d=>{let p=t.lastIndexOf("<![CDATA[",l.position),f=t.indexOf("]]>",Math.max(0,p));u("cdata",d,Math.max(0,p),f>=0?f+3:l.position)}),l.on("processinginstruction",({target:d,body:p})=>{let f=t.lastIndexOf("<?",l.position),g=t.indexOf("?>",Math.max(0,f));u("processing-instruction",p.length>0?`${d} ${p}`:d,Math.max(0,f),g>=0?g+2:l.position)}),l.on("doctype",d=>{_0(l,d,t);let p=t.lastIndexOf("<!DOCTYPE",l.position),f=t.indexOf(">",Math.max(0,p));u("doctype",d,Math.max(0,p),f>=0?f+1:l.position)});try{l.write(t).close()}catch(d){r.push(d instanceof Error?d.message:String(d))}return r.length>0?{error:r[0]}:{nodes:e}}};function Vh(t,e,n){return{severity:"error",code:e,source:t.source,entrypoint:t.entrypoint,message:n,documentPath:"/",elementName:"svg"}}function kd(t,e,n,r){return{severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,message:n,capability:"source-envelope",...r}}function Rd(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Ee(t){let e=Rd(t,"href",null);if(e)return{value:e.value,namespace:"svg2"};let n=Rd(t,"href",E0);return n?{value:n.value,namespace:"xlink"}:null}function L0(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 B0(t,e){let n=e.filter(m=>m.kind==="element"),r=new Map(n.map(m=>[m.sourceNodeId,m])),i=new Map,o=new Map,s=new Map,a=(m,h)=>{s.set(m.sourceNodeId,h);let b=m.children.filter(v=>v.kind==="element");o.set(m.sourceNodeId,Object.freeze(b));let S=new Map;for(let v of b){i.set(v.sourceNodeId,m);let I=(S.get(v.name)??0)+1;S.set(v.name,I),a(v,`${h}/${v.name}[${I}]`)}};a(t,`/${t.name}[1]`);let l=new Map,c=[];for(let m of n){let h=Rd(m,"id",null)?.value;if(h===void 0)continue;let b=l.get(h)??[],S=Object.freeze({authoredId:h,sourceNodeId:m.sourceNodeId,elementOrder:m.elementOrder,occurrenceIndex:b.length,primary:b.length===0,validXmlId:h.length>0&&!/\s/u.test(h)&&$0.test(h)});b.push(S),l.set(h,b),c.push(S)}let u=[],d=new Map,p=(m,h,b,S,v)=>{let I=l.get(S)??[],x=Object.freeze({sourceReferenceId:`reference:${u.length}`,fromSourceNodeId:m.sourceNodeId,channel:h,...v!==void 0?{attributeName:v}:{},authoredValue:b,targetAuthoredId:S,targetSourceNodeId:I[0]?.sourceNodeId??null,resolution:I.length===0?"missing":I.length===1?"resolved":"ambiguous-first"});u.push(x);let P=d.get(m.sourceNodeId)??[];P.push(x),d.set(m.sourceNodeId,P)},f=(m,h,b,S)=>{for(let v of b.matchAll(A0))p(m,h,b,v[2],S)};for(let m of n){let h=Ee(m);h?.value.startsWith("#")&&h.value.length>1&&p(m,h.namespace==="svg2"?"href":"xlink-href",h.value,h.value.slice(1),h.namespace==="svg2"?"href":"xlink:href"),m.localName.toLowerCase()==="style"&&f(m,"stylesheet-url",L0(m));for(let b of m.attributes)if(b.namespaceUri===null){if(b.localName==="style"?f(m,"inline-style-url",b.value,b.name):b.value.includes("url(")&&f(m,"presentation-url",b.value,b.name),b.localName==="begin"||b.localName==="end")for(let S of b.value.matchAll(N0))p(m,"smil-syncbase",b.value,S[1],b.name);if(M0.has(b.localName))for(let S of b.value.trim().split(/\s+/u).filter(Boolean))p(m,"idref-list",b.value,S,b.name)}}for(let m of l.values())Object.freeze(m);for(let m of d.values())Object.freeze(m);return Object.freeze(n),Object.freeze(c),Object.freeze(u),Object.freeze({elements:n,idOccurrences:c,localReferences:u,element(m){return r.get(m)??null},parent(m){return i.get(m)??null},children(m){return o.get(m)??Object.freeze([])},sourcePath(m){return s.get(m)??"/"},occurrences(m){return l.get(m)??Object.freeze([])},resolveAuthoredId(m){return l.get(m)?.[0]??null},referencesFrom(m){return d.get(m)??Object.freeze([])}})}function G0(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 Sn(t,e,n=Hh){let r=jh(t),i;try{i=n.parse(r)}catch(b){throw new Ao(n.id,`SVG XML parser host ${n.id} failed.`,b)}if(i===null||typeof i!="object"||!("error"in i)&&!("nodes"in i))throw new Ao(n.id,`SVG XML parser host ${n.id} returned no result.`);if("error"in i)return{value:null,diagnostics:[Vh(e,"malformed-source",`SVG XML parsing failed: ${i.error}`)]};let o=i.nodes.find(b=>b.kind==="element"),s=o?.namespaceUri===W||o?.namespaceUri===null;if(!o||o.localName!=="svg"||!s)return{value:null,diagnostics:[Vh(e,"missing-svg-root","The XML document element is not an SVG root in the SVG namespace.")]};let a=[],l=0,c=0,u=b=>{let S=l++,v=`source:${S}`;if(b.kind!=="element"){let T={kind:b.kind,sourceNodeId:v,sourceOrder:S,documentOrder:S,value:b.value,span:b.span};return a.push(T),T}let I=c++,x=[],P={kind:"element",sourceNodeId:v,sourceOrder:S,documentOrder:S,elementOrder:I,name:b.name,localName:b.localName,prefix:b.prefix,namespaceUri:b.namespaceUri,attributes:b.attributes.map(T=>({...T})),children:x,span:b.span,...b.rawXml!==void 0?{rawXml:b.rawXml}:{}};return a.push(P),x.push(...b.children.map(u)),P},d=null,p=i.nodes.map(b=>{let S=u(b);return b===o&&(d=S),S});if(!d)throw new Error("The validated SVG document element was not projected.");let f=B0(d,a),g=new Map;for(let b of f.idOccurrences){let S=g.get(b.authoredId)??[];S.push(b.sourceNodeId),g.set(b.authoredId,S)}let m=Object.freeze(Object.fromEntries([...g].map(([b,S])=>[b,Object.freeze(S)]))),h=[];o.namespaceUri===null&&h.push(kd(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[b,S]of g){let v=f.occurrences(b);if(v.length>1&&h.push(kd(e,"duplicate-svg-id",`SVG id ${JSON.stringify(b)} occurs ${S.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:b})),v.some(I=>!I.validXmlId)){let I=v.find(x=>!x.validXmlId);h.push(kd(e,"invalid-svg-attribute",`SVG id ${JSON.stringify(b)} 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:b}))}}return{value:G0({root:d,documentNodes:p,nodes:a,idIndex:m,index:f,rawSource:t,parserSource:r}),diagnostics:h}}function E(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName===e)?.value??null}function lt(t,e){return t.attributes.some(n=>n.namespaceUri===null&&n.localName===e)}var ha="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",V0=new RegExp(`^\\s*(${ha})(?:\\s*,\\s*|\\s+)(${ha})(?:\\s*,\\s*|\\s+)(${ha})(?:\\s*,\\s*|\\s+)(${ha})\\s*$`);function Xe(t){let e=V0.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 j0(t){return t==="none"||/^x(Min|Mid|Max)Y(Min|Mid|Max)$/.test(t)}function Mo(t){if(t==null)return{align:"xMidYMid",meetOrSlice:"meet"};let e=t.trim().split(/\s+/).filter(Boolean);return e.length<1||e.length>2||!j0(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 Wh(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 Kh(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function Xh(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 No(t,e){return Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==void 0}function U0(t){let e=["viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight"],n=e.filter(i=>No(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 H0(t,e,n){let{align:r,meetOrSlice:i}=Mo(n),o=t.width/e.viewBoxWidth,s=t.height/e.viewBoxHeight,a=t.x-e.viewBoxX*o,l=t.y-e.viewBoxY*s;if(r!=="none"){let c=i==="slice"?Math.max(o,s):Math.min(o,s),u=e.viewBoxWidth*c,d=e.viewBoxHeight*c;o=c,s=c,a=t.x+(t.width-u)*Wh(r,"x")-e.viewBoxX*c,l=t.y+(t.height-d)*Wh(r,"y")-e.viewBoxY*c}return st(o,0,0,s,a,l)}function Ti(t,e){let n=[],r=Kh(t.x,0),i=Kh(t.y,0),o=Xh(t.width,e?.width,"width",n),s=Xh(t.height,e?.height,"height",n),a=o===null||s===null?null:{x:r,y:i,width:o,height:s},l=U0(t);if((o===0||s===0)&&(l="zero-disabled"),l==="zero-disabled")return{status:l,renders:!1,frame:a,contentMatrix:null,childPercentBasis:null,diagnostics:n};if(l==="partial"?n.push({code:"invalid-viewbox",message:"Nested SVG viewBox is partial or non-finite and is ignored."}):l==="negative-invalid"&&n.push({code:"invalid-viewbox",message:"Nested SVG viewBox has a negative dimension and is ignored."}),l!=="valid")return{status:l,renders:!0,frame:a,contentMatrix:st(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:l,renders:!1,frame:null,contentMatrix:null,childPercentBasis:null,diagnostics:n};let c={viewBoxX:t.viewBoxX,viewBoxY:t.viewBoxY,viewBoxWidth:t.viewBoxWidth,viewBoxHeight:t.viewBoxHeight};return{status:l,renders:!0,frame:a,contentMatrix:H0(a,c,t.preserveAspectRatio),childPercentBasis:{width:c.viewBoxWidth,height:c.viewBoxHeight},diagnostics:n}}function oF(t,e){let n=No(t,"viewBoxWidth")&&No(t,"viewBoxHeight")&&!No(t,"viewBoxX")&&!No(t,"viewBoxY")?{...t,viewBoxX:0,viewBoxY:0}:t,r=Ti(n,e).contentMatrix;return r&&r.every((i,o)=>i===[1,0,0,1,0,0][o])?null:r}var W0=new Set(["animate","animatetransform","animatemotion","set"]),K0="http://www.w3.org/1999/xlink";function Yh(t,e){let n=E(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(),l=ot(a);if(l&&l.value>=0&&(l.unit!==""||l.value===0))return a}}return E(t,e)}function X0(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 qh(t){for(let e of t.children)if(e.kind==="element"&&(e.localName.toLowerCase()==="view"||qh(e)))return!0;return!1}function Y0(t,e){let n=t.attributes.find(i=>i.localName==="href"&&(i.namespaceUri===null||i.namespaceUri===K0))?.value;if(n===void 0)return!0;let r=E(e,"id");return r!==null&&n===`#${r}`}function Pd(t,e){let n=[],r=Ot(Yh(t,"width")),i=Ot(Yh(t,"height")),o=r!==void 0&&r>=0?r:void 0,s=i!==void 0&&i>=0?i:void 0,a=E(t,"preserveAspectRatio"),l=a&&a.trim().length>0?a.trim():void 0,c=lt(t,"viewBox"),u=E(t,"viewBox"),d=u!==null?Xe(u):null,p=d!==null&&d.width>=0&&d.height>=0?d:null;c&&!p&&n.push(X0(e,`Root SVG viewBox ${JSON.stringify(u)} is invalid per SVG 2 section 8.6 and was ignored.`));let f=t.children.some(v=>v.kind==="element"&&W0.has(v.localName.toLowerCase())&&Y0(v,t)),g=p!==null||f||qh(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}:{},...l!==void 0?{preserveAspectRatio:l}:{},sizingMode:"explicit",targetedPasteWrapper:g},diagnostics:n};let m=o!==void 0,h=s!==void 0,b=m?o:300,S=h?s:150;return{value:{viewBoxX:0,viewBoxY:0,viewBoxWidth:b,viewBoxHeight:S,...m||h?{width:b,height:S}:{},...l!==void 0?{preserveAspectRatio:l}:{},sizingMode:m||h?"sized":"implicit",targetedPasteWrapper:g},diagnostics:n}}function q0(t){return t.localName.toLowerCase()==="view"&&(t.namespaceUri===W||t.namespaceUri===null)}function Z0(t,e,n,r){let i=E(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 J0(t){return Object.freeze(t.state),Object.freeze(t)}function Cd(t,e){let n=[],r=[];for(let i of t.index.elements){if(!q0(i))continue;let o=E(i,"viewBox");if(o===null||o.trim().length===0)continue;let s=Xe(o);if(!s||s.width<0||s.height<0){r.push(Z0(t,i,e,o));continue}let a={viewName:E(i,"id")??"",viewBoxX:s.x,viewBoxY:s.y,viewBoxWidth:s.width,viewBoxHeight:s.height},l=E(i,"preserveAspectRatio");l&&(a.viewPreserveAspectRatio=l);let c=E(i,"zoomAndPan");(c==="disable"||c==="magnify")&&(a.viewZoomAndPan=c);let u=E(i,"viewTarget");u&&(a.viewTarget=u),n.push(J0({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 Jh(t){return t.localName.toLowerCase()==="svg"&&(t.namespaceUri===W||t.namespaceUri===null)}function Qh(t,e){let n=E(t,"style");if(!n)return null;let r=null;for(let i of yi(n,";")){let[o,...s]=yi(i,":");if(o?.trim().toLowerCase()!==e.toLowerCase())continue;let a=s.join(":").trim(),l=/\s*!\s*important\s*$/iu.test(a),c=a.replace(/\s*!\s*important\s*$/iu,"").trim();(!r||l||!r.important)&&(r={value:c,important:l})}return r}function Q0(t,e){let n=Qh(t,e);if(n){if(n.value.toLowerCase()==="auto")return{kind:"auto"};let r=ot(n.value);if(r&&r.value>=0)return{kind:"value",value:n.value}}return lt(t,e)?{kind:"value",value:E(t,e)??""}:{kind:"absent"}}function eR(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){let r=Ot(Qh(n,"font-size")?.value??null);if(r!==void 0)return r;let i=Ot(E(n,"font-size"));if(i!==void 0)return i;n=t.index.parent(n.sourceNodeId)}return 16}function ey(t,e,n,r,i){let o=E(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 Zh(t){let e=t.root,n=E(e,"viewBox"),r=n===null?null:Xe(n);if(r&&r.width>=0&&r.height>=0)return{width:r.width,height:r.height};let i=a=>{let l=Q0(e,a);return l.kind==="value"?Ot(l.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 tR(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){if(Jh(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function ya(t,e,n,r,i,o){if(!lt(e,n))return;let s=E(e,n)??"",a={percentBasis:n==="x"||n==="width"?r.width:r.height,viewportWidth:r.width,viewportHeight:r.height,fontSize:eR(t,e),rootFontSize:16},l=Se(s,a),c=(n==="width"||n==="height")&&(l??0)<0;if(l===void 0||c){o.push(ey(t,e,i,n,s));return}return l}function $d(t,e){let n=[],r=[],i=new Map([[t.root.sourceNodeId,Zh(t)]]);for(let o of t.index.elements){if(!Jh(o)||o.sourceNodeId===t.root.sourceNodeId)continue;let s=tR(t,o),a=(s&&i.get(s.sourceNodeId))??Zh(t),l={},c=ya(t,o,"x",a,e,r),u=ya(t,o,"y",a,e,r),d=ya(t,o,"width",a,e,r),p=ya(t,o,"height",a,e,r);c!==void 0&&(l.svgX=c),u!==void 0&&(l.svgY=u),d!==void 0&&(l.svgWidth=d),p!==void 0&&(l.svgHeight=p);let f=E(o,"viewBox"),g=f===null?null:Xe(f),m=g&&g.width>=0&&g.height>=0?g:null;f!==null&&!m&&r.push(ey(t,o,e,"viewBox",f)),m&&(l.svgViewBoxX=m.x,l.svgViewBoxY=m.y,l.svgViewBoxWidth=m.width,l.svgViewBoxHeight=m.height),lt(o,"preserveAspectRatio")&&(l.svgPreserveAspectRatio=E(o,"preserveAspectRatio")??"");let h=d??a.width,b=p??a.height;i.set(o.sourceNodeId,{width:m?.width??h,height:m?.height??b}),Object.freeze(l),n.push(Object.freeze({sourceNodeId:o.sourceNodeId,elementOrder:o.elementOrder,parentSourceNodeId:t.index.parent(o.sourceNodeId)?.sourceNodeId??null,state:l}))}return{value:Object.freeze(n),diagnostics:Object.freeze(r.map(o=>Object.freeze(o)))}}function nR(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 Ed(t,e){return nR(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function rR(t,e,n){if(n.namespaceUri!==W||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 ty(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:E(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:o})}function Ad(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 b=t.index.element(h.correspondingSourceNodeId);if(!b)throw new Error(`SVG occurrence ${h.occurrenceId} has no source element.`);i.set(h.occurrenceId,b);let S=rR(t,h,b);S&&o.set(h.occurrenceId,S)}let s=[],a=new Set;for(let h of n.materializedOccurrenceIds){if(a.has(h))continue;a.add(h);let b=r.get(h);if(!b)throw new Error(`Unknown materialized SVG occurrence ${h}.`);if(b.role==="definition")throw new Error(`Definition occurrence ${h} cannot be materialized in the scene.`);s.push(b)}s.sort(Ed);for(let h of s){let b=h.parentOccurrenceId,S=new Set;for(;b;){if(S.has(b))throw new Error(`SVG occurrence ancestry contains a cycle at ${b}.`);S.add(b);let v=r.get(b);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${b}.`);v.role==="use-carrier"&&o.set(b,"group"),b=v.parentOccurrenceId}}let l=new Set;for(let h of s){let b=h.parentOccurrenceId,S=new Set;for(;b;){if(S.has(b))throw new Error(`SVG occurrence ancestry contains a cycle at ${b}.`);S.add(b);let v=r.get(b);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${b}.`);o.has(b)&&l.add(b),b=v.parentOccurrenceId}}let c=[],u=new Set,d=[...l].map(h=>r.get(h)).sort(Ed),p=h=>{let b=h.parentOccurrenceId,S=new Set;for(;b;){if(S.has(b))return!1;S.add(b);let v=r.get(b);if(!v)return!1;if(o.get(b)==="hyperlink")return!0;b=v.parentOccurrenceId}return!1};for(let h of d){if(o.get(h.occurrenceId)==="hyperlink"&&p(h)){let S=i.get(h.occurrenceId);c.push(ty(t,h,S,n,"nested-hyperlink-flattened","Nested SVG hyperlinks are invalid; the inner hyperlink was flattened."));continue}u.add(h.occurrenceId)}for(let h of e.occurrences){if(o.get(h.occurrenceId)!=="hyperlink"||l.has(h.occurrenceId)||p(h))continue;let b=i.get(h.occurrenceId);c.push(ty(t,h,b,n,"empty-hyperlink-dropped","The SVG hyperlink has no materializable content and was dropped."))}let f=h=>{let b=h.parentOccurrenceId,S=new Set;for(;b;){if(S.has(b))throw new Error(`SVG occurrence ancestry contains a cycle at ${b}.`);if(S.add(b),u.has(b))return b;let v=r.get(b);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${b}.`);b=v.parentOccurrenceId}return null},g=d.filter(h=>u.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])})),m=s.map(h=>Object.freeze({occurrenceId:h.occurrenceId,sourceNodeId:h.correspondingSourceNodeId,parentContainerOccurrenceId:f(h),orderKey:Object.freeze([...h.orderKey])}));return c.sort((h,b)=>{let S=h.occurrenceId?r.get(h.occurrenceId):void 0,v=b.occurrenceId?r.get(b.occurrenceId):void 0;return!S||!v?0:Ed(S,v)}),Object.freeze({value:Object.freeze({containers:Object.freeze(g),placements:Object.freeze(m)}),diagnostics:Object.freeze(c)})}var ry="http://www.w3.org/1999/xhtml",iy="http://www.w3.org/1998/Math/MathML",iR=Object.freeze([ry,iy]),Md=Object.freeze(["systemLanguage","requiredExtensions","requiredFeatures"]),oR=/[\t\n\f\r ]+/,sR=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function Nd(t,e){return E(t,e)}function aR(t){if(t.namespaceUri!==W)return null;let e=Nd(t,"systemLanguage"),n=Nd(t,"requiredExtensions"),r=Nd(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 lR(t,e,n){return Object.freeze({severity:"warning",code:"required-features-dropped",source:n.source,entrypoint:n.entrypoint,capability:"conditional-processing",sourceId:E(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 Od(t,e){let n=[],r=[];for(let a of t.index.elements){let l=aR(a);l&&(n.push(l),l.requiredFeatures!==null&&r.push(lR(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 ny(t){let e=t.replace(sR,"");if(e.length===0)return null;try{return new Intl.Locale(e).toString().toLowerCase()}catch{return null}}function cR(t,e){if(t.requiredExtensions!==null){let i=t.requiredExtensions.split(oR).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(ny).filter(i=>i!==null);return n.length===0?!1:e.preferredLanguages.map(ny).filter(i=>i!==null).some(i=>n.some(o=>o===i||o.startsWith(`${i}-`)))}var dR=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol","view"]),uR=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol"]),pR=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu;function oy(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 fR(t,e){let n=1;for(;e.has(`${t}-${n}`);)n++;let r=`${t}-${n}`;return e.add(r),r}function sy(t,e,n){let r=t.trim(),i=r.length>0?oy(r):oy(e);return t===i&&!n.has(i)||!n.has(i)?(n.add(i),i):fR(i,n)}function ay(t,e){return t.replace(pR,(n,r,i)=>{let o=e.get(i);return!o||o===i?n:`url(${r}#${o}${r})`})}function mR(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 gR(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 hR(t){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.resourceIds),Object.freeze(t.generatedIds),Object.freeze(t.sourceIdToLiveId),Object.freeze(t.rewrites),Object.freeze(t)}function Dd(t,e={}){let n=t.index.elements,r=g=>{let m=t.index.parent(g.sourceNodeId);for(;m;){if(m.localName.toLowerCase()==="defs")return!0;m=t.index.parent(m.sourceNodeId)}return!1},i=new Set;for(let g of n)E(g,"id")!==null&&(dR.has(g.localName.toLowerCase())||r(g))&&i.add(g.sourceNodeId);for(let g of t.index.localReferences)g.channel!=="href"&&g.channel!=="xlink-href"||g.targetSourceNodeId&&i.add(g.targetSourceNodeId);let o=new Set(e.claimedIds??[]),s=[],a=new Map;for(let g of n){if(!i.has(g.sourceNodeId))continue;let m=E(g,"id");if(m===null)continue;let h=gR(g,r(g)),b=sy(m,h,o);a.has(m)||a.set(m,b),s.push({sourceNodeId:g.sourceNodeId,authoredId:m,sourceId:m.length>0?m:b,liveId:b,kind:h,restoreSourceId:b!==m&&uR.has(g.localName.toLowerCase())})}let l=new Set(s.map(g=>g.sourceNodeId));for(let g of n){if(l.has(g.sourceNodeId))continue;let m=E(g,"id");m!==null&&m!==""&&o.add(m)}let c=[],u=new Set,d=0;for(let g of n){if(g.namespaceUri!=="http://www.w3.org/2000/svg")continue;let m=g.localName.toLowerCase();if(!["animate","animatemotion","animatetransform","discard","set"].includes(m)||Ee(g))continue;let h=t.index.parent(g.sourceNodeId);if(!h||u.has(h.sourceNodeId))continue;let b=h,S=!1;for(;b;){if(b.namespaceUri==="http://www.w3.org/2000/svg"&&["clippath","mask"].includes(b.localName.toLowerCase())){S=!0;break}b=t.index.parent(b.sourceNodeId)}if(!S||E(h,"id"))continue;let I=`svgsketch-smil-target-${d++}`,x=sy(I,"other",o);u.add(h.sourceNodeId),c.push({sourceNodeId:h.sourceNodeId,liveId:x,reason:"clip-mask-animation-target"})}let p=[];for(let g of n){if(g.localName.toLowerCase()==="style"){let h=mR(g),b=ay(h,a);b!==h&&p.push({sourceNodeId:g.sourceNodeId,target:"text-content",value:b})}let m=Ee(g);for(let h of g.attributes){if(h.localName==="id"&&h.namespaceUri===null||h.name==="data-source-id")continue;let b=h.value;if((m?.namespace==="svg2"?h.localName==="href"&&h.namespaceUri===null:m?.namespace==="xlink"?h.localName==="href"&&h.namespaceUri!==null:!1)&&b.startsWith("#")){let v=a.get(b.slice(1));v&&v!==b.slice(1)&&(b=`#${v}`)}else h.namespaceUri===null&&b.includes("url(")&&(b=ay(b,a));b!==h.value&&p.push({sourceNodeId:g.sourceNodeId,target:"attribute",name:h.name,value:b})}}let f=Object.fromEntries(a);return hR({elementOrder:n.map(g=>g.sourceNodeId),resourceIds:s,generatedIds:c,sourceIdToLiveId:f,rewrites:p,liveIdForSourceId(g){return a.get(g)}})}var Pe=t=>({authority:"core",by:t}),ly={geometry:Pe("ingest/svg-leaf-geometry.ts"),containers:Pe("ingest/svg-container-hierarchy.ts"),"source-order":Pe("ingest/svg-source.ts and ingest/svg-use-occurrences.ts"),hierarchy:Pe("ingest/svg-container-hierarchy.ts"),"root-viewport-frame":Pe("ingest/root-frame.ts"),"common-presentation":Pe("ingest/svg-style-cascade.ts and svg-property-semantics.ts"),"conditional-processing":Pe("ingest/svg-conditional-processing.ts"),"authored-attributes":Pe("ingest/svg-authored-attributes.ts"),gradients:Pe("ingest/svg-gradients.ts"),patterns:Pe("ingest/svg-patterns.ts"),filters:Pe("ingest/svg-filters.ts"),"paint-server-definitions":Pe("ingest/svg-paint-server-definitions.ts"),markers:Pe("ingest/svg-markers.ts"),symbols:Pe("ingest/svg-symbol-uses.ts"),"use-and-linked-references":Pe("ingest/svg-use-occurrences.ts and ingest/svg-symbol-uses.ts"),"clip-definitions":Pe("ingest/svg-clip-masks.ts"),"mask-definitions":Pe("ingest/svg-clip-masks.ts"),"clip-mask-membership":Pe("ingest/svg-clip-masks.ts"),"smil-animation":Pe("ingest/svg-animations.ts and smil-value-syntax.ts"),"css-animation":Pe("ingest/svg-animations.ts and css-animation-syntax.ts"),metadata:Pe("ingest/svg-metadata.ts"),scripts:Pe("ingest/svg-scripts.ts"),styles:Pe("ingest/svg-style-cascade.ts"),"custom-properties":Pe("ingest/svg-style-cascade.ts custom-property environments"),views:Pe("ingest/svg-views.ts"),"embedded-svg":Pe("ingest/svg-embedded-frames.ts"),fonts:Pe("ingest/svg-external-effects.ts"),"external-assets":Pe("ingest/svg-external-effects.ts")};function yR(t=da,e=ly){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 retired 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 SR=64,bR=1e5,Sa="http://www.w3.org/2000/svg",vR=new Set(["circle","ellipse","line","path","polygon","polyline","rect","text"]);function cy(t,e){return t===void 0||!Number.isFinite(t)?e:Math.max(1,Math.floor(t))}var zd=new Set(["defs","clippath","mask","marker","pattern","lineargradient","radialgradient","filter","symbol"]);function xR(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 IR(t,e){return xR(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function dy(t,e,n){let r=e.map(i=>i.sourceReferenceId).join("/");return`occurrence:${r?`${r}/`:""}${t}:${n}`}function wR(t,e){let n=Ee(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 kR(t,e){let n=Ee(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=wR(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!==Sa?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 RR(t,e){let n=e;for(;n&&n!==t.root;){if(zd.has(n.localName.toLowerCase()))return!0;n=t.index.parent(n.sourceNodeId)}return!1}function Pi(t){return t.namespaceUri===Sa&&t.localName.toLowerCase()==="use"}function TR(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!==Sa||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 l=[],c=new Set;for(let v of o){if(c.has(v))continue;c.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++,c.has(T)||(c.add(T),I.push({sourceNodeId:T,targetIndex:0}));continue}l.push(x.sourceNodeId),I.pop()}}let u=[],d=new Set;for(let v=l.length-1;v>=0;v--){let I=l[v];if(d.has(I))continue;let x=[],P=[I];for(d.add(I);P.length>0;){let T=P.pop();x.push(T);let k=a.get(T)??[];for(let w=k.length-1;w>=0;w--){let $=k[w];d.has($)||(d.add($),P.push($))}}x.sort(i),u.push(x)}let p=new Map;u.forEach((v,I)=>{v.forEach(x=>p.set(x,I))});let f=u.map(()=>new Set);for(let[v,I]of r){let x=p.get(v);for(let P of I){let T=p.get(P);x!==T&&f[x].add(T)}}let g=u.map(v=>n.get(v[0])?.elementOrder??Number.MAX_SAFE_INTEGER),m=(v,I)=>g[v]-g[I],h=u.map((v,I)=>I).sort(m),b=[],S=new Set;for(let v of h){if(S.has(v))continue;S.add(v);let I=[{componentIndex:v,dependencyIndex:0,dependencies:[...f[v]].sort(m)}];for(;I.length>0;){let x=I[I.length-1],P=x.dependencies[x.dependencyIndex];if(P!==void 0){x.dependencyIndex++,S.has(P)||(S.add(P),I.push({componentIndex:P,dependencyIndex:0,dependencies:[...f[P]].sort(m)}));continue}b.push(x.componentIndex),I.pop()}}return b.map(v=>{let I=u[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 Ci(t,e,n,r,i){return Object.freeze({severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,capability:"use-and-linked-references",sourceId:E(r,"id")??void 0,sourceNodeId:r.sourceNodeId,occurrenceId:i,elementName:r.name,message:n})}function _d(t,e){let n=cy(e.maxDepth,SR),r=cy(e.maxOccurrences,bR),i=t.index.elements.filter(k=>k.namespaceUri===Sa&&k.localName.toLowerCase()==="use").map(k=>kR(t,k)),o=new Map(i.map(k=>[k.useSourceNodeId,k])),s=[],a=new Map,l=new Map,c=[],u=[],d=[],p=new Map,f=new Set;for(let k of e.resourceRoots??[]){let w=`${k.capability}\0${k.sourceNodeId}`;if(f.has(w))continue;f.add(w);let $=t.index.element(k.sourceNodeId),R=[];if($&&k.capability==="clip-path")for(let A of t.index.children($.sourceNodeId)){if(!Pi(A))continue;let D=o.get(A.sourceNodeId),_=D?.targetSourceNodeId?t.index.element(D.targetSourceNodeId):null;(D?.status!=="resolved"||!_||!vR.has(_.localName.toLowerCase()))&&(R.push(A.sourceNodeId),u.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:e.source,entrypoint:e.entrypoint,capability:"clip-definitions",sourceId:E($,"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 C=Object.freeze({resourceRootSourceNodeId:k.sourceNodeId,capability:k.capability,status:R.length===0?"valid":"invalid",invalidUseSourceNodeIds:Object.freeze(R)});d.push(C),p.has(k.sourceNodeId)||p.set(k.sourceNodeId,C)}let g=new Set,m=0,h=!1,b=(k,w,$,R,C)=>{let A=dy(k.sourceNodeId,w,0),D=a.get(A);if(D)return D;let _=Object.freeze({occurrenceId:A,correspondingSourceNodeId:k.sourceNodeId,usePath:Object.freeze(w.map(O=>Object.freeze({...O}))),role:C,parentOccurrenceId:$,orderKey:Object.freeze([...R]),productIndex:0});return s.push(_),a.set(A,_),w.length===0?l.set(k.sourceNodeId,_):m++,_};for(let k of t.index.elements){let w=t.index.parent(k.sourceNodeId),$=w?dy(w.sourceNodeId,[],0):null,R=Pi(k)?"use-carrier":RR(t,k)?"definition":"source";b(k,[],$,[k.elementOrder],R)}let S=(k,w)=>{h||(h=!0,u.push(Ci(e,"use-expansion-limit-exceeded",`SVG use expansion exceeded depth ${n} or ${r} shadow occurrences.`,k,w.occurrenceId)))},v=(k,w,$)=>{if(g.has(w.occurrenceId))return;g.add(w.occurrenceId);let R=Ee(k),C=o.get(k.sourceNodeId);if(!C||C.status==="empty"){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:null,status:"empty"}),u.push(Ci(e,"unresolved-reference","The SVG use element has no local target.",k,w.occurrenceId));return}if(C.status==="external"){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:null,status:"external"}),u.push(Ci(e,"unresolved-reference",`External SVG use target "${R?.value??""}" is not materialized by local import.`,k,w.occurrenceId));return}if(C.status==="missing"){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:null,status:"missing"}),u.push(Ci(e,"unresolved-reference",`SVG use target "${R?.value??""}" does not exist.`,k,w.occurrenceId));return}if(C.status==="invalid"){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:C.targetSourceNodeId,status:"invalid"}),u.push(Ci(e,"unresolved-reference",`SVG use target "${R?.value??""}" is outside the SVG namespace.`,k,w.occurrenceId));return}let A=C.targetSourceNodeId?t.index.element(C.targetSourceNodeId):null;if(!A||!C.sourceReferenceId)return;let D={sourceReferenceId:C.sourceReferenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:A.sourceNodeId},_=[...w.usePath,D];if($.has(A.sourceNodeId)){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"circular"}),u.push(Ci(e,"circular-use-reference",`SVG use target "${R?.value??""}" closes a circular shadow-tree reference.`,k,w.occurrenceId));return}if(_.length>n||m>=r){c.push({useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"limit"}),S(k,w);return}let O={useOccurrenceId:w.occurrenceId,useSourceNodeId:k.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"resolved"};c.push(O);let L=()=>{O.status="limit",S(k,w)},re=new Set($),ee=(F,V,H)=>{if(m>=r){L();return}re.add(F.sourceNodeId);let X=Pi(F)?"use-carrier":"shadow-instance",z=b(F,_,V,H,X);if(Pi(F))v(F,z,re);else if(!zd.has(F.localName.toLowerCase())||F.localName.toLowerCase()==="symbol"){for(let G of t.index.children(F.sourceNodeId))if(ee(G,z.occurrenceId,[...H,G.elementOrder]),m>=r){L();break}}re.delete(F.sourceNodeId)};ee(A,w.occurrenceId,[...w.orderKey,A.elementOrder])},I=(k,w)=>{if(zd.has(k.localName.toLowerCase()))return;let $=new Set(w);$.add(k.sourceNodeId);let R=l.get(k.sourceNodeId);if(Pi(k)){v(k,R,w);return}for(let C of t.index.children(k.sourceNodeId))I(C,$)};I(t.root,new Set);let x=(k,w)=>{let $=new Set(w);$.add(k.sourceNodeId);let R=l.get(k.sourceNodeId);if(Pi(k)){v(k,R,w);return}for(let C of t.index.children(k.sourceNodeId))x(C,$)};for(let k of e.resourceRoots??[]){if(p.get(k.sourceNodeId)?.status==="invalid")continue;let $=t.index.element(k.sourceNodeId);if(!$)continue;let R=new Set,C=t.index.parent($.sourceNodeId);for(;C;)R.add(C.sourceNodeId),C=t.index.parent(C.sourceNodeId);x($,R)}s.sort(IR);let P=c.map(k=>Object.freeze({...k})),T=TR(t,o);return Object.freeze(i),Object.freeze(s),Object.freeze(P),Object.freeze(T),Object.freeze(d),Object.freeze(u),Object.freeze({occurrences:s,sourceResolutions:i,resolutions:P,definitionComponents:T,resourcePolicies:d,diagnostics:u,occurrence(k){return a.get(k)??null},direct(k){return l.get(k)??null},sourceResolution(k){return o.get(k)??null},resourcePolicy(k){return p.get(k)??null}})}var U="all-svg-elements",uy=[["alignment-baseline",!1,"auto",U],["baseline-shift",!1,"0",U],["clip",!1,"auto",U],["clip-path",!1,"none",U],["clip-rule",!0,"nonzero",U],["color",!0,"black",U],["color-interpolation",!0,"sRGB",U],["color-interpolation-filters",!0,"linearRGB",U],["cursor",!0,"auto",U],["direction",!0,"ltr",U],["display",!1,"inline",U],["dominant-baseline",!0,"auto",U],["fill",!0,"black",U],["fill-opacity",!0,"1",U],["fill-rule",!0,"nonzero",U],["filter",!1,"none",U],["flood-color",!1,"black",U],["flood-opacity",!1,"1",U],["font-family",!0,"serif",U],["font-feature-settings",!0,"normal",U],["font-kerning",!0,"auto",U],["font-size",!0,"medium",U],["font-size-adjust",!0,"none",U],["font-stretch",!0,"normal",U],["font-style",!0,"normal",U],["font-variant",!0,"normal",U],["font-variant-caps",!0,"normal",U],["font-variant-east-asian",!0,"normal",U],["font-variant-ligatures",!0,"normal",U],["font-variant-numeric",!0,"normal",U],["font-variant-position",!0,"normal",U],["font-weight",!0,"normal",U],["image-rendering",!0,"auto",U],["letter-spacing",!0,"normal",U],["lighting-color",!1,"white",U],["line-height",!0,"normal",U],["marker-end",!0,"none",U],["marker-mid",!0,"none",U],["marker-start",!0,"none",U],["mask",!1,"none",U],["mask-image",!1,"none",U],["opacity",!1,"1",U],["overflow",!1,"visible",U],["paint-order",!0,"normal",U],["pointer-events",!0,"auto",U],["shape-rendering",!0,"auto",U],["stop-color",!1,"black",U],["stop-opacity",!1,"1",U],["stroke",!0,"none",U],["stroke-dasharray",!0,"none",U],["stroke-dashoffset",!0,"0",U],["stroke-linecap",!0,"butt",U],["stroke-linejoin",!0,"miter",U],["stroke-miterlimit",!0,"4",U],["stroke-opacity",!0,"1",U],["stroke-width",!0,"1px",U],["text-anchor",!0,"start",U],["text-decoration",!1,"none",U],["text-rendering",!0,"auto",U],["text-transform",!0,"none","none"],["transform",!1,"none",U],["transform-box",!1,"view-box","none"],["transform-origin",!1,"50% 50%",U],["unicode-bidi",!1,"normal",U],["vector-effect",!1,"none",U],["visibility",!0,"visible",U],["word-spacing",!0,"normal",U],["writing-mode",!0,"horizontal-tb",U]],PR=new Map(uy.map(([t,e,n,r="none"])=>[t,Object.freeze({name:t,inherited:e,initialValue:n,presentationAttribute:r})])),ba=Object.freeze(uy.filter(t=>(t[3]??"none")!=="none").map(t=>t[0]));function Ar(t){return PR.get(t.toLowerCase())??null}function Fd(t){return(Ar(t)?.presentationAttribute??"none")!=="none"}var my=new Set(["circle","ellipse","image","line","path","polygon","polyline","rect","text"]),CR=new Set([...my,"a","g","use"]),$R=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),ER=new Set(["clippath","filter","marker","mask","pattern"]),AR=new Set(["defs"]),py=new Set([...$R,"flowregion"]),NR=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"]),MR=new Set(["data-shape-id","height","href","id","style","transform","width","x","xlink:href","xmlns","xmlns:xlink","y"]),OR=["animation","transition","-moz-animation","-moz-transition","-o-animation","-o-transition","-webkit-animation","-webkit-transition"],DR=new Set(["height","id","preserveaspectratio","refx","refy","viewbox","width","x","y"]);function $i(t){return t.localName.toLowerCase()}function gy(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 xa(t,e,n){return gy(t,e).some(r=>n.has($i(r)))}function zR(t,e){let n=$i(e);return xa(t,e,AR)?n==="symbol"||n==="g"||n==="use"||my.has(n):!1}function fy(t){let e=t.toLowerCase();return OR.some(n=>e===n||e.startsWith(`${n}-`))}function _R(t){let e={};for(let n of["x","y","width","height"])lt(t,n)&&(e[n]=E(t,n)??"");return Object.keys(e).length===0?null:Object.freeze(e)}function FR(t,e,n,r){let i=e;for(;i&&$i(i)!=="svg";)i=t.index.parent(i.sourceNodeId);let o=i?Xe(E(i,"viewBox")??""):null,s=i?Se(E(i,"width"),{}):void 0,a=i?Se(E(i,"height"),{}):void 0,l=o?.width??s,c=o?.height??a,u=Se(n.value(r,"font-size"),{viewportWidth:l,viewportHeight:c,percentBasis:16,fontSize:16,rootFontSize:16});return{viewportWidth:l,viewportHeight:c,fontSize:u??16,rootFontSize:16}}function LR(t,e){for(let n of gy(t,e))switch($i(n)){case"pattern":return E(n,"patternContentUnits")==="objectBoundingBox";case"clippath":return E(n,"clipPathUnits")==="objectBoundingBox";case"mask":return E(n,"maskContentUnits")==="objectBoundingBox";default:break}return!1}function va(t,e){if(t===null||t.trim()===""||t.trim().toLowerCase()==="auto")return e;let n=ot(t);return n?n.unit==="%"?n.value/100:n.unit===""?n.value:e:e}function BR(t,e,n,r){let i=LR(t,e),o=FR(t,e,r,n),s=E(e,"x"),a=E(e,"y"),l=i?va(s,0):Se(s,{...o,percentBasis:o.viewportWidth})??0,c=i?va(a,0):Se(a,{...o,percentBasis:o.viewportHeight})??0,u=E(e,"width"),d=E(e,"height"),p=u===null||u.trim()===""||u.trim().toLowerCase()==="auto"?null:i?va(u,0):Se(u,{...o,percentBasis:o.viewportWidth})??null,f=d===null||d.trim()===""||d.trim().toLowerCase()==="auto"?null:i?va(d,0):Se(d,{...o,percentBasis:o.viewportHeight})??null;return Object.freeze({authored:_R(e),x:l,y:c,width:p,height:f})}function GR(t,e,n){let r=E(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:st(1,0,0,1,0,0),valid:!0,pureTranslation:!0});let s=Xt(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 VR(t,e,n){let r={};for(let s of t.attributes){let a=s.name;MR.has(a)||s.value===""||fy(a)||(r[a]=s.value)}let i=n.style(e.occurrenceId);for(let[s,a]of Object.entries(i?.cascadedValues??{}))s==="transform"||fy(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||!Ar(s)?.inherited||o?.resolvedValues[s]!==a)continue;o.cascadedValues[s]&&(r[s]=a)}return Object.freeze(r)}function jR(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&DR.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function UR(t,e){return t.find(n=>n.memberSourceNodeIds.includes(e))??null}function HR(t,e,n,r,i,o){let s=i.get(`${n.occurrenceId}\0${r.sourceNodeId}`);if(!s)return null;let a=UR(e.definitionComponents,r.sourceNodeId),l=o(s.occurrenceId),c=E(r,"viewBox");return Object.freeze({sourceNodeId:r.sourceNodeId,sourceId:E(r,"id"),defKind:$i(r)==="symbol"?"symbol":"group",productKey:`symbol-product:${r.sourceNodeId}:${n.occurrenceId}`,productUseOccurrenceId:n.occurrenceId,productRootOccurrenceId:s.occurrenceId,contentOccurrenceIds:Object.freeze(l),componentId:a?.componentId??null,circular:a?.circular??!1,viewBox:c,parsedViewBox:c===null?null:Xe(c),preserveAspectRatio:E(r,"preserveAspectRatio"),x:E(r,"x"),y:E(r,"y"),width:E(r,"width"),height:E(r,"height"),refX:E(r,"refX"),refY:E(r,"refY"),rootAttributes:jR(r)})}function WR(t,e,n,r,i,o){if(r.usePath.length!==0||!i.valid||!i.pureTranslation||!CR.has($i(n))||xa(t,e,py)||xa(t,n,py))return!1;for(let s of NR)if(lt(e,s)||o.style(r.occurrenceId)?.cascadedValues[s])return!1;return!0}function Ld(t,e,n,r){let i=new Map,o=new Map;for(let f of e.occurrences){if(!f.parentOccurrenceId)continue;let g=`${f.parentOccurrenceId}\0${f.correspondingSourceNodeId}`;i.has(g)||i.set(g,f);let m=o.get(f.parentOccurrenceId)??[];m.push(f),o.set(f.parentOccurrenceId,m)}let s=new Map,a=f=>{let g=s.get(f);if(g)return g;let m=[],h=[...o.get(f)??[]].reverse(),b=new Set;for(;h.length>0;){let v=h.pop();if(b.has(v.occurrenceId))continue;b.add(v.occurrenceId),m.push(v.occurrenceId);let I=o.get(v.occurrenceId)??[];for(let x=I.length-1;x>=0;x--)h.push(I[x])}let S=Object.freeze(m);return s.set(f,S),S},l=[],c=[],u=new Map,d=new Map;for(let f of e.resolutions){let g=e.occurrence(f.useOccurrenceId),m=t.index.element(f.useSourceNodeId);if(!g||!m||m.namespaceUri!==W)continue;let h=f.targetSourceNodeId?t.index.element(f.targetSourceNodeId):null,b=BR(t,m,g.occurrenceId,n),S=GR(m,g.occurrenceId,n),v=VR(m,g,n),I=f.status==="resolved"?"flattened":f.status,x=null;if(f.status==="resolved"&&h){let T=xa(t,m,ER);if(!T&&zR(t,h)){let k=HR(t,e,g,h,i,a);k&&(l.push(k),u.set(k.productKey,k),x=k.productKey,I="symbol-instance")}else!T&&WR(t,m,h,g,S,n)&&(I="linked-reference")}let P=Object.freeze({useOccurrenceId:g.occurrenceId,useSourceNodeId:m.sourceNodeId,targetSourceNodeId:h?.sourceNodeId??null,targetElementName:h?.name??null,status:I,definitionProductKey:x,geometry:b,presentation:v,transform:S,orderKey:Object.freeze([...g.orderKey])});c.push(P),d.set(P.useOccurrenceId,P)}Object.freeze(l),Object.freeze(c);let p=Object.freeze([]);return Object.freeze({definitions:l,uses:c,diagnostics:p,definition(f){return u.get(f)??null},use(f){return d.get(f)??null}})}var KR=new Map([["lineargradient","gradient"],["radialgradient","gradient"],["pattern","pattern"],["filter","filter"],["marker","marker"],["clippath","clip-path"],["mask","mask"]]),hy=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"]]),XR=new Set(["animate","set"]),YR=new Set(["clippath","defs","desc","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]);function yy(t){return!t||t.namespaceUri!==W?null:KR.get(t.localName.toLowerCase())??null}function Sy(t,e,n){if(!n||n.namespaceUri!==W)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 qR(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 by(t,e){let n=e;for(;n;){if(yy(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function vy(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(YR.has(r.localName.toLowerCase()))return"parked";r=t.index.parent(r.sourceNodeId)}return r?"resource-product":"parked"}function ZR(t){let e=[];for(let n of On(t,";")){let r=t.slice(n.start,n.end),i=On(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 xy(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 JR(t,e,n){return(t.get(e)?.elementOrder??Number.MAX_SAFE_INTEGER)-(t.get(n)?.elementOrder??Number.MAX_SAFE_INTEGER)}function QR(t,e,n){let r=(S,v)=>JR(n,S,v),i=[...t].sort(r),o=new Map(i.map(S=>[S,[...e.get(S)??[]].sort(r)])),s=new Map(i.map(S=>[S,[]]));for(let[S,v]of o)for(let I of v)s.get(I)?.push(S);for(let S of s.values())S.sort(r);let a=[],l=new Set;for(let S of i){if(l.has(S))continue;l.add(S);let v=[{nodeId:S,targetIndex:0}];for(;v.length>0;){let I=v[v.length-1],x=o.get(I.nodeId)?.[I.targetIndex];x!==void 0?(I.targetIndex++,l.has(x)||(l.add(x),v.push({nodeId:x,targetIndex:0}))):(a.push(I.nodeId),v.pop())}}let c=[],u=new Set;for(let S=a.length-1;S>=0;S--){let v=a[S];if(u.has(v))continue;let I=[],x=[v];for(u.add(v);x.length>0;){let P=x.pop();I.push(P);let T=s.get(P)??[];for(let k=T.length-1;k>=0;k--){let w=T[k];u.has(w)||(u.add(w),x.push(w))}}I.sort(r),c.push(I)}let d=new Map;c.forEach((S,v)=>{S.forEach(I=>d.set(I,v))});let p=c.map(()=>new Set);for(let[S,v]of e){let I=d.get(S);if(I!==void 0)for(let x of v){let P=d.get(x);P!==void 0&&I!==P&&p[I].add(P)}}let f=c.map(S=>n.get(S[0])?.elementOrder??Number.MAX_SAFE_INTEGER),g=(S,v)=>f[S]-f[v],m=c.map((S,v)=>v).sort(g),h=[],b=new Set;for(let S of m){if(b.has(S))continue;b.add(S);let v=[{component:S,dependencyIndex:0,dependencies:[...p[S]].sort(g)}];for(;v.length>0;){let I=v[v.length-1],x=I.dependencies[I.dependencyIndex];x!==void 0?(I.dependencyIndex++,b.has(x)||(b.add(x),v.push({component:x,dependencyIndex:0,dependencies:[...p[x]].sort(g)}))):(h.push(I.component),v.pop())}}return h.map(S=>{let v=c[S];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 Iy(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 Ia(t,e,n,r,i,o,s,a,l,c=n.length,u=null){let d=l??hy.get(r);if(!d)return[];let p=by(t,e);return Dn(n.slice(s,c)).map((f,g)=>{let m=Iy(t,f.targetAuthoredId);return{sourceReferenceId:(i==="authored-direct"?xy(t,e,f.targetAuthoredId,n,o,a):null)?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:u,containingResourceSourceNodeId:p?.sourceNodeId??null,participation:vy(t,e,p),binding:i,kind:d,propertyName:r,attributeName:o,authoredValue:n,propertyValue:n.slice(s,c),tokenIndex:g,tokenStart:s+f.targetStart,tokenEnd:s+f.targetEnd,targetAuthoredId:f.targetAuthoredId,targetSourceNodeId:m.targetSourceNodeId,targetElementName:m.target?.localName??null,resolution:m.resolution,validity:m.resolution==="missing"?"missing":Sy(d,r,m.target)?"valid":"invalid-target",componentId:null}})}function Bd(t,e,n,r){let i=Ee(e);if(!i||!i.value.startsWith("#")||i.value.length<=1)return null;let o=i.value.slice(1),s=Iy(t,o),a=i.namespace==="svg2"?"href":"xlink:href",l=xy(t,e,o,i.value,a,r),c=by(t,e);return{sourceReferenceId:l?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:null,containingResourceSourceNodeId:c?.sourceNodeId??null,participation:vy(t,e,c),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":Sy(n,null,s.target)?"valid":"invalid-target",componentId:null}}function Gd(t){let e=t.trim().toLowerCase();return hy.has(e)?e:null}function eT(t,e){let n=[];for(let r of t.index.elements){if(r.namespaceUri!==W)continue;let i=r.localName.toLowerCase();if(i==="lineargradient"||i==="radialgradient"){let o=Bd(t,r,"gradient-template",e);o&&n.push(o)}else if(i==="pattern"){let o=Bd(t,r,"pattern-template",e);o&&n.push(o)}else if(i==="feimage"){let o=Bd(t,r,"filter-image",e);o&&n.push(o)}if(XR.has(i)){let o=Gd(E(r,"attributeName")??"");if(o)for(let s of["values","from","to","by"]){let a=r.attributes.find(l=>l.namespaceUri===null&&l.localName===s);a&&n.push(...Ia(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 ZR(o.value)){let l=Gd(a.propertyName);l&&n.push(...Ia(t,r,o.value,l,"authored-direct",o.name,a.valueStart,e,void 0,a.valueEnd))}continue}let s=Gd(o.localName);s&&n.push(...Ia(t,r,o.value,s,"authored-direct",o.name,0,e))}}return n}function tT(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 Ia(t,i,r.value,r.propertyName,"applied-css",null,0,n,void 0,r.value.length,r.occurrenceId??null)})}function nT(t){let e=[];for(let n of t.index.elements){if(n.namespaceUri!==W||n.localName.toLowerCase()!=="style")continue;let r=qR(n);Dn(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 rT(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?E(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 Vd(t,e){let n=new Map(t.index.elements.map(x=>[x.sourceNodeId,x])),r=t.index.elements.flatMap(x=>{let P=yy(x);return P?[Object.freeze({sourceNodeId:x.sourceNodeId,kind:P,authoredId:E(x,"id")})]:[]}),i=new Set(r.map(x=>x.sourceNodeId)),o=new Set,s=[...eT(t,o),...tT(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 l=QR(r.map(x=>x.sourceNodeId),a,n),c=new Map;for(let x of l)for(let P of x.memberSourceNodeIds)c.set(P,x);let u=s.map((x,P)=>{let T=x.containingResourceSourceNodeId?c.get(x.containingResourceSourceNodeId):void 0,k=x.targetSourceNodeId?c.get(x.targetSourceNodeId):void 0,w=!!(x.validity==="valid"&&T?.circular&&T===k);return Object.freeze({resourceReferenceId:`resource-reference:${P}`,...x,validity:w?"circular":x.validity,componentId:T?.componentId??null})}),d=new Map;for(let x of u){let P=d.get(x.fromSourceNodeId)??[];P.push(x),d.set(x.fromSourceNodeId,P)}let p=u.flatMap(x=>{let P=rT(x,e,n.get(x.fromSourceNodeId)??null);return P?[P]:[]}),f=new Map;for(let x of p){if(!x.sourceNodeId)continue;let P=f.get(x.sourceNodeId)??[];P.push(x),f.set(x.sourceNodeId,P)}let g=new Map(u.map(x=>[x.resourceReferenceId,x])),m=new Map;for(let x of u){if(!x.containingResourceSourceNodeId||x.participation!=="resource-product")continue;let P=m.get(x.containingResourceSourceNodeId)??[];P.push(x),m.set(x.containingResourceSourceNodeId,P)}let h=x=>x.validity==="valid"||x.validity==="circular",b=x=>Object.freeze([...new Set(x.flatMap(P=>f.get(P.fromSourceNodeId)??[]))]),S=x=>{let P=x.map(z=>{let G=g.get(z.resourceReferenceId);if(!G)throw new Error(`SVG resource edge ${z.resourceReferenceId} does not belong to this dependency plan.`);return G}),T=new Set,k=new Set,w=new Set,$=new Map,R=[],C=[],A=new Map,D=z=>{if(T.add(z.resourceReferenceId),!(!h(z)||!z.targetSourceNodeId)){if(i.has(z.targetSourceNodeId)){if(k.has(z.targetSourceNodeId))return;k.add(z.targetSourceNodeId),$.set(z.targetSourceNodeId,z.resourceReferenceId),R.push(z.targetSourceNodeId);return}z.kind!=="filter-image"||w.has(z.targetSourceNodeId)||(w.add(z.targetSourceNodeId),$.set(z.targetSourceNodeId,z.resourceReferenceId),C.push(z.targetSourceNodeId))}};for(P.forEach(D);R.length>0||C.length>0;){for(;R.length>0;){let z=R.shift();for(let G of m.get(z)??[])D(G)}for(;C.length>0;){let z=C.shift(),G=[],q=[z],te=new Set;for(;q.length>0;){let ie=q.pop();if(!te.has(ie)){te.add(ie);for(let J of d.get(ie)??[])J.containingResourceSourceNodeId===null&&(G.push(J),D(J));q.push(...t.index.children(ie).map(J=>J.sourceNodeId))}}A.set(z,G)}}let _=[],O=new Set,L=new Set,re=z=>{!h(z)||!z.targetSourceNodeId||(k.has(z.targetSourceNodeId)?ee(z.targetSourceNodeId):w.has(z.targetSourceNodeId)&&F(z.targetSourceNodeId))},ee=z=>{let G=`resource:${z}`;if(!(O.has(G)||L.has(G))){L.add(G);for(let q of m.get(z)??[])re(q);L.delete(G),O.add(G),_.push(Object.freeze({sourceNodeId:z,role:"resource",viaResourceReferenceId:$.get(z)??null}))}},F=z=>{let G=`fragment:${z}`;if(!(O.has(G)||L.has(G))){L.add(G);for(let q of A.get(z)??[])re(q);L.delete(G),O.add(G),_.push(Object.freeze({sourceNodeId:z,role:"referenced-fragment",viaResourceReferenceId:$.get(z)??null}))}};for(let z of P)re(z);let V=u.filter(z=>T.has(z.resourceReferenceId)),H=_.flatMap(z=>z.role==="resource"?[z.sourceNodeId]:[]),X=l.filter(z=>z.memberSourceNodeIds.some(G=>k.has(G)));return Object.freeze({edges:Object.freeze(V),components:Object.freeze(X),resourceSourceNodeIds:Object.freeze(H),materializations:Object.freeze(_),diagnostics:b(V)})};for(let x of d.values())Object.freeze(x);Object.freeze(r),Object.freeze(u),Object.freeze(l),Object.freeze(p);let v=Object.freeze(nT(t));return Object.freeze({resources:r,edges:u,unboundStylesheetReferences:v,components:l,diagnostics:p,direct(x){return d.get(x)??Object.freeze([])},closureFromEdges(x){return S(x)},resolvePropertyValue(x,P,T){return Object.freeze((d.get(x)??[]).filter(k=>k.propertyName===P&&k.propertyValue===T))},templateChain(x){let P=[],T=new Set,k=x;for(;k&&!T.has(k);){T.add(k);let w=(d.get(k)??[]).find($=>$.fromSourceNodeId===k&&($.kind==="gradient-template"||$.kind==="pattern-template"));if(!w||(P.push(w),!w.targetSourceNodeId||!i.has(w.targetSourceNodeId)||w.validity==="missing"||w.validity==="invalid-target"))break;k=w.targetSourceNodeId}return Object.freeze(P)},closure(x){let P=x.map(O=>n.get(O)).filter(O=>!!O),T=new Set(P.filter(O=>i.has(O.sourceNodeId)).map(O=>O.sourceNodeId)),k=new Set;for(let O of P){let L=[O];for(;L.length>0;){let re=L.pop();k.has(re.sourceNodeId)||(k.add(re.sourceNodeId),L.push(...t.index.children(re.sourceNodeId)))}}let w=new Set;for(let O of k){i.has(O)&&!T.has(O)&&w.add(O);for(let L of d.get(O)??[])L.validity==="valid"&&L.targetSourceNodeId&&i.has(L.targetSourceNodeId)&&!T.has(L.targetSourceNodeId)&&w.add(L.targetSourceNodeId)}let $=[...T,...w];for(;$.length>0;){let O=$.pop();for(let L of a.get(O)??[])T.has(L)||w.has(L)||(w.add(L),$.push(L))}let R=l.filter(O=>O.memberSourceNodeIds.some(L=>w.has(L))),C=R.flatMap(O=>O.memberSourceNodeIds.filter(L=>w.has(L))),A=new Set([...T,...w]),D=u.filter(O=>k.has(O.fromSourceNodeId)||O.containingResourceSourceNodeId!==null&&A.has(O.containingResourceSourceNodeId)),_=[...new Set(D.flatMap(O=>f.get(O.fromSourceNodeId)??[]))];return Object.freeze({edges:Object.freeze(D),components:Object.freeze(R),resourceSourceNodeIds:Object.freeze(C),materializations:Object.freeze(C.map(O=>Object.freeze({sourceNodeId:O,role:"resource",viaResourceReferenceId:null}))),diagnostics:Object.freeze(_)})}})}function iT(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 oT="http://www.w3.org/2000/xmlns/",sT="http://www.w3.org/XML/1998/namespace",wy="http://www.w3.org/1999/xlink",aT=new Set(["class","id","lang","role","tabindex","xml:base","xml:lang","xml:space"]),lT=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"]),cT=new Set(["crossorigin","decoding","href","preserveaspectratio","refx","refy","requiredextensions","requiredfeatures","systemlanguage","target","type","viewbox","zoomandpan"]);function dT(t,e,n,r){let i=e.toLowerCase(),o=n.toLowerCase();return r===oT||i==="xmlns"||i.startsWith("xmlns:")?"namespace":r!==null&&r!==sT&&r!==wy||t!==W&&t!==null?"foreign":aT.has(i)?"metadata":i.startsWith("aria-")?"aria":i.startsWith("data-")?"data":/^on[a-z]/u.test(i)?"event-handler":Md.some(s=>s.toLowerCase()===i)?"conditional":i==="style"?"style":r===null&&Fd(i)?"presentation":r===null&&lT.has(o)?"geometry":r===wy||r===null&&cT.has(o)?"element-specific":"passthrough"}function jd(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:dT(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([])})}import{compile as uT}from"css-select";import{AttributeAction as Cy,SelectorType as _n,parse as $y}from"css-what";import{generate as pT,lexer as fT,parse as Ey}from"css-tree";var Ay="\0svgsketch-element-namespace",Hd="\0svgsketch-attribute-namespace\0",mT=new Set(["clip-path","mask","mask-image","filter","fill","stroke","marker","marker-start","marker-mid","marker-end"]),Ny=new Set(["inherit","initial","unset","revert","revert-layer"]),Ai=Object.freeze({a:0,b:0,c:0});function bn(t){return t?.children?.toArray()??[]}function sr(t){return typeof t=="string"?t:t?pT(t):""}function Wd(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 My(t,e){return t.a-e.a||t.b-e.b||t.c-e.c}function Ei(t,e){return{a:t.a+e.a,b:t.b+e.b,c:t.c+e.c}}function Oo(t){return t.reduce((e,n)=>My(n,e)>0?n:e,Ai)}function Kd(t){let e=Ai;for(let n of t){if(n.type===_n.Tag||n.type===_n.PseudoElement){e=Ei(e,{a:0,b:0,c:1});continue}if(n.type===_n.Attribute){let i=n.name==="id"&&n.action===Cy.Equals&&n.ignoreCase==="quirks";e=Ei(e,i?{a:1,b:0,c:0}:{a:0,b:1,c:0});continue}if(n.type!==_n.Pseudo)continue;let r=n.name.toLowerCase();if(r!=="where"){if((r==="is"||r==="not"||r==="has")&&Array.isArray(n.data)){e=Ei(e,Oo(n.data.map(i=>Kd(i))));continue}if((r==="nth-child"||r==="nth-last-child")&&typeof n.data=="string"){let i=Ai,o=/\bof\s+(.+)$/iu.exec(n.data);if(o)try{i=Oo($y(o[1]).map(Kd))}catch{i=Ai}e=Ei(Ei(e,{a:0,b:1,c:0}),i);continue}e=Ei(e,{a:0,b:1,c:0})}}return e}function gT(t){return{type:_n.Attribute,name:Ay,action:Cy.Equals,value:t,namespace:null,ignoreCase:!1}}function ky(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 Oy(t,e){let n=[];for(let r of t){if(r.type===_n.Tag||r.type===_n.Universal){let i={...r,namespace:null};n.push(i);let o=r.namespace??(e.has("")?"":null);o!==null&&o!=="*"&&n.push(gT(ky(o,e)));continue}if(r.type===_n.Attribute&&r.namespace!==null){if(r.namespace==="*")throw new Error("Wildcard attribute namespaces require an explicit namespace prefix.");let i=ky(r.namespace,e);n.push({...r,name:`${Hd}${i}\0${r.name}`,namespace:null});continue}if(r.type===_n.Pseudo&&Array.isArray(r.data)&&["is","where","not","has"].includes(r.name.toLowerCase())){n.push({...r,data:r.data.map(i=>Oy(i,e))});continue}n.push({...r})}return n}function hT(t){return t.children.filter(e=>e.kind!=="element").map(e=>e.value).join("")}function yT(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:Wd(o.occurrence.orderKey,s.occurrence.orderKey);for(let o of n.values())o.children.sort(i);return r.sort((o,s)=>Wd(o.occurrence.orderKey,s.occurrence.orderKey)),{roots:Object.freeze(r),byOccurrenceId:n}}function Dy(t){return t.kind==="text"?t.value:t.children.map(Dy).join("")}function ka(t){return t.kind==="text"?[]:[t,...t.children.flatMap(ka)]}function ST(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 Ry(t,e){if(e===Ay)return t.element.namespaceUri??"";if(e.startsWith(Hd)){let[n,r]=e.slice(Hd.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 bT(t){return{adapter:{isTag:n=>n.kind==="element",existsOne:(n,r)=>r.some(i=>ka(i).some(n)),getAttributeValue:Ry,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:Dy,hasAttrib:(n,r)=>Ry(n,r)!==void 0,removeSubsets:ST,findAll:(n,r)=>r.flatMap(ka).filter(n),findOne:(n,r)=>r.flatMap(ka).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 vT(t,e,n){try{let i=$y(t).map(o=>{let s=Oy(o,e),a=uT([s],n);return Object.freeze({matches:l=>a(l),specificity:Object.freeze(Kd(o))})});return Object.freeze(i)}catch{return null}}function xT(t){let e=[],n=0,r=null,i=!1,o=0,s=a=>{let l=t.slice(n,a).trim();l&&e.push(l)};for(let a=0;a<t.length;a++){let l=t[a];if(r){i?i=!1:l==="\\"?i=!0:l===r&&(r=null);continue}if(l==='"'||l==="'"){r=l;continue}l==="("?o++:l===")"?o=Math.max(0,o-1):o===0&&(/[\t\n\f\r ]/u.test(l)||l==="/")&&(s(a),l==="/"&&e.push("/"),n=a+1)}return s(t.length),e}function IT(t){let e=xT(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(d=>n.test(d));if(r<0)return null;let i="normal",o="normal",s="normal",a="normal";for(let d of e.slice(0,r)){let p=d.toLowerCase();p==="italic"||p==="oblique"?i=d:p==="small-caps"?o=d:p==="bold"||p==="bolder"||p==="lighter"||/^\d{1,4}$/u.test(p)?s=d:/^(?:ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded)$/u.test(p)&&(a=d)}let l=r+1,c="normal";e[l]==="/"&&(c=e[l+1]??"normal",l+=2);let u=e.slice(l).join(" ").trim();return u?Object.freeze({"font-style":i,"font-variant":o,"font-weight":s,"font-stretch":a,"font-size":e[r],"line-height":c,"font-family":u}):null}function wT(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=IT(t.value);return n?Object.entries(n).map(([r,i])=>({...t,propertyName:r,value:i,authoredValue:i})):[]}return e==="all"&&Ny.has(t.value.toLowerCase())?ba.map(n=>({...t,propertyName:n})):[t]}function kT(t,e){let n=e.trim().toLowerCase();if(t==="color-interpolation")return n==="auto"||n==="srgb"||n==="linearrgb";if(t!=="clip-path")return!1;if(Ny.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 Yd(t){let e;try{e=Ey(t,{context:"declarationList",positions:!0})}catch{return{declarations:Object.freeze([]),raw:Object.freeze({})}}let n=[],r={};for(let[i,o]of bn(e).entries()){if(o.type!=="Declaration"||typeof o.property!="string"||!o.value)continue;let s=o.property,a=s.startsWith("--")?s:s.toLowerCase(),l=typeof o.value!="string"&&o.value.loc?t.slice(o.value.loc.start.offset,o.value.loc.end.offset).trim():sr(o.value).trim();r[a]=l;let c=a.startsWith("--"),u=/(?:^|[^-_a-z0-9])var\(/iu.test(l);if(!(c||u||fT.matchProperty(a,o.value).matched||kT(a,l)))continue;let p={propertyName:a,authoredPropertyName:s,value:l,authoredValue:l,important:!!o.important,order:i};n.push(...wT(p))}return{declarations:Object.freeze(n),raw:Object.freeze(r)}}function RT(t){if(!t)return Object.freeze({values:Object.freeze({}),importantProperties:Object.freeze([])});let e=Yd(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 wa(t,e){let n=Yd(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 Ud(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 TT(t){let e=bn(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 PT(t){return sr(t.prelude).split(",").map(e=>e.trim()).filter(Boolean)}var CT=new Set(["default","inherit","initial","none","revert","revert-layer","unset"]);function $T(t){let e=bn(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"||CT.has(n.name.toLowerCase())?null:n.name}function ET(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 AT(t){return t.important?!1:t.propertyName==="animation-timing-function"||t.propertyName!=="animation"&&!t.propertyName.startsWith("animation-")}function NT(t,e,n){let r=$T(t);if(!r||!t.block)return null;let i=`${e.sourceNodeId}:keyframes:${n}`,o=new Map;for(let[a,l]of bn(t.block).entries()){if(l.type!=="Rule"||!l.prelude||!l.block)continue;let c=sr(l.prelude).split(",").map(ET).filter(p=>p!==null);if(c.length===0)continue;let u=bn(l.block).filter(p=>p.type==="Declaration").map(p=>sr(p)).join(";"),d=Yd(u).declarations.filter(AT);for(let p of c){let f=o.get(p)??new Map;for(let[g,m]of d.entries())f.set(m.propertyName,Object.freeze({declarationId:`${i}:${a}:${m.order}:${g}`,propertyName:m.propertyName,authoredPropertyName:m.authoredPropertyName,value:m.value,authoredValue:m.authoredValue,sourceOrder:Object.freeze([n,a,m.order,g])}));o.set(p,f)}}let s=[...o.entries()].sort(([a],[l])=>a-l).map(([a,l])=>Object.freeze({offset:a,declarations:Object.freeze([...l.values()]),properties:Xd([...l].map(([c,u])=>[c,u.value]))}));return Object.freeze({keyframesId:i,stylesheetSourceNodeId:e.sourceNodeId,name:r,sourceOrder:n,stops:Object.freeze(s)})}function MT(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:E(e,"id")??void 0,elementName:e.name,documentPath:n.index.sourcePath(e.sourceNodeId),message:r})}function Ty(t,e){return t.matchesMedia(e)===!0}function OT(t,e){return t.supportsCondition(e)===!0}function Py(t,e,n){let r=Number(t.declaration.important)-Number(e.declaration.important);if(r!==0)return r;let i=l=>l.declaration.important?l.layerRank===null?-1:n-l.layerRank:l.layerRank===null?n+1:l.layerRank,o=i(t)-i(e);if(o!==0)return o;let s=t.originRank-e.originRank;return s!==0?s:My(t.declaration.specificity,e.declaration.specificity)||Wd(t.declaration.sourceOrder,e.declaration.sourceOrder)}function DT(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 or(t,e,n=new Set){let r=mn(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 l=DT(s),c=(l<0?s:s.slice(0,l)).trim(),u=l<0?null:s.slice(l+1).trim();if(!c.startsWith("--")||n.has(c))a=u?or(u,e,n):null;else{let d=e[c];if(d===void 0)a=u?or(u,e,n):null;else{let p=new Set(n);p.add(c),a=or(d,e,p),a===null&&u&&(a=or(u,e,n))}}}else{let l=or(s,e,n);a=l===null?null:`${t.slice(o.tokenStart,o.argumentsStart)}${l})`}if(a===null)return null;i=`${i.slice(0,o.tokenStart)}${a}${i.slice(o.tokenEnd)}`}return i.trim()}function Xd(t){return Object.freeze(Object.fromEntries(t))}function qd(t,e,n){let r=[],i=yT(t,e),o=bT(n.environment),s=[],a=[],l=[],c=[],u=new Map,d=0,p=0,f=0,g=w=>{let $=u.get(w);if($!==void 0)return $;let R=u.size;return u.set(w,R),R},m=(w,$,R,C)=>{for(let A of w){if(A.type==="Atrule"){let H=A.name?.toLowerCase();if(H==="keyframes"){let X=NT(A,$,f++);X&&(l.push(X),$.keyframesIds.push(X.keyframesId));continue}if(H==="namespace"){let X=TT(A);X&&R.set(X.prefix,X.uri);continue}if(H==="layer"){let X=PT(A);if(!A.block){for(let q of X)g(q);continue}let z=X[0]??`__anonymous_${d++}`,G=C?`${C}.${z}`:z;g(G),m(bn(A.block),$,new Map(R),G);continue}if(H==="media"){let X=sr(A.prelude).trim();A.block&&Ty(n.environment,X)&&m(bn(A.block),$,new Map(R),C);continue}if(H==="supports"){let X=sr(A.prelude).trim();A.block&&OT(n.environment,X)&&m(bn(A.block),$,new Map(R),C);continue}continue}if(A.type!=="Rule"||!A.prelude||!A.block)continue;let D=sr(A.prelude).trim(),_=vT(D,R,o);if(!_)continue;let O=`${$.sourceNodeId}:rule:${p}`,L=bn(A.block).filter(H=>H.type==="Declaration").map(H=>sr(H)).join(";"),re=C===null?null:g(C),ee=wa(L,{sourceNodeId:$.sourceNodeId,origin:"stylesheet",ruleId:O,sourceOrder:[$.sourceNodeId===t.root.sourceNodeId?-1:p,p],layerRank:re}),F=ee.templates.map(H=>Ud(H,"",Oo(_.map(X=>X.specificity)))),V=Object.freeze({ruleId:O,stylesheetSourceNodeId:$.sourceNodeId,selectorText:D,specificities:Object.freeze(_.map(H=>H.specificity)),layer:C,declarations:Object.freeze(F)});a.push(V),c.push(Object.freeze({plan:V,selectors:_,templates:ee.templates})),$.ruleIds.push(O),p++}};for(let w of t.index.elements){if(w.namespaceUri!==W||w.localName.toLowerCase()!=="style")continue;let $=hT(w),R=E(w,"type"),C=E(w,"media"),A=R===null||R.trim()===""||R.trim().toLowerCase()==="text/css",D=C===null||C.trim()===""||Ty(n.environment,C),_=[],O=[],L={sourceNodeId:w.sourceNodeId,authoredText:$,id:E(w,"id"),type:R,media:C,title:E(w,"title"),applicable:A&&D,ruleIds:_,keyframesIds:O};if(s.push(L),!L.applicable){Object.freeze(_),Object.freeze(O),Object.freeze(L);continue}try{let re=Ey($,{positions:!0});m(bn(re),L,new Map,null)}catch{r.push(MT(n,w,t,"The SVG style element contains malformed CSS."))}Object.freeze(_),Object.freeze(O),Object.freeze(L)}let h=new Map;for(let w of l)h.set(w.name,w);let b=new Map,S=new Map,v=w=>{let $=b.get(w.occurrence.occurrenceId);if($)return $;let R=w.parent?v(w.parent):null,C=new Map,A=[],D=[],_=(z,G,q)=>{let te=Ud(z,w.occurrence.occurrenceId,G);A.push(te);let ie=C.get(te.propertyName)??[];ie.push({declaration:te,layerRank:z.layerRank,originRank:q}),C.set(te.propertyName,ie)};for(let[z,G]of w.element.attributes.entries()){if(G.namespaceUri!==null||!Ar(G.localName))continue;let q={sourceNodeId:w.element.sourceNodeId,origin:"presentation",ruleId:null,sourceOrder:[w.element.elementOrder,-2,z],layerRank:null},te=wa(`${G.localName}:${G.value}`,q).templates,ie=G.localName==="font-size"?ot(G.value):null;te.length===0&&ie?.unit===""&&ie.value>=0&&(te=wa(`font-size:${ie.value}px`,q).templates.map(J=>Object.freeze({...J,value:G.value,authoredValue:G.value})));for(let J of te)J.important||_(J,Ai,0)}for(let z of c){let G=z.selectors.filter(te=>te.matches(w));if(G.length===0)continue;D.push(z.plan.ruleId);let q=Oo(G.map(te=>te.specificity));for(let te of z.templates)_(te,q,1)}let O=E(w.element,"style");if(O!==null){let z=wa(O,{sourceNodeId:w.element.sourceNodeId,origin:"style-attribute",ruleId:null,sourceOrder:[w.element.elementOrder,Number.MAX_SAFE_INTEGER],layerRank:null});S.set(w.occurrence.occurrenceId,z.raw);for(let G of z.templates)_(G,Ai,2)}let L=new Map,re=new Map;for(let[z,G]of C){G.sort((te,ie)=>Py(te,ie,u.size)),L.set(z,G[G.length-1].declaration);let q=G.filter(te=>te.declaration.origin==="stylesheet");q.length>0&&re.set(z,q[q.length-1].declaration)}let ee={...R?.customProperties??{}};for(let[z,G]of L){if(!z.startsWith("--"))continue;let q=G.value.trim().toLowerCase();q==="inherit"||q==="unset"?R?.customProperties[z]===void 0?delete ee[z]:ee[z]=R.customProperties[z]:q==="initial"||q==="revert"||q==="revert-layer"?delete ee[z]:ee[z]=G.value}let F={},V={},H=new Set([...ba,...[...L.keys()].filter(z=>!z.startsWith("--"))]);for(let z of H){let G=Ar(z),q=L.get(z),te=R?.resolvedValues[z],ie=G?.initialValue,J;if(q){let Fe=q.value.trim().toLowerCase();Fe==="inherit"?J=te??ie:Fe==="initial"||Fe==="revert"||Fe==="revert-layer"?J=ie:Fe==="unset"?J=G?.inherited?te??ie:ie:J=q.value}else G?.inherited?J=te??ie:J=ie;if(J===void 0)continue;F[z]=J;let ke=or(J,ee);ke===null&&(ke=G?.inherited?te??ie??null:ie??null),ke!==null&&(ke.trim().toLowerCase()==="currentcolor"&&(ke=z==="color"?R?.resolvedValues.color??"black":V.color??R?.resolvedValues.color??"black"),V[z]=ke)}let X=Object.freeze({occurrenceId:w.occurrence.occurrenceId,correspondingSourceNodeId:w.occurrence.correspondingSourceNodeId,matchedRuleIds:Object.freeze(D),declarations:Object.freeze(A),cascadedValues:Xd(L),stylesheetCascadedValues:Xd(re),specifiedValues:Object.freeze(F),resolvedValues:Object.freeze(V),customProperties:Object.freeze(ee),inlineDeclarations:S.get(w.occurrence.occurrenceId)??Object.freeze({})});return b.set(w.occurrence.occurrenceId,X),X};for(let w of i.byOccurrenceId.values())v(w);let I=Object.freeze(e.occurrences.map(w=>b.get(w.occurrenceId)).filter(w=>w!==void 0)),x=new Map;for(let w of e.occurrences){if(w.usePath.length!==0)continue;let $=b.get(w.occurrenceId);$&&x.set(w.correspondingSourceNodeId,$)}let P=[];for(let w of I)for(let[$,R]of Object.entries(w.resolvedValues)){if(!mT.has($)||!R.toLowerCase().includes("url("))continue;let C=w.cascadedValues[$];P.push(Object.freeze({fromSourceNodeId:w.correspondingSourceNodeId,occurrenceId:w.occurrenceId,propertyName:$,value:R,origin:C?C.origin==="style-attribute"?"inline-style":"matched-stylesheet":"inherited-stylesheet"}))}let T=(w,$)=>{let R=i.byOccurrenceId.get(w);if(!R)return Object.freeze({});let C={...R,attributeOverrides:Object.freeze({class:$})},A=new Map;for(let F of c){let V=F.selectors.filter(X=>X.matches(C));if(V.length===0)continue;let H=Oo(V.map(X=>X.specificity));for(let X of F.templates){let z=Ud(X,w,H),G=A.get(z.propertyName)??[];G.push({declaration:z,layerRank:X.layerRank,originRank:1}),A.set(z.propertyName,G)}}let D=new Map;for(let[F,V]of A)V.sort((H,X)=>Py(H,X,u.size)),D.set(F,V[V.length-1].declaration);let _=R.parent?b.get(R.parent.occurrence.occurrenceId):null,O={..._?.customProperties??{}};for(let[F,V]of D){if(!F.startsWith("--"))continue;let H=V.value.trim().toLowerCase();if(H==="inherit"||H==="unset"){let X=_?.customProperties[F];X===void 0?delete O[F]:O[F]=X}else H==="initial"||H==="revert"||H==="revert-layer"?delete O[F]:O[F]=V.value}let L={},re=D.get("color"),ee=re?or(re.value,O):_?.resolvedValues.color??"black";for(let[F,V]of D){if(F.startsWith("--"))continue;let H=or(V.value,O);H!==null&&(H.trim().toLowerCase()==="currentcolor"&&(H=ee??"black"),L[F]=H)}return Object.freeze(L)},k=Object.freeze({stylesheets:Object.freeze(s),rules:Object.freeze(a),keyframes:Object.freeze(l),elements:I,appliedResourceDeclarations:Object.freeze(P),keyframesRule:w=>h.get(w)??null,ownStyle:w=>x.get(w)??null,style:w=>b.get(w)??null,value:(w,$)=>b.get(w)?.resolvedValues[$.toLowerCase()]??null,stylesheetValuesWithClass:T});return Object.freeze({value:k,diagnostics:Object.freeze(r)})}function Zd(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 zy(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 Ra(t){let e=t.state;if(typeof e.d=="string")return e.d;let n=Zt(t);if(!n)return null;switch(n.kind){case"path":return n.d||null;case"rectangle":return n.pathData??Zd(n.x,n.y,n.width,n.height,n.rx,n.ry);case"circle":return zy(n.cx,n.cy,n.r,n.r);case"ellipse":return zy(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 zT=new Map([["animate","animate"],["animatetransform","animateTransform"],["animatemotion","animateMotion"],["set","set"],["discard","discard"]]);function _T(t){return Object.freeze(Object.fromEntries(t.attributes.map(e=>[e.name,e.value])))}function FT(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function LT(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&FT(r,e))??t.direct(n)}function BT(t,e,n,r){let i=Ee(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!==W&&a.namespaceUri!==null)return{status:"invalid",sourceNodeId:s.sourceNodeId,occurrenceId:null};let l=LT(e,r,a.sourceNodeId);return{status:l?"resolved":"missing",sourceNodeId:a.sourceNodeId,occurrenceId:l?.occurrenceId??null}}function GT(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 VT(t,e,n,r){let i=t.index.children(n.sourceNodeId).find(d=>(d.namespaceUri===W||d.namespaceUri===null)&&d.localName.toLowerCase()==="mpath");if(!i)return{sourceNodeId:null,data:E(n,"path")};let o=Ee(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:E(a,"d")};let l=e.direct(a.sourceNodeId),c=l?r?.candidate(l.occurrenceId):null;if(!c||c.status!=="materialized"||!c.canonicalType)return{sourceNodeId:a.sourceNodeId,data:null};let u={id:c.occurrenceId,type:c.canonicalType,state:c.state};return{sourceNodeId:a.sourceNodeId,data:Ra(u)}}function jT(t,e,n,r){let i=[];for(let o of e.occurrences){let s=t.index.element(o.correspondingSourceNodeId);if(!s||s.namespaceUri!==W&&s.namespaceUri!==null)continue;let a=zT.get(s.localName.toLowerCase());if(!a)continue;let l=BT(t,e,s,o)??GT(t,e,o),c=_T(s),u={values:c.values,from:c.from,to:c.to,by:c.by,additive:c.additive,dur:c.dur,keyTimes:c.keyTimes,calcMode:c.calcMode,keySplines:c.keySplines,repeatCount:c.repeatCount,repeatDur:c.repeatDur,fill:c.fill},d=a==="animateMotion"?VT(t,e,s,r):null,p=l.sourceNodeId?t.index.element(l.sourceNodeId):null,f=(l.occurrenceId?n.style(l.occurrenceId)?.cascadedValues.transform?.value:void 0)??(p?E(p,"transform"):null),g=pd(u);i.push(Object.freeze({animationId:`smil:${o.occurrenceId}`,sourceNodeId:s.sourceNodeId,occurrenceId:o.occurrenceId,kind:a,sourceAnimationId:E(s,"id"),targetStatus:l.status,targetSourceNodeId:l.sourceNodeId,targetOccurrenceId:l.occurrenceId,attributeName:E(s,"attributeName"),attributes:c,duration:fd(u),additive:g,...a==="animateTransform"&&g==="replace"&&f!==null&&f.trim().toLowerCase()!=="none"?{replacesCarrierBase:!0}:{},fill:c.fill==="freeze"?"freeze":"remove",motionPathSourceNodeId:d?.sourceNodeId??null,motionPathData:d?.data??null}))}return Object.freeze(i)}function UT(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 HT(t){let e=[];for(let n of t.elements){let r=n.resolvedValues,i=r.animation||_g(r);if(i)for(let[o,s]of _s(i).entries()){let a=_c(s);if(!a){let c=Fs(r["animation-name"],o);c&&c!=="none"&&(a=_c(`${s} ${c}`))}if(!a)continue;zg(a,r,o);let l=t.keyframesRule(a.name);!l||l.stops.length===0||e.push(Object.freeze({animationId:`css:${n.occurrenceId}:${o}`,sourceNodeId:n.correspondingSourceNodeId,occurrenceId:n.occurrenceId,animationIndex:o,animation:UT(a),keyframes:l}))}}return Object.freeze(e)}function _y(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 Jd(t,e,n,r){let i=jT(t,e,n,r.leafGeometry),o=HT(n),s=i.filter(u=>u.targetStatus!=="resolved").map(u=>{let d=t.index.element(u.sourceNodeId);return Object.freeze({severity:"warning",code:"unresolved-reference",source:r.source,entrypoint:r.entrypoint,capability:"smil-animation",sourceId:u.sourceAnimationId??void 0,sourceNodeId:u.sourceNodeId,occurrenceId:u.occurrenceId,elementName:d?.name,documentPath:t.index.sourcePath(u.sourceNodeId),message:`The SVG animation target is ${u.targetStatus} and cannot be materialized.`})});for(let u of o)for(let d of u.keyframes.stops){let p=d.properties.transform??d.properties["-webkit-transform"]??d.properties["-moz-transform"];if(p===void 0)continue;let f=lh(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:u.sourceNodeId,occurrenceId:u.occurrenceId,documentPath:t.index.sourcePath(u.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=_y(i),l=_y(o),c=Object.freeze({smil:i,css:o,smilForOccurrence:u=>a.get(u)??Object.freeze([]),cssForOccurrence:u=>l.get(u)??Object.freeze([])});return Object.freeze({value:c,diagnostics:Object.freeze(s)})}var WT=new Set(["circle","ellipse","flowroot","foreignobject","image","line","path","polygon","polyline","rect","text"]),KT=Object.freeze({});function eu(t){if(Array.isArray(t))return Object.freeze(t.map(eu));if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))e[n]=eu(r);return Object.freeze(e)}return t}function XT(t){return eu(t)}function YT(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 YT(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function ZT(t,e,n,r,i){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"geometry",sourceId:E(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:i})}function De(t,e,n,r,i={}){return Object.freeze({occurrenceId:t.occurrenceId,sourceNodeId:e.sourceNodeId,sourceId:E(e,"id"),elementName:e.localName,canonicalType:n,status:r,state:Object.keys(i).length===0?KT:XT(i)})}function Nr(t,e,n,r){let i=t.style(e.occurrenceId);return i?.cascadedValues[r]?i.resolvedValues[r]??i.specifiedValues[r]??null:E(n,r)}function JT(t,e,n){let r=t.value(e.occurrenceId,"font-size");if(!r||r==="medium")return n.rootFontSize;let i=Se(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 tu(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 nu(t){if(t===null)return null;let e=/\S+/.exec(t.trim());return e?e[0].replace(/,$/,""):null}function Qd(t,e,n,r,i,o,s){return Se(nu(Nr(t,e,n,r)),tu(i,o,s))}function By(t){if(t===null||t.trim()==="")return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function QT(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 eP(t){let e=E(t,"transform");if(!e||e.trim()==="")return{rotation:0};let n=Dt(e);return Kt(n)?{rotation:0}:{transformMatrix:at(n)}}function vn(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 Gy(t){let e=[],n=0,r=0,i=0,o=0,s=0,a=0,l="",c=!1,u=!1;for(let d of t){let p=d.type.toUpperCase(),f=d.type===d.type.toLowerCase(),g=l.toUpperCase()==="Z",m=e.length;if(!(p==="B"||p==="R")){if(p==="Z"){n=i,r=o,c=!0,u||=e.length>1,l=d.type;continue}if(p==="M"){let[h,b]=vn(d,0,n,r),S={x:h,y:b,pointType:"corner"};e.length>0&&(S.isSubpathStart=!0),e.push(S),n=i=h,r=o=b,l=d.type;continue}if(p==="H")n=d.params[0]+(f?n:0),e.push({x:n,y:r,pointType:"corner",segmentType:"HORIZONTAL"}),u=!0;else if(p==="V")r=d.params[0]+(f?r:0),e.push({x:n,y:r,pointType:"corner",segmentType:"VERTICAL"}),u=!0;else if(p==="L")[n,r]=vn(d,0,n,r),e.push({x:n,y:r,pointType:"corner"}),u=!0;else if(p==="C"){let h=n,b=r,[S,v]=vn(d,0,h,b),[I,x]=vn(d,2,h,b),[P,T]=vn(d,4,h,b),k=e.at(-1);k&&(k.pointType="smooth",k.handleOut={x:S,y:v}),e.push({x:P,y:T,handleIn:{x:I,y:x},pointType:"smooth"}),n=P,r=T,s=I,a=x,u=!0}else if(p==="S"){let h=n,b=r,[S,v]=vn(d,0,h,b),[I,x]=vn(d,2,h,b),P=e.at(-1);P&&(P.pointType="smooth",P.handleOut=/^[CcSs]$/.test(l)?{x:2*h-s,y:2*b-a}:{x:h,y:b}),e.push({x:I,y:x,handleIn:{x:S,y:v},pointType:"smooth",segmentType:"SMOOTH_CUBIC"}),n=I,r=x,s=S,a=v,u=!0}else if(p==="Q"||p==="T"){let h=n,b=r,S=p==="T",[v,I]=S?/^[QqTt]$/.test(l)?[2*h-s,2*b-a]:[h,b]:vn(d,0,h,b),[x,P]=vn(d,S?0:2,h,b),T=e.at(-1);T&&(T.pointType="smooth",T.handleOut={x:v,y:I});let k={x,y:P,pointType:"smooth",segmentType:S?"SMOOTH_QUADRATIC":"QUADRATIC"};e.push(k),n=x,r=P,s=v,a=I,u=!0}else if(p==="A"){let h=n,b=r,[S,v]=vn(d,5,h,b),I=Math.abs(d.params[0]),x=Math.abs(d.params[1]),P={x:S,y:v,pointType:"corner"};I!==0&&x!==0&&(S!==n||v!==r)&&(P.segmentType="ARC",P.arcParams={rx:I,ry:x,rotation:d.params[2],largeArc:d.params[3]===1,sweep:d.params[4]===1}),(S!==n||v!==r)&&(e.push(P),u=!0),n=S,r=v}g&&e.length>m&&(e[m].isSubpathStart=!0),l=d.type}}return{points:e,closed:c,drawn:u}}function tP(t){return t.replace(/[\t\n\r ]+/g," ").trim()}function Vy(t){let e=[];for(let n of t.children)if(n.kind==="text"||n.kind==="cdata"){let r=tP(n.value);r&&e.push(r)}else if(n.kind==="element"){let r=Vy(n);r&&e.push(r)}return e.join(" ")}function nP(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function rP(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&nP(r,e))??t.direct(n)}function iP(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 oP(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}:iP(t,e)==="preserve"?{mode:"preserve-spaces",authored:null}:{mode:"collapse",authored:i==="normal"?"normal":null}}function Pa(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 Do(t,e){return t.children.map(n=>n.kind==="text"||n.kind==="cdata"?Pa(n.value,e):n.kind==="element"?Do(n,e):"").join("")}function sP(t,e,n){let r=e;for(;r&&r.sourceNodeId!==t.root.sourceNodeId;){if(r.localName.toLowerCase()==="svg"){let i=Xe(E(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 iu(t,e,n){return t.attributes.find(r=>r.prefix===e&&r.localName===n)?.value??null}function ht(t,e,n,r,i,o=r*.5){let s=Fc(t).at(0);if(s)return Xn(s,{percentBasis:e==="x"?n.width:n.height,viewportWidth:n.width,viewportHeight:n.height,fontSize:r,rootFontSize:i,xHeight:o})}function aP(t,e,n,r,i,o){let s=t.children.filter(S=>S.kind==="element"&&S.localName.toLowerCase()==="tspan"),a=S=>Pa(S,e);if(s.length===0){let S=a(Do(t,e));e==="collapse"&&(S=S.replace(/ {2,}/g," ").replace(/^ +| +$/g,""));let v=S.split(`
11
+ `).map(I=>({text:I,x:0,dy:0}));return{text:S,lines:v,linePositions:null}}let l=.001,c=ht(E(t,"x"),"x",n,r,i,o)??0,u=ht(E(t,"y"),"y",n,r,i,o)??null,d=[],p=!1,f=(S,v)=>{if(e!=="collapse")return S;let I=S.replace(/ {2,}/g," ");return v&&(I=I.replace(/^ +/,"")),I.replace(/ +$/,"")},g=(S,v,I,x)=>{if(!S)return;let P=I===null?0:(ht(I,"x",n,r,i,o)??c)-c,T=e==="preserve-newlines"?S.split(`
12
+ `):[S];for(let k=0;k<T.length;k++){let w=T[k],$=k>0,R=k===0&&v||$;!w&&!$||(R&&p?d.push({text:w,x:k===0?P:0,dy:k===0?x:0}):p?d[d.length-1].text+=w:d.push({text:w,x:k===0?P:0,dy:0}),w&&(p=!0))}},m=S=>{let v=E(S,"x");if(iu(S,"sodipodi","role")==="line"){let T=ht(E(S,"y"),"y",n,r,i,o),k=T!==void 0&&u!==null&&Math.abs(T-u)>.5?T-u:0;return{brk:!0,x:v,dy:k}}let x=E(S,"dy");if(x!==null){let T=ht(x,"y",n,r,i,o)??0;if(T>l||T<-l&&v!==null)return{brk:!0,x:v,dy:T}}let P=ht(E(S,"y"),"y",n,r,i,o);if(P!==void 0&&u!==null&&Math.abs(P-u)>.5)return{brk:!0,x:v,dy:P-u};if(v!==null&&p){let T=ht(v,"x",n,r,i,o);if(T!==void 0&&T<=c+.5)return{brk:!0,x:v,dy:0}}return{brk:!1,x:null,dy:0}},h=(S,v)=>{let I=!1;for(let x of S.children){if(x.kind==="text"||x.kind==="cdata"){let $=a(x.value);if(!$)continue;if(e!=="preserve-newlines"&&/^ +$/.test($)){if(p&&d.length>0){let C=d[d.length-1].text;e==="collapse"?C.endsWith(" ")||(d[d.length-1].text+=" "):d[d.length-1].text+=$}continue}let R=v.active&&!I;g($,R,R?v.x:null,R?v.dy:0),I=!0;continue}if(x.kind!=="element"||x.localName.toLowerCase()!=="tspan")continue;let P=m(x),T=ht(E(x,"y"),"y",n,r,i,o);T!==void 0&&(u=T);let k={active:v.active&&!I||P.brk,x:P.brk?P.x:v.active&&!I?v.x:null,dy:P.brk?P.dy:v.active&&!I?v.dy:0};x.children.some($=>$.kind==="element"&&$.localName.toLowerCase()==="tspan")?h(x,k):g(a(Do(x,e)),k.active,k.x,k.dy),I=!0}};h(t,{active:!1,x:null,dy:0});for(let S=0;S<d.length;S++)d[S].text=f(d[S].text,S===0);let b=d.some((S,v)=>v>0&&Math.abs(S.dy)>l||Math.abs(S.x)>l)?d.map(S=>({x:S.x,dy:S.dy})):null;return{text:d.map(S=>S.text).join(`
13
+ `),lines:d,linePositions:b}}function jy(t){return t&&t.split(",").map(n=>n.trim().replace(/^['"]|['"]$/g,"").trim()).filter(Boolean).join(", ")||null}function lP(t,e,n,r,i,o){let s=Ni(t,e,n,"font-size"),a=Ot(s);return a!==void 0&&a>=0?a:r}function Fy(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 Ni(t,e,n,r){let i=E(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 Uy(t){if(!t)return 400;if(t==="normal"||t==="bold")return t;let e=Number(t);return Number.isFinite(e)?e:400}function cP(t){let e=Uy(t);return e===400||e==="normal"?"normal":e===700||e==="bold"?"bold":e}function Ly(t,e,n){let r=k=>e?t.value(e.occurrenceId,k):null,i=r("text-decoration")?.toLowerCase()??"",o=jy(r("font-family"))??"Arial",s=r("font-style"),a=s==="italic"||s==="oblique"?s:"normal",l=r("line-height"),c=l?Number(l):NaN,u=r("fill"),d=(k,w)=>Ot(r(k))??w,p=r("font-variant")??"",f=r("baseline-shift"),g=f?Ot(f):void 0,m=f==="baseline"||f==="super"||f==="sub"?f:g??"baseline",h=r("dominant-baseline"),b=new Set(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),S=r("writing-mode"),v=S==="tb"||S==="tb-rl"?"vertical-rl":S==="lr"||S==="lr-tb"||S==="rl"||S==="rl-tb"?"horizontal-tb":S,I=r("direction"),x=r("unicode-bidi"),P=r("text-anchor"),T=r("text-transform");return{...ai,textDecoration:{underline:i.includes("underline"),strikethrough:i.includes("line-through"),overline:i.includes("overline")},fontVariationSettings:{},fontFamily:o,fontSize:n,fontWeight:cP(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:!u||u.toLowerCase()==="black"?"#000000":u,stroke:r("stroke")??"none",lineHeight:Number.isFinite(c)?c:1.2,textTransform:T==="capitalize"||T==="uppercase"||T==="lowercase"?T:"none",baselineShift:m,dominantBaseline:b.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:P==="middle"||P==="end"?P:"start",letterSpacing:d("letter-spacing",0),wordSpacing:d("word-spacing",0),fillOpacity:Number(r("fill-opacity")??1),strokeWidth:d("stroke-width",0),strokeOpacity:Number(r("stroke-opacity")??1)}}function dP(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 l=t.value(e.occurrenceId,"font-size"),c=Se(l,{percentBasis:n,viewportWidth:i.width,viewportHeight:i.height,fontSize:n,rootFontSize:o,xHeight:r});return c!==void 0&&c>=0?c:n}function uP(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 pP(t){return ru(t).filter(e=>e.localName.toLowerCase()==="tspan"&&!e.children.some(n=>n.kind==="element"&&n.localName.toLowerCase()==="tspan"))}function Ta(t,e,n,r,i,o){return t?Fc(t).map(s=>({value:Xn(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 fP(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 mP(t,e,n,r,i,o,s){let a=pP(t),l=a.length>0?a:[t],c=Array.from(e,()=>({x:null,y:null,dx:0,dy:0,rotate:0})),u=0,d=!1;for(let p of l){let f=Pa(Do(p,n),n),g=a.length>0?Math.max(u,e.indexOf(f,u)):0,m=Ta(E(p,"dx"),"x",r,i,o,s),h=Ta(E(p,"dy"),"y",r,i,o,s),b=Ta(E(p,"x"),"x",r,i,o,s),S=Ta(E(p,"y"),"y",r,i,o,s),v=fP(E(p,"rotate")),I=v.at(-1)??0,x=m.length>1||h.length>1||b.length>1||S.length>1||v.length>1,P=iu(p,"sodipodi","role")==="line",T=h[0]?.value,k=a.length>0&&!x&&(P||T!=null&&(T>.001||T<-.001&&E(p,"x")!==null));for(let w=0;w<f.length&&g+w<c.length;w++){let $=c[g+w],R=a.length===0,C=k?null:R?w>0?b[w]?.value??null:null:x?b[w]?.value??null:w===0?b[0]?.value??null:null,A=k?null:R?w>0?S[w]?.value??null:null:x?S[w]?.value??null:w===0?S[0]?.value??null:null,D=k?0:x?m[w]?.value??0:w===0?m[0]?.value??0:0,_=k?0:x?h[w]?.value??0:w===0?h[0]?.value??0:0,O=v[w]??I;Object.assign($,{x:C,y:A,dx:D,dy:_,rotate:O});let L={},re=R&&w===0?null:x?b[w]?.raw:w===0?b[0]?.raw:null,ee=R&&w===0?null:x?S[w]?.raw:w===0?S[0]?.raw:null,F=x?m[w]?.raw:w===0?m[0]?.raw:null,V=x?h[w]?.raw:w===0?h[0]?.raw:null;!k&&re&&(L.x=re),!k&&ee&&(L.y=ee),!k&&F&&(L.dx=F),!k&&V&&(L.dy=V),Object.keys(L).length>0&&($.raw=L),(C!==null||A!==null||D!==0||_!==0||O!==0)&&(d=!0)}u=Math.max(u,g+f.length)}return d?c:null}function gP(t,e,n){let r=e.children.find(m=>m.kind==="element"&&m.localName.toLowerCase()==="textpath");if(!r)return{isTextPath:!1};let i={isTextPath:!1},o=E(r,"side");o==="right"&&(i.textPathSide=o);let s=E(r,"method");(s==="align"||s==="stretch")&&(i.textPathMethod=s);let a=E(r,"spacing");(a==="auto"||a==="exact")&&(i.textPathSpacing=a);let l=E(r,"startOffset");if(l){let m=Number.parseFloat(l);Number.isFinite(m)&&(i.textPathStartOffset=m,i.textPathStartOffsetUnit=l.trim().endsWith("%")?"%":"user")}let c=E(r,"lengthAdjust");(c==="spacing"||c==="spacingAndGlyphs")&&(i.textPathLengthAdjust=c);let u=E(r,"textLength");if(u){let m=Number.parseFloat(u);Number.isFinite(m)&&m>=0&&(i.textPathLength=m,i.textPathLengthUnit=u.trim().endsWith("%")?"%":"user")}let d=E(r,"path");d&&(i.textPathInlineFormat="path-attr");let p=null;if(!d){let m=Ee(r)?.value;if(!m){let h=r.children.find(b=>b.kind==="element"&&b.localName.toLowerCase()==="mpath");m=h?Ee(h)?.value:void 0}if(m?.startsWith("#")){i.textPathImportRefId=m.slice(1);let h=t.index.resolveAuthoredId(m.slice(1));p=h?t.index.element(h.sourceNodeId):null,d=p?E(p,"d"):null}}if(!d)return i;let f=Gy(Qn(d).commands);if(f.points.length<2)return i;i.isTextPath=!0,i.textPathPoints=f.points;let g=By(p?E(p,"pathLength"):null);return g!==void 0&&g>=0&&(i.textPathPathLength=g),i.x=-n/2,i.y=-n/2,i}function hP(t,e,n,r,i,o,s,a,l,c,u,d){if(!t.children.some(k=>k.kind==="element"&&k.localName.toLowerCase()==="tspan"))return null;let f=Ly(r,e,s),g=[{segments:[]}],m=!1,h=!1,b=ht(E(t,"y"),"y",l,s,c,u)??null,S=ht(E(t,"x"),"x",l,s,c,u)??0,v=k=>Pa(k,o),I=(k,w,$)=>{if(!k)return;let R=o==="preserve-newlines"?k.split(`
14
+ `):[k];for(let C=0;C<R.length;C++){let A=R[C],D=C>0;if(!A&&!D)continue;let _={text:A,style:uo(f,w)};(C===0&&$||D)&&m?g.push({segments:[_]}):g[g.length-1].segments.push(_),A&&(m=!0),Un(w,f)||(h=!0)}},x=(k,w,$)=>{if(iu(k,"sodipodi","role")==="line")return!0;let R=E(k,"x"),C=E(k,"dy");if(C!==null){let D=ht(C,"y",l,w,c,$)??0;if(D>.001||D<-.001&&R!==null)return!0}let A=ht(E(k,"y"),"y",l,w,c,$);if(A!==void 0&&b!==null&&Math.abs(A-b)>.5)return!0;if(R!==null&&m){let D=ht(R,"x",l,w,c,$);if(D!==void 0&&D<=S+.5)return!0}return!1},P=(k,w,$,R,C)=>{let A=!1;for(let D of k.children){if(D.kind==="text"||D.kind==="cdata"){let X=v(D.value);if(!X)continue;if(o!=="preserve-newlines"&&/^ +$/.test(X)){if(m){let z=g.at(-1)?.segments.at(-1);z&&(o==="collapse"?z.text.endsWith(" ")||(z.text+=" "):z.text+=X)}continue}I(X,w,$&&!A),A=!0;continue}if(D.kind!=="element"||D.localName.toLowerCase()!=="tspan")continue;let _=rP(n,e,D.sourceNodeId),O=_?dP(r,_,R,C,l,c):R,L=_?Ly(r,_,O):w,re=uP(L,O,R,C,d),ee=x(D,O,re),F=ht(E(D,"y"),"y",l,O,c,re);F!==void 0&&(b=F);let V=$&&!A||ee;D.children.some(X=>X.kind==="element"&&X.localName.toLowerCase()==="tspan")?P(D,L,V,O,re):I(v(Do(D,o)),L,V),A=!0}};if(P(t,f,!1,s,u),o==="collapse")for(let k=0;k<g.length;k++){let w=g[k],$=!1;for(let C of w.segments)C.text=C.text.replace(/ {2,}/g," "),$&&C.text.startsWith(" ")&&(C.text=C.text.slice(1)),$=C.text.endsWith(" ");if(k===0){let C=w.segments.find(A=>A.text.length>0);C&&(C.text=C.text.replace(/^ +/,""))}let R=[...w.segments].reverse().find(C=>C.text.length>0);R&&(R.text=R.text.replace(/ +$/,"")),w.segments=w.segments.filter(C=>C.text.length>0)}return!h||g.map(k=>k.segments.map(w=>w.text).join("")).join(`
15
+ `)!==i?null:{lines:g,baseStyle:f,lineHeight:a}}function ru(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 yP(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 SP=[["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 bP(t,e,n){let r={},i=T=>Ni(t,e,n,T);for(let[T,k]of SP){let w=i(k);w&&w.trim()&&(r[T]=w.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 l=T=>{let k=i(T);if(k!=="normal")return Ot(k)},c=l("letter-spacing");c!==void 0&&(r.letterSpacing=c);let u=l("word-spacing");u!==void 0&&(r.wordSpacing=u);let d=i("text-transform");d&&(r.textTransform=d.trim());let p=i("baseline-shift");p&&(r.baselineShift=p.trim());let f=i("dominant-baseline");f&&(r.dominantBaseline=f.trim());let g=i("writing-mode");g&&(r.writingMode=g==="tb"||g==="tb-rl"?"vertical-rl":g==="vertical-lr"?"vertical-lr":"horizontal-tb");let m=Number.parseFloat(i("inline-size")??"");Number.isFinite(m)&&m>0&&(r.inlineSize=m);let b=i("shape-inside")?.match(/url\(\s*#([^)]+)\s*\)/)?.[1];b&&(r.shapeInsideImportRefId=b);let S=Number.parseFloat(i("shape-padding")??"");Number.isFinite(S)&&S>0&&(r.shapePadding=S);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 P=i("font-variation-settings");if(P&&P!=="normal"){let T={};for(let k of P.split(",")){let w=k.trim().match(/^['"](\w{4})['"]\s+([\d.eE+-]+)$/);if(!w)continue;let $=Number(w[2]);Number.isFinite($)&&(T[w[1]]=$)}Object.keys(T).length>0&&(r.fontVariationSettings=T)}return r}function vP(t,e,n,r,i,o,s){let a=n.localName.toLowerCase(),l=JT(i,e,o),c=(g,m)=>Qd(i,e,n,g,m,l,o),u=g=>{s.push(ZT(t,e,n,o,g))},d=eP(n),p=By(E(n,"pathLength")),f=g=>(p===void 0||(p<0?u("Path length must not be negative."):g.pathLength=p),g);if(a==="rect"){let g=c("x","x")??0,m=c("y","y")??0,h=c("width","x")??0,b=c("height","y")??0;if(h<0||b<0)return u("Rectangle width and height must not be negative."),De(e,n,null,"invalid");if(h===0||b===0)return De(e,n,null,"empty");let S=c("rx","x"),v=c("ry","y");(S!==void 0&&S<0||v!==void 0&&v<0)&&u("Rectangle corner radii must not be negative.");let I=S!==void 0&&S>=0,x=v!==void 0&&v>=0,P=Math.min(I?S:x?v:0,h/2),T=Math.min(x?v:I?S:0,b/2),k=f({x:g,y:m,width:h,height:b,rx:P,ry:T,cornerRadius:0});(P>0||T>0)&&Math.abs(P-T)<=1e-6&&(k.cornerRadius=P),Object.assign(k,d);let w=n.children.some(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&["x","y","width","height","rx","ry"].includes(E(R,"attributeName")??"")),$=Math.abs(h-b)<=1e-6&&Math.abs(P-T)<=1e-6&&!w?"square":"rectangle";return De(e,n,$,"materialized",k)}if(a==="circle"){let g=c("cx","x")??0,m=c("cy","y")??0,h=c("r","radius")??0;return h<0?(u("Circle radius must not be negative."),De(e,n,null,"invalid")):h===0?De(e,n,null,"empty"):De(e,n,"circle","materialized",f({x:g,y:m,radius:h,...d}))}if(a==="ellipse"){let g=c("cx","x")??0,m=c("cy","y")??0,h=c("rx","x"),b=c("ry","y");(h!==void 0&&h<0||b!==void 0&&b<0)&&u("Ellipse radii must not be negative.");let S=h!==void 0&&h>=0,v=b!==void 0&&b>=0,I=S?h:v?b:0,x=v?b:S?h:0;return I===0||x===0?De(e,n,null,"empty"):Math.abs(I-x)<=1e-6?De(e,n,"circle","materialized",f({x:g,y:m,radius:I,...d})):De(e,n,"ellipse","materialized",f({x:g,y:m,rx:I,ry:x,...d}))}if(a==="line"){let g={x1:c("x1","x")??0,y1:c("y1","y")??0,x2:c("x2","x")??0,y2:c("y2","y")??0};return f(g),Object.assign(g,d),De(e,n,"line","materialized",g)}if(a==="polyline"||a==="polygon"){let g=QT(E(n,"points"));if(g.odd&&u("The final unpaired polygon coordinate was ignored."),g.points.length===0)return De(e,n,"polyline","materialized",f({x:0,y:0,width:0,height:0,polylinePoints:[],polylineClosed:a==="polygon",...d}));let m=g.points.map(v=>v.x),h=g.points.map(v=>v.y),b=Math.min(...m),S=Math.min(...h);return De(e,n,"polyline","materialized",f({x:b,y:S,width:Math.max(...m)-b,height:Math.max(...h)-S,polylinePoints:g.points,polylineClosed:a==="polygon",...d}))}if(a==="path"){let g=Nr(i,e,n,"d")??"",m=/^path\(\s*(["'])([\s\S]*)\1\s*\)$/i.exec(g.trim()),h=m?m[2]:g;if(!h||h.trim().toLowerCase()==="none"){let $=n.children.find(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&E(R,"attributeName")==="d");$&&(h=E($,"from")??E($,"to")??"")}let b=Qn(h);b.error&&u(`Invalid path data: ${b.error.message}.`);let S=Gy(b.commands),v=["marker","marker-start","marker-mid","marker-end"].some($=>{let R=Nr(i,e,n,$)?.trim().toLowerCase();return R!=null&&R!==""&&R!=="none"}),I=Nr(i,e,n,"stroke-linecap")?.trim(),x=Nr(i,e,n,"stroke")?.trim().toLowerCase(),P=Qd(i,e,n,"stroke-width","radius",l,o),T=(I==="round"||I==="square")&&x!==void 0&&x!==null&&x!==""&&x!=="none"&&(P??1)>0;if(!S.drawn&&!(S.points.length>0&&(v||T)))return De(e,n,null,"empty");let k=sn(h);if(!k)return De(e,n,null,"empty");let w={x:k.minX,y:k.minY,width:k.maxX-k.minX,height:k.maxY-k.minY};return f(w),w.pathPoints=S.points,w.pathClosed=S.closed,w.pathCurveType=S.points.some($=>$.segmentType)?"mixed":S.points.some($=>$.handleIn||$.handleOut)?"cubic":"linear",w.pathTension=.5,Object.assign(w,d),De(e,n,"path","materialized",w)}if(a==="text"){let g=sP(t,n,o),m=oP(t,n,e,i),h=lP(i,e,n,l,g,o.rootFontSize),b=Fy(i,r,e,"font-family")?jy(Ni(i,e,n,"font-family"))??"Inter, sans-serif":"Inter, sans-serif",S=o.textMetricsHost?.measureXHeight(b,h),v=S!==void 0&&Number.isFinite(S)&&S>=0?S:h*.5,I=aP(n,m.mode,g,h,o.rootFontSize,v),x=I.text,P=Fy(i,r,e,"font-weight")?Uy(Ni(i,e,n,"font-weight")):400,T=Ni(i,e,n,"font-style")??"normal",k=Ni(i,e,n,"line-height"),w=k?Ot(k)??Number(k):NaN,$=Number.isFinite(w)?w:1.2,R=ht(nu(Nr(i,e,n,"x")),"x",g,h,o.rootFontSize,v)??0,C=ht(nu(Nr(i,e,n,"y")),"y",g,h,o.rootFontSize,v)??0,A={x:R,y:C,textX:R,textY:C,text:x,fontSize:h,fontFamily:b,fontWeight:P,fontStyle:T,lineHeight:$,useRichText:!1,isTextPath:!1};Object.assign(A,bP(i,e,n)),I.linePositions&&(A.linePositions=I.linePositions),m.authored&&m.authored!=="normal"&&(A.whiteSpace=m.authored);let D=mP(n,x,m.mode,g,h,o.rootFontSize,v);D&&(A.charOffsets=D);let _=D?null:hP(n,e,r,i,x,m.mode,h,$,g,o.rootFontSize,v,o.textMetricsHost);_&&(A.useRichText=!0,A.richTextData=_);let O=Qd(i,e,n,"textLength","x",l,o);O!==void 0&&O>=0&&(A.textLength=O);let L=E(n,"lengthAdjust");return(L==="spacing"||L==="spacingAndGlyphs")&&(A.lengthAdjust=L),Object.assign(A,gP(t,n,h)),Object.assign(A,d),De(e,n,"text","materialized",A)}if(a==="flowroot"){let g=ru(n).filter(S=>S.localName.toLowerCase()==="flowpara").map(Vy);if(g.every(S=>S.length===0))return De(e,n,null,"empty");let m=ru(n).find(S=>["rect","circle","ellipse","path"].includes(S.localName.toLowerCase())),h=0,b=0;return m?.localName.toLowerCase()==="rect"&&(h=Se(E(m,"x"),tu("x",l,o))??0,b=Se(E(m,"y"),tu("y",l,o))??0),De(e,n,"text","materialized",{x:h,y:b+l,text:g.join(`
16
+ `),fontSize:l,fontFamily:"Inter, sans-serif",fontWeight:400,fontStyle:"normal",lineHeight:1.2,useRichText:!1,isTextPath:!1,...d})}if(a==="image"){let g=c("x","x")??0,m=c("y","y")??0,h=c("width","x"),b=c("height","y"),S=Ee(n)?.value??"";if(!S||h===void 0||b===void 0)return De(e,n,null,"empty");if(h<0||b<0)return u("Image width and height must not be negative."),De(e,n,null,"invalid");if(h===0||b===0)return De(e,n,null,"empty");let v={x:g,y:m,width:h,height:b,...d};v.preserveAspectRatio=E(n,"data-preserve-aspect-ratio")!=="false";let I=E(n,"preserveAspectRatio")?.trim();return I&&I!=="none"&&(v.specPreserveAspectRatio=I),v.href=S,De(e,n,"image","materialized",v)}if(a==="foreignobject"){let g=c("x","x")??0,m=c("y","y")??0,h=c("width","x")??0,b=c("height","y")??0;if(h<0||b<0)return u("Foreign-object width and height must not be negative."),De(e,n,null,"invalid");if(h===0||b===0)return De(e,n,null,"empty");let S=n.rawXml??"",v=S.indexOf(">"),I=S.lastIndexOf("</"),x=v>=0&&I>v?S.slice(v+1,I):"";return De(e,n,"foreign-object","materialized",{x:g,y:m,width:h,height:b,rawContent:x,...d})}return De(e,n,null,"deferred")}function ou(t,e,n,r){let i=[],o=[],s=new Set,a=[...e.occurrences].sort(qT);for(let u of a){if(s.has(u.occurrenceId))throw new Error(`Duplicate SVG geometry occurrence ${u.occurrenceId}.`);s.add(u.occurrenceId);let d=t.index.element(u.correspondingSourceNodeId);if(!d)throw new Error(`SVG occurrence ${u.occurrenceId} has no source element.`);if(!(d.namespaceUri===W||t.root.namespaceUri===null&&d.namespaceUri===null))continue;let f=d.localName.toLowerCase();WT.has(f)&&(f!=="flowroot"&&yP(t,d)||o.push(vP(t,u,d,e,n,r,i)))}let l=new Map(o.map(u=>[u.occurrenceId,u])),c=Object.freeze({candidates:Object.freeze(o),candidate(u){return l.get(u)??null}});return Object.freeze({value:c,diagnostics:Object.freeze(i)})}var Hy={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 zo(t){let e=Hy[t.trim().toLowerCase()];return e===void 0?null:{r:e>>16&255,g:e>>8&255,b:e&255}}function su(t){return Hy[t.trim().toLowerCase()]!==void 0}var lu={color:"css-rgba",angle:"linear"},Ca={color:"legacy-rgb",angle:"shortest-arc"};function Ie(t,e,n){return t+(e-t)*n}function Jy(t,e,n,r){if(r==="linear")return Ie(t,e,n);let i=((e-t)%360+540)%360-180;return t+i*n}function xP(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=zo(e);return r?{...r,a:1}:null}function Qy(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 $a(t,e=lu.color){return e==="css-rgba"?xP(t):Qy(t)}function h1(t,e=lu.color){if(!t)return!1;if(e==="legacy-rgb")return Qy(t)!==null;if(t.startsWith("#")||t.startsWith("rgb"))return!0;let n=t.trim().toLowerCase();return n==="transparent"||n==="none"?!0:su(n)}function Wy(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 eS(t,e,n,r=lu.color){let i=$a(t,r),o=$a(e,r);if(!i||!o)return n<.5?t:e;if(r==="legacy-rgb")return Wy(Ie(i.r,o.r,n),Ie(i.g,o.g,n),Ie(i.b,o.b,n));let s=i.a===0?o.r:i.r,a=i.a===0?o.g:i.g,l=i.a===0?o.b:i.b,c=o.a===0?i.r:o.r,u=o.a===0?i.g:o.g,d=o.a===0?i.b:o.b,p=Ie(s,c,n),f=Ie(a,u,n),g=Ie(l,d,n),m=Ie(i.a,o.a,n);return m>=.999?Wy(p,f,g):`rgba(${Math.round(p)}, ${Math.round(f)}, ${Math.round(g)}, ${Math.round(m*1e3)/1e3})`}var tS="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",Ky=/[MLHVCSQTAZmlhvcsqtaz]/g;function Mi(t){return t.match(new RegExp(tS,"g"))}function y1(t){return(Mi(t)??[]).map(Number)}function nS(t,e,n){let r=Mi(t),i=Mi(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(tS,"g"),()=>{let l=Ie(o[a],s[a],n);return a++,String(Math.round(l*1e3)/1e3)})}function IP(t,e){let n=t.match(Ky)??[],r=e.match(Ky)??[];return n.length!==r.length?!1:n.every((i,o)=>i===r[o])}function S1(t,e,n){return n<=0?t:n>=1?e:IP(t,e)?nS(t,e,n):n<.5?t:e}function b1(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=Mi(t),i=Mi(e);return!r||!i||r.length!==i.length?n<.5?t:e:nS(t,e,n)}function v1(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=c=>{let u=c.trim().toLowerCase();if(!u||u==="none")return null;let d=(Mi(c)??[]).map(Number);return d.length===0||d.some(p=>!Number.isFinite(p)||p<0)?null:d},i=r(t),o=r(e);if(!i||!o)return n<.5?t:e;let s=(c,u)=>u===0?c:s(u,c%u),a=i.length*o.length/s(i.length,o.length),l=[];for(let c=0;c<a;c++)l.push(String(Ie(i[c%i.length],o[c%o.length],n)));return l.join(" ")}function ar(t){return Array.isArray(t)&&t.every(e=>typeof e=="number"&&Number.isFinite(e))}function au(t,e,n){return t.map((r,i)=>Ie(r,e[i],n))}function wP(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>({x:Ie(r.x,e[i].x,n),y:Ie(r.y,e[i].y,n)}))}function kP(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>{let o=e[i],s={...r,x:Ie(r.x,o.x,n),y:Ie(r.y,o.y,n)};return r.handleIn&&o.handleIn&&(s.handleIn={x:Ie(r.handleIn.x,o.handleIn.x,n),y:Ie(r.handleIn.y,o.handleIn.y,n)}),r.handleOut&&o.handleOut&&(s.handleOut={x:Ie(r.handleOut.x,o.handleOut.x,n),y:Ie(r.handleOut.y,o.handleOut.y,n)}),s})}function RP(t,e,n,r=Ca.angle){return t.length!==e.length?n<.5?t:e:t.map((i,o)=>{let s=e[o],a={...i},l=(c,u)=>c==null||u==null?c??u??null:Ie(c,u,n);return("x"in i||"x"in s)&&(a.x=l(i.x,s.x)),("y"in i||"y"in s)&&(a.y=l(i.y,s.y)),typeof i.dx=="number"&&typeof s.dx=="number"&&(a.dx=Ie(i.dx,s.dx,n)),typeof i.dy=="number"&&typeof s.dy=="number"&&(a.dy=Ie(i.dy,s.dy,n)),typeof i.rotate=="number"&&typeof s.rotate=="number"&&(a.rotate=Jy(i.rotate,s.rotate,n,r)),a})}function Xy(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 TP(t,e,n,r=Ca.color){if(t.type!==e.type||t.stops.length!==e.stops.length)return null;let i=t.stops.map((s,a)=>({offset:Ie(s.offset,e.stops[a].offset,n),color:eS(s.color,e.stops[a].color,n,r),opacity:Ie(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],l=e[s];typeof a=="number"&&typeof l=="number"&&(o[s]=Ie(a,l,n))}return o}function Yy(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 qy(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function PP(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]=Ie(s,a,n):ar(s)&&ar(a)&&s.length===a.length?r[o]=au(s,a,n):r[o]=n<.5?s:a}return r}var CP=new Set(["fillColor","borderColor"]),$P=new Set(["polylinePoints"]),EP=new Set(["pathPoints","textPathPoints"]),AP=new Set(["rotation","shiftAngle","skewX","skewY"]),NP=new Set(["customPivot"]),Zy=[1,0,0,1,0,0];function MP(t,e,n,r){if(!(NP.has(t)&&(e==null||n==null))){if(t==="children"&&Array.isArray(e)&&Array.isArray(n))return DP(e,n,r);if(t==="transformMatrix"){let i=ar(e)?e:e==null&&ar(n)?Zy:null,o=ar(n)?n:n==null&&ar(e)?Zy:null;if(i&&o&&i.length===o.length)return au(i,o,r)}if(!(e==null&&n==null)){if(e==null)return n;if(n==null)return e;if(CP.has(t)&&typeof e=="string"&&typeof n=="string")return eS(e,n,r,Ca.color);if(AP.has(t)&&typeof e=="number"&&typeof n=="number")return Jy(e,n,r,Ca.angle);if(typeof e=="number"&&typeof n=="number")return Ie(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(Ie(i,o,r)):r<.5?e:n}if(ar(e)&&ar(n)&&e.length===n.length)return au(e,n,r);if($P.has(t)&&Array.isArray(e)&&Array.isArray(n))return wP(e,n,r);if(EP.has(t)&&Array.isArray(e)&&Array.isArray(n))return kP(e,n,r);if(t==="charOffsets"&&Array.isArray(e)&&Array.isArray(n))return RP(e,n,r);if((t==="fillGradient"||t==="strokeGradient")&&Xy(e)&&Xy(n)){let i=TP(e,n,r);if(i)return i}return Yy(e)&&Yy(n)?{x:Ie(e.x,n.x,r),y:Ie(e.y,n.y,r)}:qy(e)&&qy(n)?PP(e,n,r):r<.5?e:n}}}function OP(t,e,n){let r={...t},i=new Set([...Object.keys(t),...Object.keys(e)]);for(let o of i)r[o]=MP(o,t[o],e[o],n);return r}function DP(t,e,n){let r=Math.max(0,Math.min(1,n)),i=new Map(t.map(l=>[l.id,l])),o=new Map(e.map(l=>[l.id,l])),s=[],a=new Set;for(let l of e){let c=i.get(l.id);if(c&&c.type===l.type)a.add(l.id),s.push({...l,state:OP(c.state,l.state,r)});else{let u=l.state.opacity??1;s.push({...l,state:{...l.state,opacity:u*r}})}}for(let l of t){if(a.has(l.id))continue;let c=l.state.opacity??1,u=o.has(l.id)?rS(l,"__variant_from__"):l;s.push({...u,state:{...u.state,opacity:c*(1-r)}})}return s}function rS(t,e){let n=t.state.children;return{...t,id:`${e}${t.id}`,state:{...t.state,...Array.isArray(n)?{children:n.map(r=>rS(r,e))}:{}}}}function zP(t,e,n,r,i,o,s,a){if(t!=="mask"||e||n!=="userSpaceOnUse"||r.length!==1||!Kt(s))return!1;let l=r[0],c=i.candidate(l.occurrenceId);if(!c||c.status!=="materialized"||c.canonicalType!=="rectangle"&&c.canonicalType!=="square")return!1;let u=c.state;if(u.transformMatrix!==void 0||u.rawTransform!==void 0)return!1;let d=$a(o.value(l.occurrenceId,"fill")??"black");if(!d||d.r!==255||d.g!==255||d.b!==255||d.a!==1)return!1;let p=Number(o.value(l.occurrenceId,"fill-opacity")??1),f=Number(o.value(l.occurrenceId,"opacity")??1);if(p!==1||f!==1)return!1;let g=Number(u.x??0),m=Number(u.y??0),h=Number(u.width??u.size),b=Number(u.height??u.size),S=(v,I)=>Math.abs(v-I)<=1e-9;return S(g,0)&&S(m,0)&&S(h,a.viewport.width)&&S(b,a.viewport.height)}var uu=new Set(["animate","animatemotion","animatetransform","set"]),Aa=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),oS=new Set(["a","g","switch","use"]),pu=new Set(["desc","metadata","title"]),_P=new Set([...uu,...pu,"circle","ellipse","line","path","polygon","polyline","rect","text","use"]);function _o(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))_o(e);return Object.freeze(t)}function sS(t){if(t.namespaceUri!==W)return null;let e=t.localName.toLowerCase();return e==="clippath"?"clip":e==="mask"?"mask":null}function Fo(t,e,n,r,i){let o=sS(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:E(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 cu(t,e,n,r,i,o){let s=E(e,i);return s===null||s===""?o:s==="userSpaceOnUse"||s==="objectBoundingBox"?s:(r.push(Fo(t,e,n,i,s)),o)}function du(t,e,n,r,i,o,s,a,l){let c=r.value(n.occurrenceId,s)??E(e,s);if(c===null||c.trim()==="")return l;let u=c.trim();return a.includes(u)?u:(o.push(Fo(t,e,i,s,c)),l)}function FP(t,e,n,r){let i={x:E(e,"x"),y:E(e,"y"),width:E(e,"width"),height:E(e,"height")},{x:o,y:s,width:a,height:l}=i;if([o,s,a,l].every(d=>d===null))return null;let c={x:"-10%",y:"-10%",width:"120%",height:"120%"},u=Object.fromEntries(Object.entries(i).map(([d,p])=>p===null?[d,c[d]]:ot(p)?[d,p]:(r.push(Fo(t,e,n,d,p)),[d,c[d]])));return Object.freeze({x:u.x,y:u.y,width:u.width,height:u.height})}function iS(t){let e=ot(t);return!!(e&&e.value<=0)}function aS(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 lS(t,e,n){let r=t.index.parent(e);for(;r&&r.sourceNodeId!==n;){if(Aa.has(r.localName.toLowerCase()))return!0;r=t.index.parent(r.sourceNodeId)}return r===null}function fu(t,e,n){let r=new Map(n.map(i=>[i.occurrenceId,i]));return n.filter(i=>aS(i,e,r)?!(i.usePath.length===0&&lS(t,i.correspondingSourceNodeId,e.correspondingSourceNodeId)):!1)}function mu(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 LP(t,e,n,r,i){let o=n.occurrences,s=new Map(r.candidates.map(c=>[c.occurrenceId,c])),a=new Set(n.resolutions.map(c=>c.useOccurrenceId)),l=new Map(o.map(c=>[c.occurrenceId,c]));for(let c of fu(t,e,o)){if(!mu(c,e,l,i))continue;let u=t.index.element(c.correspondingSourceNodeId);if(!u)return!0;let d=u.localName.toLowerCase();if(uu.has(d)||d==="style"||d==="script"||["clip-path","mask","filter"].some(f=>(i.value(c.occurrenceId,f)??"").includes("url(")))return!0;if(pu.has(d))continue;if(oS.has(d)){if(d!=="use")continue;return a.has(c.occurrenceId),!0}if(Aa.has(d)){if(c.usePath.length>0)return!0;continue}let p=s.get(c.occurrenceId);if(!p||p.status==="deferred")return!0}return!1}function BP(t,e,n,r,i){let o=new Map(r.candidates.map(c=>[c.occurrenceId,c])),s=new Set(n.resolutions.map(c=>c.useOccurrenceId)),a=new Map(n.occurrences.map(c=>[c.occurrenceId,c])),l=!1;for(let c of fu(t,e,n.occurrences)){if(!mu(c,e,a,i))continue;let u=t.index.element(c.correspondingSourceNodeId);if(!u)return!1;let d=u.localName.toLowerCase();if(pu.has(d))continue;if(uu.has(d)||d==="style"||d==="script"||["clip-path","mask","filter"].some(f=>(i.value(c.occurrenceId,f)??"").includes("url(")))return!1;if(d==="use"){if(c.parentOccurrenceId!==e.occurrenceId||c.usePath.length>0||E(u,"id")!==null||!s.has(c.occurrenceId))return!1;l=!0;continue}if(oS.has(d)||Aa.has(d))return!1;let p=o.get(c.occurrenceId);if(!p||p.status!=="materialized")return!1}return l}function GP(t,e,n,r){let i=E(e,"transform");if(!i)return Oe;let o=Xt(i);return o||(r.push(Fo(t,e,n,"transform",i)),Oe)}function VP(t,e,n,r,i,o,s){let a=sS(e);if(!a)return null;let l=n.direct(e.sourceNodeId);if(!l)throw new Error(`SVG ${e.name} ${e.sourceNodeId} has no occurrence.`);let c=new Map(n.occurrences.map(C=>[C.occurrenceId,C])),u=i.candidates.flatMap(C=>{let A=c.get(C.occurrenceId);return!A||!aS(A,l,c)||A.usePath.length===0&&lS(t,C.sourceNodeId,e.sourceNodeId)||!mu(A,l,c,r)?[]:C.status==="materialized"?[A]:[]}),d=a==="clip"&&n.resourcePolicy(e.sourceNodeId)?.status==="invalid",p=a==="clip"&&t.index.children(e.sourceNodeId).some(C=>!_P.has(C.localName.toLowerCase()));if(p&&s.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:o.source,entrypoint:o.entrypoint,capability:"clip-definitions",sourceId:E(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(C=>{if(C.namespaceUri!==W||C.localName.toLowerCase()!=="use")return!1;let A=t.index.parent(C.sourceNodeId);for(;A&&A.sourceNodeId!==e.sourceNodeId;){if(Aa.has(A.localName.toLowerCase()))return!1;A=t.index.parent(A.sourceNodeId)}return A?.sourceNodeId===e.sourceNodeId})&&n.resourcePolicy(e.sourceNodeId)===null)throw new Error(`SVG ${e.name} ${e.sourceNodeId} requires a matching use resource-root plan.`);let g=a==="mask"?FP(t,e,o,s):null,m=!!(g&&(iS(g.width)||iS(g.height))),h=LP(t,l,n,i,r),b=h&&!BP(t,l,n,i,r)?[]:u,S=d||p?"invalid":m||!h&&u.length===0?"empty":"materialized",v=a==="clip"?cu(t,e,o,s,"clipPathUnits","userSpaceOnUse"):null,I=a==="clip"?du(t,e,l,r,o,s,"clip-rule",["nonzero","evenodd"],"nonzero"):null,x=a==="mask"?cu(t,e,o,s,"maskUnits","objectBoundingBox"):null,P=a==="mask"?cu(t,e,o,s,"maskContentUnits","userSpaceOnUse"):null,T=a==="mask"?du(t,e,l,r,o,s,"mask-type",["luminance","alpha"],"luminance"):null,k=GP(t,e,o,s),w=_o({sourceNodeId:e.sourceNodeId,sourceId:E(e,"id"),type:a,status:S,representation:h?"raw":"decomposed",identity:zP(a,h,P,u,i,r,k,o),clipPathUnits:v,clipRule:I,maskUnits:x,maskContentUnits:P,maskType:T,region:g,geometrySourceNodeIds:Object.freeze(h?[]:u.map(C=>C.correspondingSourceNodeId)),rawDefinition:h?e.rawXml??"":null}),$=new Map,R=new Map;for(let C of fu(t,l,n.occurrences)){let A=t.index.element(C.correspondingSourceNodeId);if(A){if(!$.has(A.sourceNodeId)){let D=E(A,"transform");if(!D)$.set(A.sourceNodeId,Oe);else{let _=Xt(D);_?$.set(A.sourceNodeId,_):(s.push(Fo(t,A,o,"transform",D)),$.set(A.sourceNodeId,Oe))}}a==="clip"&&R.set(C.occurrenceId,du(t,A,C,r,o,s,"clip-rule",["nonzero","evenodd"],w.clipRule??"nonzero"))}}return Object.freeze({definition:w,element:e,occurrence:l,rootTransform:k,transformBySourceNodeId:$,clipRuleByOccurrenceId:R,geometryOccurrences:Object.freeze(b)})}function jP(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 UP(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 HP(t){return de(_e(t.x,t.y),bi(t.width,t.height))}function WP(t,e){let r=(t.definition.type==="clip"?t.definition.clipPathUnits:t.definition.maskContentUnits)==="objectBoundingBox"?HP(e):Oe;return de(r,t.rootTransform)}function Ea(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(!ot(t))return null;if(e==="objectBoundingBox"){let u=Se(t,{percentBasis:1,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return u===void 0?null:a+u*s}let c=Se(t,{percentBasis:o?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return c===void 0?null:c}function KP(t,e,n){if(!t.region||!t.maskUnits)return null;let r=Ea(t.region.x,t.maskUnits,"x",e,n),i=Ea(t.region.y,t.maskUnits,"y",e,n),o=Ea(t.region.width,t.maskUnits,"width",e,n),s=Ea(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 XP(t,e,n,r,i){let o=new Map(r.occurrences.map(d=>[d.occurrenceId,d])),s=[],a=n.parentOccurrenceId,l=new Set;for(;a&&a!==e.occurrence.occurrenceId&&!l.has(a);){l.add(a);let d=o.get(a);if(!d)break;s.push(d),a=d.parentOccurrenceId}let c=Oe,u=e.definition.type==="clip"?e.definition.clipPathUnits:e.definition.maskContentUnits;for(let d of s.reverse()){let p=t.index.element(d.correspondingSourceNodeId);if(p&&(c=de(c,e.transformBySourceNodeId.get(p.sourceNodeId)??Oe),p.localName.toLowerCase()==="use")){let f=u==="objectBoundingBox"?1:i.viewport.width,g=u==="objectBoundingBox"?1:i.viewport.height,m=Se(E(p,"x"),{percentBasis:f,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0,h=Se(E(p,"y"),{percentBasis:g,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0;c=de(c,_e(m,h))}}return c}function gu(t,e,n,r,i,o){let s=[],a=t.index.elements.flatMap(m=>{let h=VP(t,m,e,n,i,o,s);return h?[h]:[]}),l=new Map(a.map(m=>[m.definition.sourceNodeId,m])),c=jP(r).flatMap(m=>{let h=UP(m,e,l);return h?[h]:[]}),u=new Map;for(let m of c){let h=`${m.consumerOccurrenceId}\0${m.propertyName}`,b=u.get(h)??[];b.push(m),u.set(h,b)}let d=new Map([...u].map(([m,h])=>[m,Object.freeze(h)])),p=Object.freeze(a.map(m=>m.definition)),f=Object.freeze(c),g=_o({definitions:p,bindings:f,definition(m){return l.get(m)?.definition??null},bindingsFor(m,h){return d.get(`${m}\0${h}`)??[]},binding(m,h,b){let S=d.get(`${m}\0${h}`)??[];return b===void 0?S[0]??null:S.find(v=>v.resourceReferenceId===b)??null},resolve(m,h){let b=m.definitionSourceNodeId?l.get(m.definitionSourceNodeId):void 0;if(!b||m.status!=="materialized")return _o({status:"invalid-reference",contentMatrix:null,region:null,geometrySourceNodeIds:[],geometryPlacements:[],rawDefinition:null});let S=WP(b,h.consumerObjectBounds),v=(b.definition.clipPathUnits==="objectBoundingBox"||b.definition.maskContentUnits==="objectBoundingBox"||b.definition.maskUnits==="objectBoundingBox")&&(h.consumerObjectBounds.width===0||h.consumerObjectBounds.height===0),I=b.definition.status==="empty"||v,x=(I?[]:b.geometryOccurrences).map(P=>Object.freeze({occurrenceId:P.occurrenceId,sourceNodeId:P.correspondingSourceNodeId,matrix:de(S,XP(t,b,P,e,o)),clipRule:b.definition.type==="clip"?b.clipRuleByOccurrenceId.get(P.occurrenceId)??b.definition.clipRule??"nonzero":null}));return _o({status:I?"empty":m.status,contentMatrix:S,region:KP(b.definition,h.consumerObjectBounds,o),geometrySourceNodeIds:I?[]:b.definition.geometrySourceNodeIds,geometryPlacements:x,rawDefinition:b.definition.rawDefinition})}});return Object.freeze({value:g,diagnostics:Object.freeze(s)})}var YP=new Set(["id","viewbox","preserveaspectratio","refx","refy","markerwidth","markerheight","markerunits","orient"]),qP=new Set(["a","circle","ellipse","foreignobject","g","image","line","path","polygon","polyline","rect","svg","switch","text","use"]),ZP=new Set(["animate","animatemotion","animatetransform","set"]),JP="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",QP=new RegExp(`^(${JP})(deg|grad|rad|turn)?$`,"i");function eC(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 tC(t,e){return eC(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function Oi(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"markers",sourceId:E(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Marker ${r} value ${i} ${o}.`})}function nC(t){let e=QP.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 rC(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length<1||e.length>2)return!1;let n=Mo(t);return e[0]!==n.align?!1:e.length===1||e[1]==="meet"||e[1]==="slice"}function iC(t,e){let n=E(e,"data-ssk-marker-name");if(n!==null)return n;let r=t??"marker";return r.replace(/^marker[-_]?/i,"").replace(/[-_]/g," ")||r}function oC(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&YP.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function sC(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 aC(t,e,n){let r=new Map(e.occurrences.map(u=>[u.occurrenceId,u])),i=e.occurrences.filter(u=>sC(u,n.occurrenceId,r)).sort(tC),o=new Set,s=[],a=[],l=u=>{let d=u.parentOccurrenceId;for(;d&&d!==n.occurrenceId&&!o.has(d);)d=r.get(d)?.parentOccurrenceId??null;return d===n.occurrenceId?null:d},c=u=>{if(u.usePath.length>0)return!1;let d=u.parentOccurrenceId;for(;d&&d!==n.occurrenceId;){let p=r.get(d);if(!p)return!1;if(t.index.element(p.correspondingSourceNodeId)?.localName.toLowerCase()==="defs")return!0;d=p.parentOccurrenceId}return!1};for(let u of i){let d=t.index.element(u.correspondingSourceNodeId);if(!d||d.namespaceUri!==W)continue;let p=d.localName.toLowerCase();if(ZP.has(p)){a.push(Object.freeze({occurrenceId:u.occurrenceId,sourceNodeId:u.correspondingSourceNodeId,parentOccurrenceId:l(u),elementName:d.name,orderKey:Object.freeze([...u.orderKey])}));continue}if(!qP.has(p)||c(u))continue;let f=l(u);o.add(u.occurrenceId),s.push(Object.freeze({occurrenceId:u.occurrenceId,sourceNodeId:u.correspondingSourceNodeId,parentOccurrenceId:f,elementName:d.name,orderKey:Object.freeze([...u.orderKey])}))}return{content:Object.freeze(s),animations:Object.freeze(a)}}function hu(t,e,n,r,i){let o=[],s=new Map,a=[],l=r.resources.filter(u=>u.kind==="marker").sort((u,d)=>{let p=t.index.element(u.sourceNodeId)?.elementOrder??0,f=t.index.element(d.sourceNodeId)?.elementOrder??0;return p-f});for(let u of l){let d=t.index.element(u.sourceNodeId);if(!d||d.namespaceUri!==W)continue;let p=e.occurrences.find(q=>q.correspondingSourceNodeId===u.sourceNodeId&&q.usePath.length===0);if(!p)continue;let f=E(d,"id"),g=n.style(p.occurrenceId),m=Se(g?.resolvedValues["font-size"]??null,{fontSize:i.rootFontSize,rootFontSize:i.rootFontSize,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height}),h=m&&m>0?m:i.rootFontSize,b=E(d,"viewBox"),S=b===null?null:Xe(b),v=!1,I=!1;b!==null&&(!S||S.width<0||S.height<0?(v=!0,o.push(Oi(t,d,i,"viewBox",b,"is not a valid four-number viewBox with non-negative dimensions"))):(S.width===0||S.height===0)&&(I=!0));let x=E(d,"preserveAspectRatio");x!==null&&!rC(x)&&(v=!0,o.push(Oi(t,d,i,"preserveAspectRatio",x,"does not match the SVG preserveAspectRatio grammar")));let P={},T=q=>{let te=E(d,q);return te!==null&&(P[q]=te),te},k=T("markerWidth"),w=T("markerHeight"),$=q=>({percentBasis:q==="width"?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,fontSize:h,rootFontSize:i.rootFontSize}),R=(q,te,ie)=>{if(te===null)return 3;let J=Se(te,$(ie));return J===void 0||J<0?(v=!0,o.push(Oi(t,d,i,q,te,J===void 0?"is not a resolvable length":"must not be negative")),3):(J===0&&(I=!0),J)},C=R("markerWidth",k,"width"),A=R("markerHeight",w,"height"),D={width:S?.width??C,height:S?.height??A},_=q=>{let te=T(q);if(te===null)return 0;let ie=te.trim(),J=q==="refX"?D.width:D.height;if(q==="refX"){if(ie==="left")return 0;if(ie==="center")return J/2;if(ie==="right")return J}else{if(ie==="top")return 0;if(ie==="center")return J/2;if(ie==="bottom")return J}let ke=Se(te,{...$(q==="refX"?"width":"height"),percentBasis:J});return ke!==void 0?ke:(v=!0,o.push(Oi(t,d,i,q,te,"is not a valid marker reference length or keyword")),0)},O=_("refX"),L=_("refY"),re=T("markerUnits"),ee="strokeWidth";re==="userSpaceOnUse"?ee="userSpaceOnUse":re!==null&&re!=="strokeWidth"&&(v=!0,o.push(Oi(t,d,i,"markerUnits",re,"must be strokeWidth or userSpaceOnUse")));let F=T("orient"),V=0;if(F==="auto"||F==="auto-start-reverse")V=F;else if(F!==null){let q=nC(F);q===null?(v=!0,o.push(Oi(t,d,i,"orient",F,"is not an orientation keyword, number, or angle"))):V=q}let H=E(d,"overflow"),X=H==="visible"||H==="hidden"?H:void 0,z=aC(t,e,p),G=Object.freeze({sourceNodeId:d.sourceNodeId,sourceId:f,name:iC(f,d),status:v?"invalid":I?"empty":"materialized",...b!==null?{viewBox:b}:{},...x!==null?{preserveAspectRatio:x}:{},refX:O,refY:L,markerWidth:C,markerHeight:A,markerUnits:ee,orient:V,...X?{overflow:X}:{},authoredGeometry:Object.freeze(P),rootAttributes:oC(d),content:z.content,animations:z.animations});s.set(G.sourceNodeId,G),a.push(G)}let c=Object.freeze({candidates:Object.freeze(a),candidate:u=>s.get(u)??null});return Object.freeze({value:c,diagnostics:Object.freeze(o)})}var mS=["x1","y1","x2","y2"],lC=["cx","cy","r","fx","fy","fr"],cS=Object.freeze({x1:0,y1:0,x2:1,y2:0});function Go(t){return t.namespaceUri!==W?null:t.localName.toLowerCase()==="lineargradient"?"linear-gradient":t.localName.toLowerCase()==="radialgradient"?"radial-gradient":null}function lr(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"gradients",sourceId:E(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Gradient ${r} value ${i} ${o}.`})}function cC(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||!Go(s))break;i.add(s.sourceNodeId),r.push(s)}return r}function dS(t,e,n){for(let r of t){if(n&&Go(r)!==n)continue;let i=E(r,e);if(i!==null)return i}return null}function uS(t,e,n){for(let r of t){if(n&&Go(r)!==n)continue;let i=E(r,e);if(i!==null)return Object.freeze({raw:i,ownerSourceNodeId:r.sourceNodeId})}return null}function dC(t,e,n,r){let i=t.direct(n.sourceNodeId);return i?e.value(i.occurrenceId,r):null}function gS(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:E(n,r)}function yu(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 pS(t,e,n,r){let i=dC(t,e,n,"font-size"),o=Se(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 Lo(t,e,n,r){if(e==="objectBoundingBox")return yu(t);let i=n==="x"?r.viewport.width:n==="y"?r.viewport.height:Math.hypot(r.viewport.width,r.viewport.height)/Math.SQRT2;return Se(t,{percentBasis:i,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.fontSize,rootFontSize:r.rootFontSize})??null}function Bo(t){return t==="r"||t==="fr"?"radius":t.endsWith("x")||t==="x1"||t==="x2"||t==="cx"||t==="fx"?"x":"y"}function hS(t,e){let n={};if(t.type==="linear-gradient"){for(let i of mS){let o=t.authoredGeometry[i];n[i]=o===void 0?cS[i]:Lo(o,t.gradientUnits,Bo(i),e)??cS[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]:Lo(o,t.gradientUnits,Bo(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:Lo(o,t.gradientUnits,Bo(i),e)??s}return Object.freeze(n)}function fS(t){return t.children.filter(e=>e.kind==="element"&&e.namespaceUri===W&&e.localName.toLowerCase()==="stop")}function uC(t,e,n,r,i,o){let s=e.find(f=>fS(f).length>0)??null,a=s?fS(s):[],l=[],c=0,u=e[0],d=n.direct(u.sourceNodeId),p=d?r.value(d.occurrenceId,"color"):null;for(let f of a){let g=E(f,"offset")??"0",m=yu(g);m===null&&o.push(lr(t,f,i,"offset",g,"is not a number or percentage"));let h=Math.min(1,Math.max(0,m??0)),b=Math.max(c,h);c=b;let S=n.direct(f.sourceNodeId),v=S?r.style(S.occurrenceId):null,I=(v?.cascadedValues["stop-color"]?v.specifiedValues["stop-color"]??v.resolvedValues["stop-color"]:E(f,"stop-color"))??"black",x=I.trim().toLowerCase(),P=/(?:^|[^-_a-z0-9])var\(/iu.test(I),T=x==="currentcolor"?p??"black":P?I:v?.resolvedValues["stop-color"]??I,k=gS(n,r,f,"stop-opacity")??"1",w=yu(k);w===null&&o.push(lr(t,f,i,"stop-opacity",k,"is not a number or percentage"));let $=Math.min(1,Math.max(0,w??1));T.trim().toLowerCase()==="transparent"&&(T="black",$=0),l.push(Object.freeze({occurrenceId:s?.sourceNodeId===u.sourceNodeId&&S?S.occurrenceId:`gradient-stop:${d?.occurrenceId??u.sourceNodeId}:${f.sourceNodeId}`,sourceNodeId:f.sourceNodeId,correspondingSourceNodeId:f.sourceNodeId,hostGradientSourceNodeId:u.sourceNodeId,offsetAuthored:E(f,"offset"),offset:b,color:T,opacity:$}))}return Object.freeze(l)}function pC(t,e,n,r,i,o,s){let a=Go(e),l=cC(t,i,e),c=E(e,"id"),u=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,d=dS(l,"gradientUnits"),p=!1,f="objectBoundingBox";d==="userSpaceOnUse"?f="userSpaceOnUse":d!==null&&d!=="objectBoundingBox"&&s.push(lr(t,e,o,"gradientUnits",d,"must be objectBoundingBox or userSpaceOnUse"));let g=dS(l,"spreadMethod"),m="pad";g==="reflect"||g==="repeat"?m=g:g!==null&&g!=="pad"&&s.push(lr(t,e,o,"spreadMethod",g,"must be pad, reflect, or repeat"));let h=gS(n,r,e,"color-interpolation"),b="sRGB";h==="auto"||h==="linearRGB"?b=h:h!==null&&h!=="sRGB"&&s.push(lr(t,e,o,"color-interpolation",h,"must be auto, sRGB, or linearRGB"));let S={},v={},I=a==="linear-gradient"?mS:lC;for(let R of I){let C=uS(l,R,a);if(!C)continue;S[R]=C.raw;let A=Lo(C.raw,f,Bo(R),{viewport:o.viewport,fontSize:pS(n,r,e,o),rootFontSize:o.rootFontSize});v[R]=Object.freeze({...C,validity:A===null?"invalid":"valid"})}let x=uS(l,"gradientTransform"),P=x?.raw??null,T=Xt(P??"");x&&(S.gradientTransform=x.raw,v.gradientTransform=Object.freeze({...x,validity:T===null?"invalid":"valid"}),T===null&&s.push(lr(t,e,o,"gradientTransform",x.raw,"does not match the SVG transform-list grammar")));for(let[R,C]of Object.entries(v))R==="gradientTransform"||C.validity==="valid"||s.push(lr(t,e,o,R,C.raw,"is not a valid gradient coordinate"));if(a==="radial-gradient")for(let R of["r","fr"]){let C=v[R];if(!C||C.validity!=="valid")continue;let A=Lo(C.raw,f,Bo(R),{viewport:o.viewport,fontSize:pS(n,r,e,o),rootFontSize:o.rootFontSize});A!==null&&A<0&&(p=!0,s.push(lr(t,e,o,R,C.raw,"must not be negative")))}let k=uC(t,l,n,r,o,s),w=Object.freeze(at(T??[1,0,0,1,0,0])),$=v.gradientTransform??null;return Object.freeze({occurrenceId:u,sourceNodeId:e.sourceNodeId,sourceId:c,type:a,status:p?"invalid":k.length===0?"empty":"materialized",gradientUnits:f,spreadMethod:m,colorInterpolation:b,authoredGeometry:Object.freeze(S),geometryValues:Object.freeze(v),transform:Object.freeze({authored:$,matrix:w}),stops:k,templateSourceNodeIds:Object.freeze(l.map(R=>R.sourceNodeId))})}function fC(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=Dn(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}),l=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:l,fallback:a})]});return Object.freeze(n)}function Su(t,e,n,r,i){let o=[],s=r.resources.filter(d=>d.kind==="gradient").map(d=>t.index.element(d.sourceNodeId)).filter(d=>!!(d&&Go(d))).sort((d,p)=>d.elementOrder-p.elementOrder).map(d=>pC(t,d,e,n,r,i,o)),a=new Map(s.map(d=>[d.sourceNodeId,d])),l=fC(r,a),c=new Map;for(let d of l){let p=c.get(d.occurrenceId)??[];p.push(d),c.set(d.occurrenceId,p)}for(let d of c.values())Object.freeze(d);let u=Object.freeze({candidates:Object.freeze(s),bindings:l,candidate:d=>a.get(d)??null,bindingsFor:d=>c.get(d)??Object.freeze([]),binding:(d,p,f)=>(c.get(d)??[]).find(g=>g.propertyName===p&&(f===void 0||g.resourceReferenceId===f))??null,resolveGeometry:(d,p)=>{let f=d.gradientSourceNodeId?a.get(d.gradientSourceNodeId):null;return f?hS(f,p):null}});return Object.freeze({value:u,diagnostics:Object.freeze(o)})}var mC=["x","y","width","height"],gC=new Set(["desc","metadata","title"]),hC=new Set(["defs","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]),yC=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(%)?$/u,SC=/^(?:none|x(?:Min|Mid|Max)Y(?:Min|Mid|Max))(?:\s+(?:meet|slice))?$/u;function yS(t){return!!(t&&t.namespaceUri===W&&t.localName.toLowerCase()==="pattern")}function SS(t){let e=yC.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?e[2]?n/100:n:null}function bC(t){if(t===null)return Object.freeze({value:"xMidYMid meet",valid:!0});let e=t.trim().replace(/\s+/gu," "),n=SC.test(e),r=Mo(n?e:null);return Object.freeze({value:`${r.align}${r.align==="none"&&!e.includes(" ")?"":` ${r.meetOrSlice}`}`,valid:n})}function Mr(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"patterns",sourceId:E(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Pattern ${r} value ${i} ${o}.`})}function vC(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(!yS(s))break;i.add(s.sourceNodeId),r.push(s)}return Object.freeze(r)}function Di(t,e){for(let n of t){let r=E(n,e);if(r!==null)return Object.freeze({raw:r,ownerSourceNodeId:n.sourceNodeId})}return null}function xC(t){return t.children.filter(e=>e.kind==="element"&&!gC.has(e.localName.toLowerCase()))}function IC(t){return t.find(e=>xC(e).length>0)??null}function wC(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 kC(t,e,n,r){let i=e;for(;i&&i.correspondingSourceNodeId!==n;){let o=t.index.element(i.correspondingSourceNodeId);if(o&&hC.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 RC(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(c=>[c.occurrenceId,c])),s=e.occurrences.filter(c=>c.occurrenceId!==i.occurrenceId&&wC(c,i.occurrenceId,o)&&kC(t,c,r.sourceNodeId,o)),a=new Set(s.map(c=>c.occurrenceId)),l=new Map(s.map(c=>[c.occurrenceId,`pattern-content:${n.sourceNodeId}:${c.occurrenceId}`]));return Object.freeze(s.map(c=>Object.freeze({occurrenceId:l.get(c.occurrenceId),sourceOccurrenceId:c.occurrenceId,sourceNodeId:c.correspondingSourceNodeId,correspondingSourceNodeId:c.correspondingSourceNodeId,hostPatternSourceNodeId:n.sourceNodeId,parentOccurrenceId:c.parentOccurrenceId&&a.has(c.parentOccurrenceId)?l.get(c.parentOccurrenceId)??null:null,role:c.role,shadow:c.usePath.length>0,orderKey:Object.freeze([...c.orderKey])})))}function TC(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 PC(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 CC(t,e,n,r){return e==="objectBoundingBox"?SS(t)===null?"invalid":"valid":Se(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 zi(t,e,n,r,i){return t===void 0?i:e==="objectBoundingBox"?SS(t)??i:Se(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 bS(t,e){if(t.status!=="materialized")return null;let n=zi(t.values.x?.raw,t.patternUnits,"x",e,0),r=zi(t.values.y?.raw,t.patternUnits,"y",e,0),i=zi(t.values.width?.raw,t.patternUnits,"x",e,0),o=zi(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 $C(t,e,n,r,i,o){let s=vC(t,r,e),a=E(e,"id"),l=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,c=Di(s,"patternUnits"),u="objectBoundingBox";c?.raw==="userSpaceOnUse"?u="userSpaceOnUse":c&&c.raw!=="objectBoundingBox"&&o.push(Mr(t,e,i,"patternUnits",c.raw,"must be objectBoundingBox or userSpaceOnUse"));let d=Di(s,"patternContentUnits"),p="userSpaceOnUse";d?.raw==="objectBoundingBox"?p="objectBoundingBox":d&&d.raw!=="userSpaceOnUse"&&o.push(Mr(t,e,i,"patternContentUnits",d.raw,"must be objectBoundingBox or userSpaceOnUse"));let f=!1,g={};for(let F of mC){let V=Di(s,F);if(!V)continue;let H=CC(V.raw,u,F==="x"||F==="width"?"x":"y",i);g[F]=Object.freeze({...V,validity:H}),H==="invalid"&&o.push(Mr(t,e,i,F,V.raw,"is not a valid pattern coordinate"))}let m={viewport:i.viewport,objectBounds:{x:0,y:0,width:1,height:1},fontSize:i.rootFontSize,rootFontSize:i.rootFontSize},h=zi(g.width?.raw,u,"x",m,0),b=zi(g.height?.raw,u,"y",m,0);for(let[F,V]of[["width",h],["height",b]])g[F]?.validity==="valid"&&V<0&&(f=!0,o.push(Mr(t,e,i,F,g[F].raw,"must not be negative")));let S=Di(s,"patternTransform"),v=S?Xt(S.raw):[1,0,0,1,0,0],I=v===null?"invalid":"valid";S&&I==="invalid"&&o.push(Mr(t,e,i,"patternTransform",S.raw,"does not match the SVG transform-list grammar"));let x=Object.freeze({raw:S?.raw??null,ownerSourceNodeId:S?.ownerSourceNodeId??null,matrix:Object.freeze(at(v??[1,0,0,1,0,0])),validity:I}),P=Di(s,"viewBox"),T=P?Xe(P.raw):null,k="valid";P&&(!T||T.width<0||T.height<0)&&(k="invalid",o.push(Mr(t,e,i,"viewBox",P.raw,"must be four numbers with non-negative width and height")));let w=P?Object.freeze({...P,validity:k}):null,$=T&&k==="valid"?Object.freeze([T.x,T.y,T.width,T.height]):null,R=Di(s,"preserveAspectRatio"),C=bC(R?.raw??null);R&&!C.valid&&o.push(Mr(t,e,i,"preserveAspectRatio",R.raw,"does not match the preserveAspectRatio grammar"));let A=R?Object.freeze({...R,validity:C.valid?"valid":"invalid"}):null,D=IC(s),_=RC(t,n,e,D),O=TC(r,D,_),L=PC(r,O),re=!!($&&($[2]===0||$[3]===0)),ee=f?"invalid":!D||h===0||b===0||re?"empty":"materialized";return Object.freeze({occurrenceId:l,sourceNodeId:e.sourceNodeId,sourceId:a,status:ee,patternUnits:u,patternContentUnits:p,values:Object.freeze(g),transform:x,viewBox:$,viewBoxAuthored:w,preserveAspectRatio:C.value,preserveAspectRatioAuthored:A,templateSourceNodeIds:Object.freeze(s.map(F=>F.sourceNodeId)),contentProviderSourceNodeId:D?.sourceNodeId??null,contentOccurrences:_,contentOccurrenceIds:Object.freeze(_.map(F=>F.occurrenceId)),resources:L})}function EC(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=Dn(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 bu(t,e,n,r,i){let o=[],s=r.resources.filter(d=>d.kind==="pattern").map(d=>t.index.element(d.sourceNodeId)).filter(yS).sort((d,p)=>d.elementOrder-p.elementOrder).map(d=>$C(t,d,e,r,i,o)),a=new Map(s.map(d=>[d.sourceNodeId,d])),l=EC(r,a),c=new Map;for(let d of l){let p=c.get(d.occurrenceId)??[];p.push(d),c.set(d.occurrenceId,p)}for(let d of c.values())Object.freeze(d);let u=Object.freeze({candidates:Object.freeze(s),bindings:l,candidate:d=>a.get(d)??null,bindingsFor:d=>c.get(d)??Object.freeze([]),binding:(d,p,f)=>(c.get(d)??[]).find(g=>g.propertyName===p&&(f===void 0||g.resourceReferenceId===f))??null,resolveTile:(d,p)=>{let f=d.patternSourceNodeId?a.get(d.patternSourceNodeId):null;return f?bS(f,p):null}});return Object.freeze({value:u,diagnostics:Object.freeze(o)})}var vS=new Map([["clippath","clipPath"],["filter","filter"],["lineargradient","linearGradient"],["mask","mask"],["pattern","pattern"],["radialgradient","radialGradient"],["symbol","symbol"]]),AC=new Set(["clipPathUnits","filterUnits","gradientUnits","maskContentUnits","maskUnits","patternContentUnits","patternUnits","primitiveUnits","spreadMethod"]);function NC(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 vu(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Na(t){return vu(t).replaceAll('"',"&quot;")}function MC(t){switch(t.kind){case"text":return vu(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 xS(t,e,n=[],r=!1){if(t.namespaceUri===W&&t.localName.toLowerCase()==="script"||r&&t.namespaceUri===W&&["animate","animatemotion","animatetransform","discard","set"].includes(t.localName.toLowerCase())&&!Ee(t))return"";let i=e.identifierBySourceNodeId.get(t.sourceNodeId),o=e.generatedIdBySourceNodeId.get(t.sourceNodeId),s=e.attributeRewrites.get(t.sourceNodeId),a=[],l=!1,c=!1;for(let g of n)a.push(`${g.name}="${Na(g.value)}"`);for(let g of t.attributes){if(/^on/iu.test(g.name))continue;g.name==="data-source-id"&&(l=!0),g.localName==="id"&&g.namespaceUri===null&&(c=!0);let m=g.localName==="id"&&g.namespaceUri===null&&i?i.liveId:g.localName==="id"&&g.namespaceUri===null&&o?o:s?.get(g.name)??g.value;m===""&&AC.has(g.name)||a.push(`${g.name}="${Na(m)}"`)}i?.restoreSourceId&&!l&&a.push(`data-source-id="${Na(i.sourceId)}"`),o&&!c&&a.push(`id="${Na(o)}"`);let u=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,d=e.textRewrites.get(t.sourceNodeId),p=d!==void 0?vu(d):t.children.map(g=>g.kind==="element"?xS(g,e,[],r):MC(g)).join(""),f=/\/\s*>\s*$/u.test(t.rawXml??"");return p.length===0&&f?`${u}/>`:`${u}>${p}</${t.name}>`}function OC(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 IS(t,e){let n=t.index.parent(e);for(;n;){if(n.namespaceUri===W&&n.localName.toLowerCase()==="defs")return!0;n=t.index.parent(n.sourceNodeId)}return!1}function DC(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 wS(t,e,n){if(e.namespaceUri!==W||e.localName.toLowerCase()!=="g"||!IS(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!==W)return null;let s=vS.get(o.localName.toLowerCase()),a=wS(t,o,n);if(!s&&!a)return null;let l=n.identifierBySourceNodeId.get(o.sourceNodeId);if(!l)return null;i.push({sourceId:l.liveId,destinationId:l.liveId})}return i}function xu(t,e,n){let r=[],i=OC(e),o=[];for(let c of t.index.elements){if(c.namespaceUri!==W)continue;let u=vS.get(c.localName.toLowerCase()),d=wS(t,c,i);if(!u&&!d)continue;let p=E(c,"id");if(!p)continue;let f=i.identifierBySourceNodeId.get(c.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(c.sourceNodeId),elementName:c.name,sourceId:p,sourceNodeId:c.sourceNodeId,capability:"paint-server-definitions"});continue}let g={id:f.liveId,type:u??c.localName,...d?{role:"referenced-fragment",definitionChildIds:d.map(m=>m.destinationId),sourceDefinitionChildIds:d.map(m=>m.sourceId)}:{},markup:xS(c,i,NC(t,c),u==="clipPath"||u==="mask"),passthrough:!0};o.push(DC({sourceNodeId:c.sourceNodeId,sourceId:p,destinationId:f.liveId,type:u??c.localName,insideDefs:IS(t,c.sourceNodeId),definition:g}))}let s=Object.freeze(o),a=new Map(s.map(c=>[c.sourceNodeId,c])),l=Object.freeze({candidates:s,candidate:c=>a.get(c)??null,definitions:(c=new Set)=>Object.freeze(s.filter(u=>!c.has(u.sourceNodeId)).map(u=>u.definition))});return Object.freeze({value:l,diagnostics:Object.freeze(r)})}var Ma=Object.freeze({x:"-10%",y:"-10%",width:"120%",height:"120%"}),zC=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u,_C=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(%)?$/u,FC=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(deg|grad|rad|turn)?$/iu,TS=new Set(["animate","animatemotion","animatetransform","set"]),LC=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 Dr(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))Dr(e);return Object.freeze(t)}function cr(t){return t.children.filter(e=>e.kind==="element")}function kS(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 Iu(t){return(t.rawXml??"").replace(/\s+xmlns="http:\/\/www\.w3\.org\/2000\/svg"/gu,"").replace(/\s+xmlns=""/gu,"")}function Fn(t){if(t===null||!zC.test(t.trim()))return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function Or(t,e){let n=E(t,e);return n===null?void 0:n}function Da(t,e,n=""){return`${t}:${e}${n}`}function Oa(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:E(n,"id")??void 0,occurrenceId:r,elementName:n.name,message:e})}function BC(t){let e=[...cr(t)];for(;e.length>0;){let n=e.pop();if(n.namespaceUri===W&&n.localName.toLowerCase()==="script")return!0;e.push(...cr(n))}return!1}function RS(t,e,n){let r=e.direct(t.sourceNodeId);return r?n.value(r.occurrenceId,"display"):E(t,"display")}function GC(t,e,n,r){if(RS(e,n,r)?.trim().toLowerCase()==="none")return!0;let i=t.index.parent(e.sourceNodeId);for(;i;){if(i.namespaceUri===W&&i.localName.toLowerCase()==="defs"&&RS(i,n,r)?.trim().toLowerCase()==="none")return!0;i=t.index.parent(i.sourceNodeId)}return!1}function VC(t){let e=E(t,"color-interpolation-filters"),n=E(t,"filterUnits"),r=E(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:E(t,"x")??Ma.x,y:E(t,"y")??Ma.y,width:E(t,"width")??Ma.width,height:E(t,"height")??Ma.height})}}function PS(t,e){let n=Or(e,"x"),r=Or(e,"y"),i=Or(e,"width"),o=Or(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=E(e,"filterUnits");(s==="userSpaceOnUse"||s==="objectBoundingBox")&&(t.filterUnits=s);let a=E(e,"primitiveUnits");(a==="userSpaceOnUse"||a==="objectBoundingBox")&&(t.primitiveUnits=a);let l=E(e,"color-interpolation-filters");(l==="auto"||l==="sRGB"||l==="linearRGB")&&(t.type==="raw-svg"?t.colorInterpolationFilters=l:t.filterColorInterpolation=l);let c=Or(e,"flood-color"),u=Or(e,"flood-opacity"),d=Or(e,"lighting-color");c!==void 0&&(t.floodColor=c),u!==void 0&&(t.floodOpacity=u),d!==void 0&&(t.lightingColor=d)}function jC(t){return cr(t).filter(e=>TS.has(e.localName.toLowerCase())).map(Iu).filter(Boolean)}function yt(t,e,n){let r={id:Da(e,t.sourceNodeId),type:e};for(let l of["in","result","x","y","width","height"]){let c=E(t,l);c!==null&&(r[l]=c)}let i=E(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 l of t.attributes)o.has(l.name)||n.has(l.name)||(s[l.name]=l.value);Object.keys(s).length>0&&(r.unknownAttrs=s);let a=jC(t);return a.length>0&&(r.animations=a),r}function UC(t){let e=E(t,"type");if(e==="identity")return{type:e};if(e==="table"||e==="discrete"){let r=(E(t,"tableValues")??"").trim().split(/[\s,]+/u).filter(Boolean).map(i=>Fn(i));return r.some(i=>i===void 0)?void 0:{type:e,tableValues:r}}if(e==="linear"){let n={type:e},r=Fn(E(t,"slope")),i=Fn(E(t,"intercept"));return r!==void 0&&(n.slope=r),i!==void 0&&(n.intercept=i),n}if(e==="gamma"){let n={type:e},r=Fn(E(t,"amplitude")),i=Fn(E(t,"exponent")),o=Fn(E(t,"offset"));return r!==void 0&&(n.amplitude=r),i!==void 0&&(n.exponent=i),o!==void 0&&(n.offset=o),n}}function HC(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=Fn(E(t,i));o!==void 0&&(e[i]=o)}return n==="fedistantlight"?{kind:"feDistantLight",...e}:n==="fepointlight"?{kind:"fePointLight",...e}:{kind:"feSpotLight",...e}}}function Ft(t,e,n,r=n){let i=Fn(E(e,n));i!==void 0&&(t[r]=i)}function tt(t,e,n,r=n){let i=E(e,n);i!==null&&(t[r]=i)}function WC(t){let e=t.localName.toLowerCase();switch(e){case"feblend":{let n=yt(t,"feBlend",new Set(["in2","mode","no-composite"]));tt(n,t,"in2");let r=E(t,"mode");return r&&LC.has(r)&&(n.mode=r),lt(t,"no-composite")&&(n.noComposite=!0),n}case"fecolormatrix":{let n=yt(t,"feColorMatrix",new Set(["type","values"])),r=E(t,"type");return(r==="matrix"||r==="saturate"||r==="hueRotate"||r==="luminanceToAlpha")&&(n.matrixType=r),tt(n,t,"values"),n}case"fecomponenttransfer":{let n=yt(t,"feComponentTransfer",new Set);for(let r of cr(t)){let i=UC(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=yt(t,"feComposite",new Set(["in2","operator","k1","k2","k3","k4"]));tt(n,t,"in2");let r=E(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"])Ft(n,t,i);return n}case"feconvolvematrix":{let r=yt(t,"feConvolveMatrix",new Set(["order","kernelMatrix","divisor","bias","targetX","targetY","edgeMode","kernelUnitLength","preserveAlpha"]));tt(r,t,"order"),tt(r,t,"kernelMatrix");for(let s of["divisor","bias","targetX","targetY"])Ft(r,t,s);let i=E(t,"edgeMode");(i==="duplicate"||i==="wrap"||i==="none")&&(r.edgeMode=i),tt(r,t,"kernelUnitLength");let o=E(t,"preserveAlpha");return o!==null&&(r.preserveAlpha=o==="true"),r}case"fediffuselighting":case"fespecularlighting":{let n=e==="fediffuselighting",i=yt(t,n?"feDiffuseLighting":"feSpecularLighting",new Set(["surfaceScale","diffuseConstant","specularConstant","specularExponent","kernelUnitLength","lighting-color"]));Ft(i,t,"surfaceScale"),n?Ft(i,t,"diffuseConstant"):(Ft(i,t,"specularConstant"),Ft(i,t,"specularExponent")),tt(i,t,"kernelUnitLength"),tt(i,t,"lighting-color","lightingColor");for(let o of cr(t)){let s=HC(o);if(s){i.lightSource=s;break}}return i}case"fedisplacementmap":{let n=yt(t,"feDisplacementMap",new Set(["in2","scale","xChannelSelector","yChannelSelector"]));tt(n,t,"in2"),Ft(n,t,"scale");for(let r of["xChannelSelector","yChannelSelector"]){let i=E(t,r);(i==="R"||i==="G"||i==="B"||i==="A")&&(n[r]=i)}return n}case"fedropshadow":{let n=yt(t,"feDropShadow",new Set(["dx","dy","stdDeviation","flood-color","flood-opacity"]));return Ft(n,t,"dx"),Ft(n,t,"dy"),tt(n,t,"stdDeviation"),tt(n,t,"flood-color","floodColor"),tt(n,t,"flood-opacity","floodOpacity"),n}case"feflood":{let n=yt(t,"feFlood",new Set(["flood-color","flood-opacity"]));return tt(n,t,"flood-color","floodColor"),tt(n,t,"flood-opacity","floodOpacity"),n}case"fegaussianblur":{let n=yt(t,"feGaussianBlur",new Set(["stdDeviation","edgeMode"]));tt(n,t,"stdDeviation");let r=E(t,"edgeMode");return(r==="duplicate"||r==="wrap"||r==="none")&&(n.edgeMode=r),n}case"feimage":{let n=yt(t,"feImage",new Set(["href","xlink:href","preserveAspectRatio","crossorigin"])),r=Ee(t);r?.namespace==="svg2"?n.href=r.value:r?.namespace==="xlink"&&(n.xlinkHref=r.value),tt(n,t,"preserveAspectRatio");let i=E(t,"crossorigin");return(i==="anonymous"||i==="use-credentials")&&(n.crossorigin=i),n}case"femerge":{let n=yt(t,"feMerge",new Set);return n.nodes=cr(t).filter(r=>r.localName.toLowerCase()==="femergenode").map(r=>{let i=E(r,"in");return i===null?{}:{in:i}}),n}case"femorphology":{let n=yt(t,"feMorphology",new Set(["operator","radius"])),r=E(t,"operator");return(r==="erode"||r==="dilate")&&(n.operator=r),tt(n,t,"radius"),n}case"feoffset":{let n=yt(t,"feOffset",new Set(["dx","dy"]));return Ft(n,t,"dx"),Ft(n,t,"dy"),n}case"fetile":return yt(t,"feTile",new Set);case"feturbulence":{let n=yt(t,"feTurbulence",new Set(["baseFrequency","numOctaves","seed","stitchTiles","type"]));tt(n,t,"baseFrequency"),Ft(n,t,"numOctaves"),Ft(n,t,"seed");let r=E(t,"stitchTiles");(r==="stitch"||r==="noStitch")&&(n.stitchTiles=r);let i=E(t,"type");return(i==="fractalNoise"||i==="turbulence")&&(n.turbulenceType=i),n}default:return null}}function KC(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 Jt(t,e){return(t===void 0?void 0:Fn(t))??e}function XC(t,e){let n=KC(t);if(n.length<2)return null;let r=n[0],i=n[1]==="1",o={id:Da(r,e,":preset"),enabled:i};switch(r){case"hue-rotate":return{...o,type:r,angle:Jt(n[2],0)};case"sepia":case"grayscale":case"saturate":case"invert":case"brightness":case"contrast":return{...o,type:r,amount:Jt(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:Jt(n[2],0),offsetY:Jt(n[3],0),blurRadius:Jt(n[4],0),choke:Jt(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"drop-shadow":return{...o,type:r,offsetX:Jt(n[2],0),offsetY:Jt(n[3],0),blurRadius:Jt(n[4],0),spread:Jt(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"gaussian-blur":{let s=Jt(n[2],0);return{...o,type:r,blurX:s,blurY:Jt(n[3],s),linked:n[3]===void 0,quality:"normal"}}default:return null}}function YC(t,e){let n={id:Da("raw-svg",t.sourceNodeId),type:"raw-svg",enabled:!0,svgContent:cr(t).map(Iu).filter(Boolean).join(`
17
+ `)};return PS(n,t),e&&(n.display="none"),n}function qC(t){let e={id:Da("svg-primitive-chain",t.sourceNodeId),type:"svg-primitive-chain",enabled:!0,primitives:[]};PS(e,t);let n=[];for(let r of cr(t)){let i=r.localName.toLowerCase();if(i==="title")e.filterTitle=kS(r);else if(i==="desc")e.filterDescription=kS(r);else if(TS.has(i))n.push(Iu(r));else{let o=WC(r);o&&e.primitives.push(o)}}return n.length>0&&(e.filterAnimations=n),e}function ZC(t,e,n,r,i,o){let s=VC(e),a=e.attributes.find(m=>m.localName==="preset"&&m.prefix==="bx")?.value,l=GC(t,e,n,r),c=E(e,"filterUnits"),u=E(e,"primitiveUnits"),d=E(e,"color-interpolation-filters");c!==null&&c!=="userSpaceOnUse"&&c!=="objectBoundingBox"&&o.push(Oa(i,`Invalid filterUnits value "${c}" uses its initial value.`,e)),u!==null&&u!=="userSpaceOnUse"&&u!=="objectBoundingBox"&&o.push(Oa(i,`Invalid primitiveUnits value "${u}" uses its initial value.`,e)),d!==null&&d!=="auto"&&d!=="sRGB"&&d!=="linearRGB"&&o.push(Oa(i,`Invalid color-interpolation-filters value "${d}" uses its initial value.`,e));let p=a?XC(a,e.sourceNodeId):l||BC(e)?YC(e,l):qC(e),f=Object.freeze(p?[p]:[]),g=p?.type==="svg-primitive-chain"&&p.primitives.length===0;return Dr({sourceNodeId:e.sourceNodeId,sourceId:E(e,"id"),status:p?g?"empty":"materialized":"invalid",filters:f,...s})}function JC(t,e){let n=_C.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 QC(t){let e=FC.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 e$(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 t$(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=zo(t);return n?`rgb(${n.r}, ${n.g}, ${n.b})`:null}function n$(t,e,n,r,i,o){if(t==="brightness"||t==="contrast"||t==="grayscale"||t==="invert"||t==="opacity"||t==="saturate"||t==="sepia"){let l=JC(e,1);return l===null?null:{id:n,type:t,enabled:!0,amount:l}}if(t==="hue-rotate"){let l=QC(e);return l===null?null:{id:n,type:t,enabled:!0,angle:l}}if(t==="blur"){let l=Se(e.trim(),{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});return l===void 0||l<0||e.trim().endsWith("%")?null:{id:n,type:"gaussian-blur",enabled:!0,blurX:l,blurY:l,linked:!0,quality:"normal"}}if(t!=="drop-shadow")return null;let s=[],a=null;for(let l of e$(e.trim())){let c=Se(l,{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});if(c!==void 0&&!l.endsWith("%"))s.push(c);else{let u=t$(l,r);if(!u||a!==null)return null;a=u}}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 r$(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 i$(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 o$(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 s$(t,e,n,r,i,o,s,a){let l=[],c=r$(r,t,e),u=0,d=!1,p=Se(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"),g=mn(e);o$(e,g)||(d=!0);for(let[b,S]of g.entries()){let v=`filter-operation:${t.occurrenceId}:${b}`,I=e.slice(S.tokenStart,S.tokenEnd);if(S.name!=="url"){let $=n$(S.name,e.slice(S.argumentsStart,S.argumentsEnd),v,f,p,o),R=$?"materialized":"invalid-reference";$||(d=!0,s.push(Oa(o,`Invalid or unsupported CSS filter function "${I}".`,a,t.occurrenceId))),l.push(Object.freeze({operationId:v,kind:"function",authoredValue:I,filter:$,filterSourceNodeId:null,status:R}));continue}let P=i$(e.slice(S.argumentsStart,S.argumentsEnd))===null?void 0:c[u++],T=P?.targetSourceNodeId?i.get(P.targetSourceNodeId):null,w=P?.validity==="valid"&&T?T.status==="empty"?"empty":T.status==="materialized"?"materialized":"invalid-reference":"invalid-reference";w==="invalid-reference"&&(d=!0),l.push(Dr({operationId:v,kind:"reference",authoredValue:I,filter:w==="materialized"?T?.filters[0]??null:null,filterSourceNodeId:P?.targetSourceNodeId??null,status:w}))}let h=e.trim().toLowerCase()==="none"?"none":d||l.length===0?"invalid-reference":"materialized";return Dr({consumerOccurrenceId:t.occurrenceId,consumerSourceNodeId:t.correspondingSourceNodeId,authoredValue:e,status:h,operations:Object.freeze(l)})}function wu(t,e,n,r,i){let o=[],s=r.resources.filter(d=>d.kind==="filter").map(d=>t.index.element(d.sourceNodeId)).filter(d=>!!d).map(d=>ZC(t,d,e,n,i,o)),a=new Map(s.map(d=>[d.sourceNodeId,d])),l=[];for(let d of e.occurrences){let p=t.index.element(d.correspondingSourceNodeId);if(!p)continue;let f=n.value(d.occurrenceId,"filter");f&&l.push(s$(d,f,n,r,a,i,o,p))}let c=new Map(l.map(d=>[d.consumerOccurrenceId,d]));Dr(s),Dr(l),Dr(o);let u=Object.freeze({candidates:s,bindings:l,diagnostics:o,candidate(d){return a.get(d)??null},binding(d){return c.get(d)??null}});return Object.freeze({value:u,diagnostics:o})}var a$="application/ecmascript",l$="http://www.w3.org/1999/xlink",c$=Object.freeze([]);function d$(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 u$(t,e){let n=t.attributes[e];return n.namespaceUri===l$&&n.localName==="href"?!0:n.namespaceUri!==null?!1:["id","type","href","crossorigin","async","defer"].includes(n.localName)}function p$(t){let e=t.attributes.filter((n,r)=>!u$(t,r)).map(n=>[n.name,n.value]);return e.length>0?Object.freeze(Object.fromEntries(e)):void 0}function f$(t,e){return!e||e.sourceNodeId===t.root.sourceNodeId||e.namespaceUri===W&&["defs","metadata"].includes(e.localName.toLowerCase())?"document":"element"}function m$(t){let e=Ee(t)?.value,n=e!==void 0&&e.length>0,r=E(t,"type")||a$,i=E(t,"crossorigin"),o=E(t,"id")||void 0,s=p$(t);return Object.freeze({id:`script:${t.sourceNodeId}`,...o?{svgId:o}:{},source:n?"external":"inline",content:n?"":d$(t),...n?{href:e}:{},type:r,...i==="anonymous"||i==="use-credentials"?{crossorigin:i}:{},...lt(t,"async")?{async:!0}:{},...lt(t,"defer")?{defer:!0}:{},...s?{customAttrs:s}:{}})}function ku(t,e){let n=[],r=t.index.elements.filter(c=>c.namespaceUri===W&&c.localName.toLowerCase()==="script").map(c=>{let u=t.index.parent(c.sourceNodeId);return Object.freeze({sourceNodeId:c.sourceNodeId,parentSourceNodeId:u?.sourceNodeId??null,scope:f$(t,u),script:m$(c)})}),i=Object.freeze(r.filter(c=>c.scope==="document")),o=Object.freeze(r.filter(c=>c.scope==="element")),s=new Map(r.map(c=>[c.sourceNodeId,c])),a=new Map;for(let c of o){if(!c.parentSourceNodeId)continue;let u=a.get(c.parentSourceNodeId)??[];a.set(c.parentSourceNodeId,Object.freeze([...u,c]))}Object.freeze(r),Object.freeze(n);let l=Object.freeze({candidates:r,documentScripts:i,elementScripts:o,candidate(c){return s.get(c)??null},forParent(c){return a.get(c)??c$}});return Object.freeze({value:l,diagnostics:n})}function Ln(t){if(!t)return"";let e=t.replace(/[^A-Za-z0-9_.-]/g,"_");return e&&!/^[A-Za-z_]/.test(e)&&(e=`_${e}`),e}function g$(t){let e=t.state?.children;return Array.isArray(e)?e:[]}function CS(t,e,n="shapes"){let r=new Set,i=(o,s)=>{r.has(o)||(r.add(o),e(o,s),g$(o).forEach((a,l)=>i(a,`${s}.children[${l}]`)),r.delete(o))};t.forEach((o,s)=>i(o,`${n}[${s}]`))}function h$(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 y$(t){return t.definitionId??`${t.type}-${t.id}`}function S$(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 tL(t,e={}){let n=[],r=new Map,i=new Set,o=[],s=f=>{if(!f.id)return;let g=`${f.channel}\0${f.ownerKey}\0${f.id}`;if(i.has(g))return;i.add(g);let m=Object.freeze({...f});n.push(m);let h=r.get(f.id)??[];h.push(m),r.set(f.id,h)},a=(f,g)=>{let m=f.state??{},h=m.metadata;if(typeof h?.name=="string"){let b=Ln(h.name);b&&s({id:b,ownerKey:`shape:${f.id}:metadata`,channel:"shape-authored",documentPath:g})}f.type==="view"&&typeof m.viewName=="string"&&m.viewName&&s({id:Ln(m.viewName),ownerKey:`view:${f.id}`,channel:"view",documentPath:g}),f.type==="text"&&m.isTextPath===!0&&m.textPathPoints&&s({id:`text-path-${f.id}`,ownerKey:`shape:${f.id}:text-path`,channel:"shape-generated",documentPath:g}),m.displayMode==="motionOnly"&&s({id:f.id,ownerKey:`shape:${f.id}:motion-path`,channel:"shape-generated",documentPath:g}),Array.isArray(m.filters)&&m.filters.length>0&&s({id:`filter-${f.id}`,ownerKey:`shape:${f.id}:filter`,channel:"shape-generated",documentPath:g}),typeof h?.rawMetadata=="string"&&l(h.rawMetadata,`shape:${f.id}:metadata`,void 0,g)},l=(f,g,m,h)=>{let b=`<svg xmlns="${W}">${f}</svg>`,S=Sn(b,{source:"native-document",entrypoint:"full-snapshot-restore"},e.parserHost);if(o.push(...S.diagnostics),!S.value)return;let v=new Map;for(let I of S.value.index.elements.slice(1)){let x=E(I,"id");if(!x||S.value.index.parent(I.sourceNodeId)===S.value.root&&m===x)continue;let T=v.get(x)??0;v.set(x,T+1),s({id:x,ownerKey:`${g}#${x}${T>0?`@${T}`:""}`,channel:"verbatim-fragment"})}},c=new Map;CS(t.shapes??[],(f,g)=>{c.has(f.id)||c.set(f.id,f),a(f,g)});for(let f of c.values()){let g=f.state??{},m=[f.type==="text"?g.shapeInsideRef:void 0,f.type==="shape-reference"?g.targetShapeId:void 0];for(let h of m){if(typeof h!="string")continue;let b=c.get(h),S=b?.state?.metadata?.name;b&&(typeof S!="string"||Ln(S).length===0)&&s({id:b.id,ownerKey:`shape:${b.id}:reference-target`,channel:"shape-generated",documentPath:`shape:${b.id}`})}}typeof t.documentMetadata?.rawMetadata=="string"&&l(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 u=(f,g,m)=>{let h=g?`libraryFurniture[${m}]`:`library[${m}]`;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}),h$(f).forEach((b,S)=>CS(b,a,`${h}.shapeForest[${S}]`))};(t.library??[]).forEach((f,g)=>u(f,!1,g)),(e.libraryFurniture??[]).forEach((f,g)=>u(f,!0,g));for(let[f,g]of(t.paintServerDefs??[]).entries())s({id:g.id,ownerKey:`paint-server:${g.id}`,channel:"paint-server",documentPath:`paintServerDefs[${f}]`}),l(g.markup,`paint-server:${g.id}`,g.id,`paintServerDefs[${f}].markup`);for(let[f,g]of(t.clipMaskGroups??[]).entries()){let m=y$(g);s({id:m,ownerKey:`clip-mask:${g.id}`,channel:"clip-mask-definition",documentPath:`clipMaskGroups[${f}]`}),g.rawDefinition&&l(g.rawDefinition,`clip-mask:${g.id}`,m,`clipMaskGroups[${f}].rawDefinition`)}for(let f of e.platformReservations??[])s(f);for(let f of r.values())Object.freeze(f);Object.freeze(n);let d=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,g])=>S$(f,g));return{value:d,diagnostics:Object.freeze([...o,...p])}}function nL(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 l=s.preferredId,c=Ln(l??""),u=Ln(s.fallbackBase)||"svg-resource",d=c||u,p=e.has(d)?t.firstOwner(d):null,f=d;if(e.has(f)){let m=i.get(d)??1;for(;e.has(`${d}-${m}`);)m++;f=`${d}-${m}`,i.set(d,m+1)}e.add(f);let g=Object.freeze({requestKey:s.requestKey,...l!==void 0?{authoredId:l}:{},destinationId:f,...p?{collisionOwner:p}:{}});return n.set(s.requestKey,g),r.push(g),g},assignment(s){return n.get(s)??null},has(s){return e.has(s)},snapshot(){return Object.freeze([...r])}})}function za(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 b$(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${r}"`).join("");return`<${t.tag}${e}/>`}function Ru(t,e,n,r,i){let o=10*e,s="";s+=`<rect width="${o}" height="${o}" fill="${r}"/>`;let a=za(t,o,n,i);for(let l of a)s+=b$(l);return{svgContent:s,width:o,height:o}}function oe(t,e,n){n==null||n===""||t.push([e,n])}function Tu(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 v$(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${ue(String(r))}"`).join("");return`<${t.tag}${e}/>`}function Pu(t,e){let n=[["id",t]];if(e.svgContent!=null){let l=e.authoredGeometry??{};return oe(n,"patternUnits",e.patternUnits??"userSpaceOnUse"),oe(n,"patternContentUnits",e.patternContentUnits),oe(n,"x",l.x??e.x),oe(n,"y",l.y??e.y),oe(n,"width",l.width??e.width??10),oe(n,"height",l.height??e.height??10),oe(n,"viewBox",e.viewBox),oe(n,"preserveAspectRatio",e.preserveAspectRatio),oe(n,"patternTransform",e.patternTransform),{attributes:n,content:e.svgContent}}let r=10*(e.scale??1),i=e.color||"#000000",o=e.backgroundColor||"#ffffff";oe(n,"patternUnits","userSpaceOnUse"),oe(n,"width",r),oe(n,"height",r),e.rotation&&oe(n,"patternTransform",`rotate(${e.rotation})`);let s=`<rect width="${ue(String(r))}" height="${ue(String(r))}" fill="${ue(o)}"/>`,a=za(e.patternType,r,i).map(v$).join("");return{attributes:n,content:`${s}${a}`}}function Cu(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=s=>n?String(s):`${s*100}%`,i=e.authoredGeometry??{},o=[["id",t]];return n&&oe(o,"gradientUnits","userSpaceOnUse"),oe(o,"x1",i.x1??r(e.x1)),oe(o,"y1",i.y1??r(e.y1)),oe(o,"x2",i.x2??r(e.x2)),oe(o,"y2",i.y2??r(e.y2)),oe(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&oe(o,"color-interpolation",e.colorInterpolation),oe(o,"gradientTransform",i.gradientTransform??Ws(e.gradientTransform)),{element:"linearGradient",attributes:o,stops:Tu(e)}}function $u(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=a=>n?String(a):`${a*100}%`,i=e.authoredGeometry??{},o=[["id",t]];if(n&&oe(o,"gradientUnits","userSpaceOnUse"),oe(o,"cx",i.cx??r(e.cx)),oe(o,"cy",i.cy??r(e.cy)),oe(o,"fx",i.fx??r(e.fx)),oe(o,"fy",i.fy??r(e.fy)),oe(o,"r",i.r??r(e.r)),(i.fr!==void 0||e.fr!==void 0&&e.fr>0)&&oe(o,"fr",i.fr??r(e.fr??0)),oe(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&oe(o,"color-interpolation",e.colorInterpolation),i.gradientTransform!==void 0||e.gradientTransform!==void 0)oe(o,"gradientTransform",i.gradientTransform??Ws(e.gradientTransform));else{let a=e.ry!==void 0&&e.ry!==e.r,l=!!e.rotation;if(!a&&!l)return{element:"radialGradient",attributes:o,stops:Tu(e)};let c=e.cx??(n?0:.5),u=e.cy??(n?0:.5),d=[`translate(${c}, ${u})`];l&&d.push(`rotate(${e.rotation})`),a&&e.ry!==0&&d.push(`scale(1, ${e.ry/e.r})`),d.push(`translate(${-c}, ${-u})`),oe(o,"gradientTransform",d.join(" "))}return{element:"radialGradient",attributes:o,stops:Tu(e)}}function $S(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 Eu(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 oe(p,"x",n.x??i.x),oe(p,"y",n.y??i.y),oe(p,"width",n.width??i.width),oe(p,"height",n.height??i.height),oe(p,"filterUnits",n.filterUnits??i.filterUnits),oe(p,"primitiveUnits",n.primitiveUnits??i.primitiveUnits),oe(p,"color-interpolation-filters",n.colorInterpolation&&n.colorInterpolation!=="auto"?n.colorInterpolation:i.colorInterpolationFilters),oe(p,"flood-color",i.floodColor),oe(p,"flood-opacity",i.floodOpacity),oe(p,"lighting-color",i.lightingColor),oe(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=$S(r),l=a?s?"-200%":"-100%":"-10%",c=a?s?"500%":"300%":"120%",u=n.primitiveUnits??"userSpaceOnUse",d=[["id",t]];return oe(d,"x",n.x??l),oe(d,"y",n.y??l),oe(d,"width",n.width??c),oe(d,"height",n.height??c),oe(d,"filterUnits",n.filterUnits??"objectBoundingBox"),oe(d,"primitiveUnits",u),n.colorInterpolation&&n.colorInterpolation!=="auto"&&oe(d,"color-interpolation-filters",n.colorInterpolation),{kind:"generated",attributes:d,filters:r,primitiveUnits:u}}function y(t,e){return e==null||e===""?"":` ${t}="${ue(String(e))}"`}function Fa(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 x$(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,spread:s,color:a,opacity:l}=t,c="";if(s===0)c+=`<feDropShadow${y("in",e)}${y("dx",r)}${y("dy",i)}${y("stdDeviation",o/2)}${y("flood-color",a)}${y("flood-opacity",l)}${y("result",`${n}_shadow`)}/>`,c+=`<feMerge${y("result",n)}><feMergeNode${y("in",`${n}_shadow`)}/><feMergeNode${y("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${y("in",e)}${y("type","matrix")}${y("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${y("result",`${n}_alpha`)}/>`;let u=s>0?"dilate":"erode",d=Math.abs(s);c+=`<feMorphology${y("in",`${n}_alpha`)}${y("operator",u)}${y("radius",d)}${y("result",`${n}_spread`)}/>`,c+=`<feGaussianBlur${y("in",`${n}_spread`)}${y("stdDeviation",o/2)}${y("result",`${n}_blur`)}/>`,c+=`<feOffset${y("in",`${n}_blur`)}${y("dx",r)}${y("dy",i)}${y("result",`${n}_offset`)}/>`,c+=`<feFlood${y("flood-color",a)}${y("flood-opacity",l)}${y("result",`${n}_color`)}/>`,c+=`<feComposite${y("in",`${n}_color`)}${y("in2",`${n}_offset`)}${y("operator","in")}${y("result",`${n}_shadow`)}/>`,c+=`<feMerge${y("result",n)}><feMergeNode${y("in",`${n}_shadow`)}/><feMergeNode${y("in",e)}/></feMerge>`}return c}function I$(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,choke:s,color:a,opacity:l}=t,c=o*(1-s/100),u="";return u+=`<feColorMatrix${y("in",e)}${y("type","matrix")}${y("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${y("result",`${n}_alpha`)}/>`,u+=`<feComponentTransfer${y("in",`${n}_alpha`)}${y("result",`${n}_inverted`)}><feFuncA${y("type","table")}${y("tableValues","1 0")}/></feComponentTransfer>`,u+=`<feGaussianBlur${y("in",`${n}_inverted`)}${y("stdDeviation",c/2)}${y("result",`${n}_blur`)}/>`,u+=`<feOffset${y("in",`${n}_blur`)}${y("dx",r)}${y("dy",i)}${y("result",`${n}_offset`)}/>`,u+=`<feFlood${y("flood-color",a)}${y("flood-opacity",l)}${y("result",`${n}_color`)}/>`,u+=`<feComposite${y("in",`${n}_color`)}${y("in2",`${n}_offset`)}${y("operator","in")}${y("result",`${n}_coloredShadow`)}/>`,u+=`<feComposite${y("in",`${n}_coloredShadow`)}${y("in2",`${n}_alpha`)}${y("operator","in")}${y("result",`${n}_innerShadow`)}/>`,u+=`<feComposite${y("in",`${n}_innerShadow`)}${y("in2",e)}${y("operator","over")}${y("result",n)}/>`,u}function w$(t,e,n){let{blurX:r,blurY:i}=t;return r===0&&i===0?we(e,n):`<feGaussianBlur${y("in",e)}${y("stdDeviation",`${r/2} ${i/2}`)}${y("result",n)}/>`}function k$(t,e,n){let{distance:r,angle:i}=t;if(r===0)return we(e,n);let o=i*Math.PI/180,s=Math.abs(Math.cos(o)*r),a=Math.abs(Math.sin(o)*r);return`<feGaussianBlur${y("in",e)}${y("stdDeviation",`${s/2} ${a/2}`)}${y("result",n)}/>`}function ES(t,e,n){let{x:r,y:i,z:o,color:s,surfaceScale:a,diffuseConstant:l,specularConstant:c,specularExponent:u}=t,d="";return d+=`<feDiffuseLighting${y("in","SourceAlpha")}${y("surfaceScale",a)}${y("diffuseConstant",l)}${y("lighting-color",s)}${y("result",`${n}_diffuse`)}>`,d+=`<fePointLight${y("x",r)}${y("y",i)}${y("z",o)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${y("in","SourceAlpha")}${y("surfaceScale",a)}${y("specularConstant",c)}${y("specularExponent",u)}${y("lighting-color",s)}${y("result",`${n}_specular`)}>`,d+=`<fePointLight${y("x",r)}${y("y",i)}${y("z",o)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${y("in",e)}${y("in2",`${n}_diffuse`)}${y("operator","arithmetic")}${y("k1",1)}${y("k2",0)}${y("k3",0)}${y("k4",0)}${y("result",`${n}_lit`)}/>`,d+=`<feComposite${y("in",`${n}_specular`)}${y("in2",`${n}_lit`)}${y("operator","arithmetic")}${y("k1",0)}${y("k2",1)}${y("k3",1)}${y("k4",0)}${y("result",n)}/>`,d}function AS(t,e,n){let{x:r,y:i,z:o,pointsAtX:s,pointsAtY:a,pointsAtZ:l,coneAngle:c,color:u,surfaceScale:d,specularConstant:p,specularExponent:f}=t,g="";return g+=`<feSpecularLighting${y("in","SourceAlpha")}${y("surfaceScale",d)}${y("specularConstant",p)}${y("specularExponent",f)}${y("lighting-color",u)}${y("result",`${n}_specular`)}>`,g+=`<feSpotLight${y("x",r)}${y("y",i)}${y("z",o)}${y("pointsAtX",s)}${y("pointsAtY",a)}${y("pointsAtZ",l)}${y("limitingConeAngle",c)}/>`,g+="</feSpecularLighting>",g+=`<feComposite${y("in",`${n}_specular`)}${y("in2","SourceAlpha")}${y("operator","in")}${y("result",`${n}_clipped`)}/>`,g+=`<feComposite${y("in",`${n}_clipped`)}${y("in2",e)}${y("operator","arithmetic")}${y("k1",0)}${y("k2",1)}${y("k3",1)}${y("k4",0)}${y("result",n)}/>`,g}function NS(t){switch(t.kind){case"point":return`<fePointLight${y("x",t.x)}${y("y",t.y)}${y("z",t.z)}/>`;case"spot":{let e=`<feSpotLight${y("x",t.x)}${y("y",t.y)}${y("z",t.z)}${y("pointsAtX",t.pointsAtX)}${y("pointsAtY",t.pointsAtY)}${y("pointsAtZ",t.pointsAtZ)}`;return t.limitingConeAngle!==void 0&&(e+=y("limitingConeAngle",t.limitingConeAngle)),t.specularExponent!==void 0&&(e+=y("specularExponent",t.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${y("azimuth",t.azimuth)}${y("elevation",t.elevation)}/>`}}function R$(t,e,n){return`<feDiffuseLighting${y("in",e)}${y("surfaceScale",t.surfaceScale)}${y("diffuseConstant",t.diffuseConstant)}${y("lighting-color",t.color)}${y("result",n)}>`+NS(t.lightSource)+"</feDiffuseLighting>"}function T$(t,e,n){return`<feSpecularLighting${y("in",e)}${y("surfaceScale",t.surfaceScale)}${y("specularConstant",t.specularConstant)}${y("specularExponent",t.specularExponent)}${y("lighting-color",t.color)}${y("result",n)}>`+NS(t.lightSource)+"</feSpecularLighting>"}function P$(t,e,n){let{width:r,color:i,opacity:o,position:s}=t,a="";if(s==="inside")a+=`<feMorphology${y("in","SourceAlpha")}${y("operator","erode")}${y("radius",r)}${y("result",`${n}_eroded`)}/>`,a+=`<feComposite${y("in","SourceAlpha")}${y("in2",`${n}_eroded`)}${y("operator","out")}${y("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${y("flood-color",i)}${y("flood-opacity",o)}${y("result",`${n}_color`)}/>`,a+=`<feComposite${y("in",`${n}_color`)}${y("in2",`${n}_outlineAlpha`)}${y("operator","in")}${y("result",`${n}_outline`)}/>`,a+=`<feComposite${y("in",`${n}_outline`)}${y("in2",e)}${y("operator","over")}${y("result",n)}/>`;else{let l=s==="outside"?r:r/2;a+=`<feMorphology${y("in","SourceAlpha")}${y("operator","dilate")}${y("radius",l)}${y("result",`${n}_dilated`)}/>`,a+=`<feComposite${y("in",`${n}_dilated`)}${y("in2","SourceAlpha")}${y("operator","out")}${y("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${y("flood-color",i)}${y("flood-opacity",o)}${y("result",`${n}_color`)}/>`,a+=`<feComposite${y("in",`${n}_color`)}${y("in2",`${n}_outlineAlpha`)}${y("operator","in")}${y("result",`${n}_outline`)}/>`,a+=`<feMerge${y("result",n)}><feMergeNode${y("in",`${n}_outline`)}/><feMergeNode${y("in",e)}/></feMerge>`}return a}function C$(t,e,n){let{amount:r}=t;if(r===0)return we(e,n);let i=1+4*r,o=-r,s=[0,o,0,o,i,o,0,o,0].join(" ");return`<feConvolveMatrix${y("in",e)}${y("order","3")}${y("kernelMatrix",s)}${y("divisor","1")}${y("bias","0")}${y("preserveAlpha","true")}${y("edgeMode","duplicate")}${y("result",n)}/>`}function $$(t,e,n){let{blockSize:r}=t;if(r<=1)return we(e,n);let i=r/2,o="";return o+=`<feMorphology${y("in",e)}${y("operator","erode")}${y("radius",i)}${y("result",`${n}_eroded`)}/>`,o+=`<feMorphology${y("in",`${n}_eroded`)}${y("operator","dilate")}${y("radius",i)}${y("result",n)}/>`,o}function E$(t,e,n){let{scale:r,frequency:i,octaves:o,warpType:s}=t;if(r===0)return we(e,n);let a="";return a+=`<feTurbulence${y("type",s)}${y("baseFrequency",i)}${y("numOctaves",o)}${y("seed",0)}${y("result",`${n}_turbulence`)}/>`,a+=`<feDisplacementMap${y("in",e)}${y("in2",`${n}_turbulence`)}${y("scale",r)}${y("xChannelSelector","R")}${y("yChannelSelector","G")}${y("result",n)}/>`,a}function A$(t,e,n){let{operator:r,radiusX:i,radiusY:o}=t;return i===0&&o===0?we(e,n):`<feMorphology${y("in",e)}${y("operator",r)}${y("radius",`${i} ${o}`)}${y("result",n)}/>`}function N$(t,e,n){let{levels:r}=t;if(r<2)return we(e,n);let i=[];for(let a=0;a<r;a++)i.push(a/(r-1));let o=i.join(" "),s=`<feComponentTransfer${y("in",e)}${y("result",n)}>`;return s+=`<feFuncR${y("type","discrete")}${y("tableValues",o)}/>`,s+=`<feFuncG${y("type","discrete")}${y("tableValues",o)}/>`,s+=`<feFuncB${y("type","discrete")}${y("tableValues",o)}/>`,s+="</feComponentTransfer>",s}function M$(t,e,n){let{levels:r,contrast:i}=t;if(r<2)return we(e,n);let o=[];for(let l=0;l<r;l++){let c=l/(r-1),u=c;i!==1&&(u=.5+(c-.5)*i,u=Math.max(0,Math.min(1,u))),o.push(u)}let s=o.join(" "),a=`<feComponentTransfer${y("in",e)}${y("result",n)}>`;return a+=`<feFuncR${y("type","table")}${y("tableValues",s)}/>`,a+=`<feFuncG${y("type","table")}${y("tableValues",s)}/>`,a+=`<feFuncB${y("type","table")}${y("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function O$(t,e,n){let{radius:r}=t;if(r===0)return we(e,n);let i="";return i+=`<feGaussianBlur${y("in","SourceAlpha")}${y("stdDeviation",r)}${y("result",`${n}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${y("in",`${n}_blurredAlpha`)}${y("result",`${n}_thresholdAlpha`)}><feFuncA${y("type","linear")}${y("slope",20)}${y("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${y("in",e)}${y("in2",`${n}_thresholdAlpha`)}${y("operator","in")}${y("result",n)}/>`,i}function D$(t,e,n){let{amount:r}=t;if(r===0)return we(e,n);let i=1-r;return`<feColorMatrix${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("type","saturate")}${y("values",i)}${y("result",n)}/>`}function z$(t,e,n){let{red:r,green:i,blue:o}=t;if(r===1&&i===1&&o===1)return we(e,n);let s=`<feComponentTransfer${y("in",e)}${y("result",n)}>`;return s+=`<feFuncR${y("type","linear")}${y("slope",r)}${y("intercept",0)}/>`,s+=`<feFuncG${y("type","linear")}${y("slope",i)}${y("intercept",0)}/>`,s+=`<feFuncB${y("type","linear")}${y("slope",o)}${y("intercept",0)}/>`,s+="</feComponentTransfer>",s}function _$(t,e,n){let{amount:r}=t;if(r===1)return we(e,n);let i=`<feComponentTransfer${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("result",n)}>`;return i+=`<feFuncR${y("type","linear")}${y("slope",r)}${y("intercept",0)}/>`,i+=`<feFuncG${y("type","linear")}${y("slope",r)}${y("intercept",0)}/>`,i+=`<feFuncB${y("type","linear")}${y("slope",r)}${y("intercept",0)}/>`,i+="</feComponentTransfer>",i}function F$(t,e,n){let{amount:r}=t;if(r===1)return we(e,n);let i=.5*(1-r),o=`<feComponentTransfer${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("result",n)}>`;return o+=`<feFuncR${y("type","linear")}${y("slope",r)}${y("intercept",i)}/>`,o+=`<feFuncG${y("type","linear")}${y("slope",r)}${y("intercept",i)}/>`,o+=`<feFuncB${y("type","linear")}${y("slope",r)}${y("intercept",i)}/>`,o+="</feComponentTransfer>",o}function L$(t,e,n){let{amount:r}=t;if(r===1)return we(e,n);let i=`<feComponentTransfer${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("result",n)}>`;return i+=`<feFuncA${y("type","linear")}${y("slope",r)}${y("intercept",0)}/>`,i+="</feComponentTransfer>",i}function B$(t,e,n){let{amount:r}=t;if(r===0)return we(e,n);let i=r,o=1-r,s=`${i} ${o}`,a=`<feComponentTransfer${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("result",n)}>`;return a+=`<feFuncR${y("type","table")}${y("tableValues",s)}/>`,a+=`<feFuncG${y("type","table")}${y("tableValues",s)}/>`,a+=`<feFuncB${y("type","table")}${y("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function G$(t,e,n){let{angle:r}=t;return r===0||r===360?we(e,n):`<feColorMatrix${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("type","hueRotate")}${y("values",r)}${y("result",n)}/>`}function V$(t,e,n){let{amount:r}=t;return r===1?we(e,n):`<feColorMatrix${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("type","saturate")}${y("values",r)}${y("result",n)}/>`}function j$(t,e,n){let{threshold:r}=t,i="";if(i+=`<feColorMatrix${y("in",e)}${y("type","saturate")}${y("values",0)}${y("result",`${n}_gray`)}/>`,r===.5)i+=`<feComponentTransfer${y("in",`${n}_gray`)}${y("result",n)}>`,i+=`<feFuncR${y("type","discrete")}${y("tableValues","0 1")}/>`,i+=`<feFuncG${y("type","discrete")}${y("tableValues","0 1")}/>`,i+=`<feFuncB${y("type","discrete")}${y("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let s=[];for(let l=0;l<256;l++)s.push(l/255<r?0:1);let a=s.join(" ");i+=`<feComponentTransfer${y("in",`${n}_gray`)}${y("result",n)}>`,i+=`<feFuncR${y("type","table")}${y("tableValues",a)}/>`,i+=`<feFuncG${y("type","table")}${y("tableValues",a)}/>`,i+=`<feFuncB${y("type","table")}${y("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function U$(t,e,n){let{amount:r}=t;if(r===0)return we(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],l=[0,1,0,0,0],c=[0,0,1,0,0],u=(m,h)=>m.map((b,S)=>b*(1-r)+h[S]*r),d=u(a,i),p=u(l,o),f=u(c,s),g=[...d,...p,...f,0,0,0,1,0].join(" ");return`<feColorMatrix${y("color-interpolation-filters","sRGB")}${y("in",e)}${y("type","matrix")}${y("values",g)}${y("result",n)}/>`}function H$(t,e,n){let{shadowColor:r,highlightColor:i}=t,o=Fa(r),s=Fa(i),a="";return a+=`<feColorMatrix${y("in",e)}${y("type","saturate")}${y("values",0)}${y("result",`${n}_gray`)}/>`,a+=`<feComponentTransfer${y("in",`${n}_gray`)}${y("result",n)}>`,a+=`<feFuncR${y("type","table")}${y("tableValues",`${o.r} ${s.r}`)}/>`,a+=`<feFuncG${y("type","table")}${y("tableValues",`${o.g} ${s.g}`)}/>`,a+=`<feFuncB${y("type","table")}${y("tableValues",`${o.b} ${s.b}`)}/>`,a+="</feComponentTransfer>",a}function W$(t,e,n){let{intensity:r}=t;if(r===0)return we(e,n);let i="";i+=`<feComponentTransfer${y("in",e)}${y("result",`${n}_invert`)}>`,i+=`<feFuncR${y("type","table")}${y("tableValues","1 0")}/>`,i+=`<feFuncG${y("type","table")}${y("tableValues","1 0")}/>`,i+=`<feFuncB${y("type","table")}${y("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${y("in",`${n}_invert`)}${y("type","saturate")}${y("values",0)}${y("result",`${n}_gray`)}/>`;let o=[.1,.1,.1,0,0],s=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],l=[1,0,0,0,0],c=[0,1,0,0,0],u=[0,0,1,0,0],d=(h,b)=>h.map((S,v)=>S*(1-r)+b[v]*r),p=d(l,o),f=d(c,s),g=d(u,a),m=[...p,...f,...g,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${y("in",`${n}_gray`)}${y("type","matrix")}${y("values",m)}${y("result",n)}/>`,i}function K$(t,e,n){let{amount:r,scale:i}=t;if(r===0)return we(e,n);let o=1/i,s="";return s+=`<feTurbulence${y("type","fractalNoise")}${y("baseFrequency",o)}${y("numOctaves",3)}${y("seed",0)}${y("result",`${n}_noise`)}/>`,s+=`<feColorMatrix${y("in",`${n}_noise`)}${y("type","saturate")}${y("values",0)}${y("result",`${n}_noiseGray`)}/>`,s+=`<feBlend${y("in",e)}${y("in2",`${n}_noiseGray`)}${y("mode","overlay")}${y("result",`${n}_blended`)}/>`,s+=`<feComposite${y("in",`${n}_blended`)}${y("in2",e)}${y("operator","arithmetic")}${y("k1",0)}${y("k2",r)}${y("k3",1-r)}${y("k4",0)}${y("result",`${n}_amt`)}/>`,s+=`<feComposite${y("in",`${n}_amt`)}${y("in2",e)}${y("operator","in")}${y("result",n)}/>`,s}function X$(t,e,n){let{strength:r,angle:i}=t;if(r===0)return we(e,n);let o=i*Math.PI/180,s=Math.cos(o),a=Math.sin(o),l=r,c=[-(l*(s+a)),-(l*a),l*(-s+a),-(l*s),1,l*s,l*(s-a),l*a,l*(s+a)].join(" ");return`<feConvolveMatrix${y("in",e)}${y("order","3 3")}${y("kernelMatrix",c)}${y("divisor",1)}${y("bias",.5)}${y("preserveAlpha","true")}${y("result",n)}/>`}function Y$(t,e,n){let{amount:r,size:i}=t;if(r===0)return we(e,n);let o=.5/i,s="";return s+=`<feTurbulence${y("type","fractalNoise")}${y("baseFrequency",`${o} ${o}`)}${y("numOctaves",5)}${y("seed",0)}${y("stitchTiles","stitch")}${y("result",`${n}_grain`)}/>`,s+=`<feColorMatrix${y("in",`${n}_grain`)}${y("type","saturate")}${y("values",0)}${y("result",`${n}_grainGray`)}/>`,s+=`<feBlend${y("in",e)}${y("in2",`${n}_grainGray`)}${y("mode","soft-light")}${y("result",`${n}_blended`)}/>`,s+=`<feComposite${y("in",`${n}_blended`)}${y("in2",e)}${y("operator","arithmetic")}${y("k1",0)}${y("k2",r)}${y("k3",1-r)}${y("k4",0)}${y("result",`${n}_amt`)}/>`,s+=`<feComposite${y("in",`${n}_amt`)}${y("in2",e)}${y("operator","in")}${y("result",n)}/>`,s}function q$(t,e,n){let{wetness:r,turbulence:i}=t;if(r===0&&i===0)return we(e,n);let o="";return o+=`<feTurbulence${y("type","fractalNoise")}${y("baseFrequency",.02+i*.03)}${y("numOctaves",4)}${y("seed",42)}${y("result",`${n}_turb`)}/>`,o+=`<feDisplacementMap${y("in",e)}${y("in2",`${n}_turb`)}${y("scale",r*15)}${y("xChannelSelector","R")}${y("yChannelSelector","G")}${y("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${y("in",`${n}_disp`)}${y("stdDeviation",r*2)}${y("result",`${n}_blur`)}/>`,o+=`<feBlend${y("in",`${n}_blur`)}${y("in2",e)}${y("mode","multiply")}${y("result",n)}/>`,o}function Z$(t,e,n){let{thickness:r,texture:i}=t;if(r===0&&i===0)return we(e,n);let o="";o+=`<feTurbulence${y("type","turbulence")}${y("baseFrequency",.03+i*.02)}${y("numOctaves",3)}${y("seed",1e3)}${y("result",`${n}_brush`)}/>`;let s=Math.max(3,8-Math.floor(r*5)),a=Array.from({length:s+1},(l,c)=>c/s).join(" ");o+=`<feComponentTransfer${y("in",e)}${y("result",`${n}_poster`)}>`;for(let l of["R","G","B"])o+=`<feFunc${l}${y("type","discrete")}${y("tableValues",a)}/>`;return o+="</feComponentTransfer>",o+=`<feDisplacementMap${y("in",`${n}_poster`)}${y("in2",`${n}_brush`)}${y("scale",i*4)}${y("xChannelSelector","R")}${y("yChannelSelector","G")}${y("result",`${n}_disp`)}/>`,o+=`<feMorphology${y("in",`${n}_disp`)}${y("operator","dilate")}${y("radius",r*.5)}${y("result",`${n}_thick`)}/>`,o+=`<feComposite${y("in",`${n}_thick`)}${y("in2",e)}${y("operator","in")}${y("result",n)}/>`,o}function J$(t,e,n){let{spread:r,edges:i}=t;if(r===0&&i===0)return we(e,n);let o="";return o+=`<feTurbulence${y("type","fractalNoise")}${y("baseFrequency",.01+i*.02)}${y("numOctaves",5)}${y("seed",1100)}${y("result",`${n}_ink`)}/>`,o+=`<feMorphology${y("in",e)}${y("operator","dilate")}${y("radius",r*3)}${y("result",`${n}_dilate`)}/>`,o+=`<feDisplacementMap${y("in",`${n}_dilate`)}${y("in2",`${n}_ink`)}${y("scale",i*10)}${y("xChannelSelector","R")}${y("yChannelSelector","G")}${y("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${y("in",`${n}_disp`)}${y("stdDeviation",r*.5)}${y("result",n)}/>`,o}function Q$(t,e,n){let{wrinkles:r,shine:i}=t;if(r===0&&i===0)return we(e,n);let o="";return o+=`<feTurbulence${y("type","turbulence")}${y("baseFrequency",.02)}${y("numOctaves",4)}${y("seed",1200)}${y("result",`${n}_wrinkle`)}/>`,o+=`<feDisplacementMap${y("in",e)}${y("in2",`${n}_wrinkle`)}${y("scale",r*15)}${y("xChannelSelector","R")}${y("yChannelSelector","G")}${y("result",`${n}_disp`)}/>`,o+=`<feSpecularLighting${y("in",`${n}_wrinkle`)}${y("surfaceScale",r*2)}${y("specularConstant",i*1.5)}${y("specularExponent",20)}${y("result",`${n}_sheen`)}>`,o+=`<feDistantLight${y("azimuth",45)}${y("elevation",60)}/>`,o+="</feSpecularLighting>",o+=`<feBlend${y("in",`${n}_disp`)}${y("in2",`${n}_sheen`)}${y("mode","screen")}${y("result",`${n}_blend`)}/>`,o+=`<feComposite${y("in",`${n}_blend`)}${y("in2",e)}${y("operator","in")}${y("result",n)}/>`,o}function eE(t,e,n){let{density:r,size:i}=t;if(r===0)return we(e,n);let o="",s=1-r;o+=`<feTurbulence${y("type","turbulence")}${y("baseFrequency",.1/i)}${y("numOctaves",1)}${y("seed",1400)}${y("result",`${n}_hole`)}/>`,o+=`<feComponentTransfer${y("in",`${n}_hole`)}${y("result",`${n}_thresh`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${y("type","linear")}${y("slope",10)}${y("intercept",-s*10+5)}/>`;o+="</feComponentTransfer>",o+=`<feComponentTransfer${y("in",`${n}_thresh`)}${y("result",`${n}_clamp`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${y("type","table")}${y("tableValues","0 0 1 1")}/>`;return o+="</feComponentTransfer>",o+=`<feComposite${y("in",e)}${y("in2",`${n}_clamp`)}${y("operator","in")}${y("result",n)}/>`,o}function tE(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return we(e,n);let{r:s,g:a,b:l}=Fa(r),c="";return c+=`<feColorMatrix${y("in",e)}${y("type","matrix")}${y("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${y("result",`${n}_alpha`)}/>`,c+=`<feGaussianBlur${y("in",`${n}_alpha`)}${y("stdDeviation",i/2)}${y("result",`${n}_blur`)}/>`,c+=`<feColorMatrix${y("in",`${n}_blur`)}${y("type","matrix")}${y("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${o} 0`)}${y("result",`${n}_color`)}/>`,c+=`<feMerge${y("result",n)}><feMergeNode${y("in",`${n}_color`)}/><feMergeNode${y("in",e)}/></feMerge>`,c}function nE(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return we(e,n);let{r:s,g:a,b:l}=Fa(r),c="";return c+=`<feColorMatrix${y("in",e)}${y("type","matrix")}${y("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${y("result",`${n}_alpha`)}/>`,c+=`<feMorphology${y("in",`${n}_alpha`)}${y("operator","erode")}${y("radius",i/4)}${y("result",`${n}_erode`)}/>`,c+=`<feComposite${y("in",`${n}_alpha`)}${y("in2",`${n}_erode`)}${y("operator","out")}${y("result",`${n}_edge`)}/>`,c+=`<feGaussianBlur${y("in",`${n}_edge`)}${y("stdDeviation",i/3)}${y("result",`${n}_blur`)}/>`,c+=`<feColorMatrix${y("in",`${n}_blur`)}${y("type","matrix")}${y("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${o*2} 0`)}${y("result",`${n}_color`)}/>`,c+=`<feComposite${y("in",`${n}_color`)}${y("in2",`${n}_alpha`)}${y("operator","in")}${y("result",`${n}_clipped`)}/>`,c+=`<feComposite${y("in",`${n}_clipped`)}${y("in2",e)}${y("operator","over")}${y("result",n)}/>`,c}function we(t,e){return`<feMerge${y("result",e)}><feMergeNode${y("in",t)}/></feMerge>`}function Au(t){switch(t.type){case"feBlend":return rE(t);case"feColorMatrix":return iE(t);case"feComponentTransfer":return oE(t);case"feComposite":return sE(t);case"feConvolveMatrix":return aE(t);case"feDiffuseLighting":return lE(t);case"feSpecularLighting":return cE(t);case"feDisplacementMap":return dE(t);case"feDropShadow":return uE(t);case"feFlood":return pE(t);case"feGaussianBlur":return fE(t);case"feImage":return mE(t);case"feMerge":return gE(t);case"feMorphology":return hE(t);case"feOffset":return yE(t);case"feTile":return SE(t);case"feTurbulence":return bE(t)}}function ct(t){let e="";if(e+=y("in",t.in),e+=y("x",t.x),e+=y("y",t.y),e+=y("width",t.width),e+=y("height",t.height),e+=y("color-interpolation-filters",t.colorInterpolationFilters),e+=y("result",t.result),t.unknownAttrs){let n=Object.keys(t.unknownAttrs).sort();for(let r of n)e+=y(r,t.unknownAttrs[r])}return e}function dt(t){return t.animations&&t.animations.length>0?t.animations.join(""):""}function rE(t){let e=`<feBlend${ct(t)}${y("in2",t.in2)}${y("mode",t.mode)}`;t.noComposite&&(e+=' no-composite="no-composite"');let n=dt(t);return n?`${e}>${n}</feBlend>`:`${e}/>`}function iE(t){let e=`<feColorMatrix${ct(t)}${y("type",t.matrixType)}${y("values",t.values)}`,n=dt(t);return n?`${e}>${n}</feColorMatrix>`:`${e}/>`}function _a(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}"${y("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${n} type="linear"${y("slope",e.slope)}${y("intercept",e.intercept)}/>`;case"gamma":return`<${n} type="gamma"${y("amplitude",e.amplitude)}${y("exponent",e.exponent)}${y("offset",e.offset)}/>`}}function oE(t){let e="";return e+=_a("R",t.funcR),e+=_a("G",t.funcG),e+=_a("B",t.funcB),e+=_a("A",t.funcA),e+=dt(t),`<feComponentTransfer${ct(t)}>${e}</feComponentTransfer>`}function sE(t){let e=`<feComposite${ct(t)}${y("in2",t.in2)}${y("operator",t.operator)}`;t.operator==="arithmetic"&&(e+=y("k1",t.k1),e+=y("k2",t.k2),e+=y("k3",t.k3),e+=y("k4",t.k4));let n=dt(t);return n?`${e}>${n}</feComposite>`:`${e}/>`}function aE(t){let e=`<feConvolveMatrix${ct(t)}`;e+=y("order",t.order),e+=y("kernelMatrix",t.kernelMatrix),e+=y("divisor",t.divisor),e+=y("bias",t.bias),e+=y("targetX",t.targetX),e+=y("targetY",t.targetY),e+=y("edgeMode",t.edgeMode),e+=y("kernelUnitLength",t.kernelUnitLength),t.preserveAlpha!==void 0&&(e+=y("preserveAlpha",t.preserveAlpha?"true":"false"));let n=dt(t);return n?`${e}>${n}</feConvolveMatrix>`:`${e}/>`}function MS(t){switch(t.kind){case"feDistantLight":return`<feDistantLight${y("azimuth",t.azimuth)}${y("elevation",t.elevation)}/>`;case"fePointLight":return`<fePointLight${y("x",t.x)}${y("y",t.y)}${y("z",t.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${y("x",t.x)}${y("y",t.y)}${y("z",t.z)}${y("pointsAtX",t.pointsAtX)}${y("pointsAtY",t.pointsAtY)}${y("pointsAtZ",t.pointsAtZ)}`;return e+=y("specularExponent",t.specularExponent),e+=y("limitingConeAngle",t.limitingConeAngle),e+"/>"}}}function lE(t){let e=`<feDiffuseLighting${ct(t)}`;e+=y("surfaceScale",t.surfaceScale),e+=y("diffuseConstant",t.diffuseConstant),e+=y("kernelUnitLength",t.kernelUnitLength),e+=y("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=MS(t.lightSource)),n+=dt(t),`${e}>${n}</feDiffuseLighting>`}function cE(t){let e=`<feSpecularLighting${ct(t)}`;e+=y("surfaceScale",t.surfaceScale),e+=y("specularConstant",t.specularConstant),e+=y("specularExponent",t.specularExponent),e+=y("kernelUnitLength",t.kernelUnitLength),e+=y("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=MS(t.lightSource)),n+=dt(t),`${e}>${n}</feSpecularLighting>`}function dE(t){let e=`<feDisplacementMap${ct(t)}`;e+=y("in2",t.in2),e+=y("scale",t.scale),e+=y("xChannelSelector",t.xChannelSelector),e+=y("yChannelSelector",t.yChannelSelector);let n=dt(t);return n?`${e}>${n}</feDisplacementMap>`:`${e}/>`}function uE(t){let e=`<feDropShadow${ct(t)}`;e+=y("dx",t.dx),e+=y("dy",t.dy),e+=y("stdDeviation",t.stdDeviation),e+=y("flood-color",t.floodColor),e+=y("flood-opacity",t.floodOpacity);let n=dt(t);return n?`${e}>${n}</feDropShadow>`:`${e}/>`}function pE(t){let e=`<feFlood${ct(t)}${y("flood-color",t.floodColor)}${y("flood-opacity",t.floodOpacity)}`,n=dt(t);return n?`${e}>${n}</feFlood>`:`${e}/>`}function fE(t){let e=`<feGaussianBlur${ct(t)}${y("stdDeviation",t.stdDeviation)}${y("edgeMode",t.edgeMode)}`,n=dt(t);return n?`${e}>${n}</feGaussianBlur>`:`${e}/>`}function mE(t){let e=`<feImage${ct(t)}`;t.href!==void 0?e+=y("href",t.href):t.xlinkHref!==void 0&&(e+=y("xlink:href",t.xlinkHref)),e+=y("preserveAspectRatio",t.preserveAspectRatio),e+=y("crossorigin",t.crossorigin);let n=dt(t);return n?`${e}>${n}</feImage>`:`${e}/>`}function gE(t){let e="";for(let n of t.nodes)e+=`<feMergeNode${y("in",n.in)}/>`;return e+=dt(t),`<feMerge${ct(t)}>${e}</feMerge>`}function hE(t){let e=`<feMorphology${ct(t)}${y("operator",t.operator)}${y("radius",t.radius)}`,n=dt(t);return n?`${e}>${n}</feMorphology>`:`${e}/>`}function yE(t){let e=`<feOffset${ct(t)}${y("dx",t.dx)}${y("dy",t.dy)}`,n=dt(t);return n?`${e}>${n}</feOffset>`:`${e}/>`}function SE(t){let e=`<feTile${ct(t)}`,n=dt(t);return n?`${e}>${n}</feTile>`:`${e}/>`}function bE(t){let e=`<feTurbulence${ct(t)}`;e+=y("baseFrequency",t.baseFrequency),e+=y("numOctaves",t.numOctaves),e+=y("seed",t.seed),e+=y("stitchTiles",t.stitchTiles),e+=y("type",t.turbulenceType);let n=dt(t);return n?`${e}>${n}</feTurbulence>`:`${e}/>`}function OS(t,e){let n=`<filter${y("id",t)}`;n+=y("x",e.x),n+=y("y",e.y),n+=y("width",e.width),n+=y("height",e.height),n+=y("filterUnits",e.filterUnits),n+=y("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(n+=y("color-interpolation-filters",e.filterColorInterpolation)),n+=y("flood-color",e.floodColor),n+=y("flood-opacity",e.floodOpacity),n+=y("lighting-color",e.lightingColor),n+=">",e.filterTitle&&(n+=`<title>${ue(e.filterTitle)}</title>`),e.filterDescription&&(n+=`<desc>${ue(e.filterDescription)}</desc>`);for(let r of e.primitives)n+=Au(r);if(e.filterAnimations)for(let r of e.filterAnimations)n+=r;return n+="</filter>",n}function DS(t,e,n,r){switch(t.type){case"drop-shadow":return x$(t,e,n);case"inner-shadow":return I$(t,e,n);case"gaussian-blur":return w$(t,e,n);case"motion-blur":return k$(t,e,n);case"point-light":{let i=t;return ES(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,n)}case"spot-light":{let i=t;return AS(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 R$(t,e,n);case"specular-lighting":return T$(t,e,n);case"outline":return P$(t,e,n);case"sharpen":return C$(t,e,n);case"pixelate":return $$(t,e,n);case"warp":return E$(t,e,n);case"morphology":return A$(t,e,n);case"contouring-discrete":return N$(t,e,n);case"contouring-table":return M$(t,e,n);case"round-edges":return O$(t,e,n);case"grayscale":return D$(t,e,n);case"channel-painter":return z$(t,e,n);case"brightness":return _$(t,e,n);case"contrast":return F$(t,e,n);case"opacity":return L$(t,e,n);case"invert":return B$(t,e,n);case"hue-rotate":return G$(t,e,n);case"saturate":return V$(t,e,n);case"black-and-white":return j$(t,e,n);case"sepia":return U$(t,e,n);case"duotone":return H$(t,e,n);case"xray":return W$(t,e,n);case"noise":return K$(t,e,n);case"emboss":return X$(t,e,n);case"film-grain":return Y$(t,e,n);case"watercolor":return q$(t,e,n);case"gouache":return Z$(t,e,n);case"ink-blot":return J$(t,e,n);case"crumpled-plastic":return Q$(t,e,n);case"riddled":return eE(t,e,n);case"glow":return tE(t,e,n);case"inner-glow":return nE(t,e,n);case"raw-svg":return t.svgContent;case"svg-primitive-chain":return t.primitives.map(Au).join("");default:return we(e,n)}}function La(t,e,n={}){let r=Eu(t,e,n);if(!r)return"";if(r.kind==="primitive-chain")return OS(t,r.chain);let i=r.attributes.map(([l,c])=>y(l,c)).join("");if(r.kind==="raw")return`<filter${i}>${r.content}</filter>`;let o="",s="SourceGraphic",a=0;for(let l of r.filters){let c=`result${a++}`;o+=DS(l,s,c),s=c}return`<filter${i}>${o}</filter>`}function vE(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(c=>c.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 l=r.state;e+=La(a,o,{colorInterpolation:l.filterColorInterpolation,filterUnits:l.filterUnits,primitiveUnits:l.primitiveUnits,x:l.filterX,y:l.filterY,width:l.filterWidth,height:l.filterHeight})}return e}function Ba(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(#${ue(i)})`).join(" "):`url(#filter-${ue(t)})`}function xE(t,e,n){let r=Ba(t,e,n);return r===null?"":` filter="${r}"`}var pe=(t,e,n={})=>({channel:"attribute",name:t,value:e,...n}),Nu=/^[A-Za-z_][\w:.-]*$/,Ga=(t,e)=>({channel:"style",name:t,value:e});function ze(t){return typeof t=="string"?t:null}function dr(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function ja(t,e){let n=t(e);if(n!==void 0)return n;let r=t("extra");return r&&typeof r=="object"?r[e]:void 0}function Ua(t){let e=ze(t("fillType"));if(e)return e;let n=t("fillGradient");return n&&typeof n=="object"?"r"in n?"radial-gradient":"linear-gradient":ja(t,"linearGradient")?"linear-gradient":ja(t,"radialGradient")?"radial-gradient":"solid"}function Ha(t){return t("fillGradient")??ja(t,"linearGradient")??ja(t,"radialGradient")}function FS(t){if(!t||typeof t!="object")return;let e=t.id;return typeof e=="string"&&e.length>0?e:void 0}function LS(t,e){let n=Ua(t),r=ze(t("fillLibraryId"))??FS(Ha(t)),i=n==="pattern"?`pattern-fill-${e}`:`gradient-fill-${e}`;return`url(#${r??i})`}function BS(t,e){let n=ze(t("strokeType"))??"solid",r=ze(t("strokeLibraryId"))??FS(t("strokeGradient")),i=n==="pattern"?`pattern-stroke-${e}`:`gradient-stroke-${e}`;return`url(#${r??i})`}function zS(t,e){let n=ze(t(`${e}Type`))??(e==="fill"?Ua(t):"solid"),r=e==="fill"?Ha(t):t("strokeGradient");if(t(e==="fill"?"inheritFill":"inheritStroke")===!0&&n==="solid"&&!r||n==="none")return null;let i=dr(t(`${e}Opacity`))??1,o=r&&typeof r=="object"?dr(r.opacity)??1:1,s=i*o;return s<1?s:t(e==="fill"?"preserveFillOpacity":"preserveStrokeOpacity")===!0?1:null}function IE(t){let e=ze(t("strokeDasharray"));return e||nd(ze(t("lineStyle"))??"solid",dr(t("dashLength"))??8,dr(t("gapLength"))??4)}function _S(t){if(!ze(t("strokeDasharray"))&&ze(t("lineStyle"))==="dotted")return"round";let n=ze(t("strokeLinecap"));return n&&n!=="butt"?n:null}function Va(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 Wa=[{id:"fill",keys:["fillColor","fillType","fillGradient","fillLibraryId","inheritFill"],project:(t,e)=>{let n=Ua(t);return t("inheritFill")===!0&&n==="solid"&&!Ha(t)?[pe("fill",null)]:n==="none"?[pe("fill","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[pe("fill",LS(t,e.shapeId))]:[pe("fill",ze(t("fillColor"))??"#000000")]}},{id:"element-opacity",keys:["opacity"],project:t=>{let e=dr(t("opacity"));return[pe("opacity",e!==null&&e<1?e:null)]}},{id:"fill-opacity",keys:["fillOpacity","preserveFillOpacity","fillType","fillGradient","inheritFill"],project:t=>[pe("fill-opacity",zS(t,"fill"))]},{id:"fill-rule",keys:["fillRule"],project:t=>{let e=ze(t("fillRule"));return[pe("fill-rule",e&&e!=="nonzero"?e:null)]}},{id:"stroke",keys:["borderColor","strokeType","strokeGradient","strokeLibraryId","inheritStroke"],project:(t,e)=>{let n=ze(t("strokeType"))??"solid";return t("inheritStroke")===!0&&n==="solid"&&!t("strokeGradient")?[pe("stroke",null)]:n==="none"?[pe("stroke","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[pe("stroke",BS(t,e.shapeId))]:[pe("stroke",ze(t("borderColor"))??"none")]}},{id:"stroke-width",keys:["borderWidth"],project:t=>{let e=t("borderWidth");return[pe("stroke-width",typeof e=="number"||typeof e=="string"?e:null)]}},{id:"stroke-opacity",keys:["strokeOpacity","preserveStrokeOpacity","strokeType","strokeGradient","inheritStroke"],project:t=>[pe("stroke-opacity",zS(t,"stroke"))]},{id:"blend-mode",keys:["blendMode"],project:t=>{let e=ze(t("blendMode"));return[Ga("mix-blend-mode",e&&e!=="normal"?e:null)]}},{id:"paint-order",keys:["paintOrder"],project:t=>{let e=ze(t("paintOrder"));return[pe("paint-order",e&&e!=="normal"?e:null)]}},{id:"inline-style",keys:["inlineStyle"],project:t=>Va(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])=>pe(String(e),typeof n=="string"&&n?`url(#${n})`:null))},{id:"stroke-linejoin",keys:["strokeLinejoin"],project:t=>{let e=ze(t("strokeLinejoin"));return[pe("stroke-linejoin",e&&e!=="miter"?e:null)]}},{id:"stroke-linecap",keys:["strokeLinecap"],project:t=>[pe("stroke-linecap",_S(t))]},{id:"stroke-miterlimit",keys:["strokeMiterlimit"],project:t=>{let e=dr(t("strokeMiterlimit"));return[pe("stroke-miterlimit",e!==null&&e!==4?e:null)]}},{id:"stroke-dasharray",keys:["lineStyle","dashLength","gapLength","strokeDasharray","strokeLinecap"],project:t=>[pe("stroke-dasharray",IE(t)),pe("stroke-linecap",_S(t))]},{id:"stroke-dashoffset",keys:["dashOffset"],project:t=>{let e=dr(t("dashOffset"));return[pe("stroke-dashoffset",e!==null&&e!==0?e:null)]}},{id:"shape-rendering",keys:["shapeRendering"],project:t=>{let e=ze(t("shapeRendering"));return[pe("shape-rendering",e&&e!=="auto"?e:null)]}},{id:"text-rendering",keys:["textRendering"],project:t=>{let e=ze(t("textRendering"));return[pe("text-rendering",e&&e!=="auto"?e:null)]}},{id:"image-rendering",keys:["imageRendering"],project:t=>{let e=ze(t("imageRendering"));return[pe("image-rendering",e&&e!=="auto"?e:null)]}},{id:"color-rendering",keys:["colorRendering"],project:t=>{let e=ze(t("colorRendering"));return[pe("color-rendering",e&&e!=="auto"?e:null)]}},{id:"color-interpolation",keys:["colorInterpolation"],project:t=>{let e=ze(t("colorInterpolation"));return[pe("color-interpolation",e&&e!=="sRGB"?e:null)]}},{id:"filter",keys:["filters","filterLibraryIds"],project:(t,e)=>[pe("filter",Ba(e.shapeId,t("filters"),t("filterLibraryIds")))]},{id:"system-language",keys:["systemLanguage"],project:t=>{let e=t("systemLanguage");return[pe("systemLanguage",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"required-extensions",keys:["requiredExtensions"],project:t=>{let e=t("requiredExtensions");return[pe("requiredExtensions",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"vector-effect",keys:["vectorEffect"],project:t=>{let e=ze(t("vectorEffect"));return[pe("vector-effect",e&&e!=="none"?e:null)]}},{id:"visibility",keys:["visibility"],project:t=>{let e=ze(t("visibility"));return[pe("visibility",e&&e!=="visible"?e:null)]}},{id:"display",keys:["displayAttr"],project:t=>[pe("display",t("displayAttr")==="none"?"none":null)]},{id:"visible",keys:["visible"],project:t=>[Ga("display",t("visible")===!1?"none":null)]},{id:"path-length",keys:["pathLength"],project:t=>{let e=dr(t("pathLength"));return[pe("pathLength",e!==null&&e>=0?e:null)]}},{id:"transform-box",keys:["transformBox"],project:t=>{let e=ze(t("transformBox"));return[Ga("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?Ln(e.name):"";if(n.push(pe("id",r||null)),n.push(pe("class",e?.classes&&e.classes.length>0?e.classes.join(" "):null)),n.push(pe("role",e?.role??null)),n.push(pe("aria-label",e?.ariaLabel??null)),e?.aria)for(let[i,o]of Object.entries(e.aria))i!=="aria-label"&&Nu.test(i)&&n.push(pe(i,o));if(n.push(pe("xml:lang",e?.lang??null)),typeof e?.tabindex=="number"&&Number.isFinite(e.tabindex)&&n.push(pe("tabindex",String(Math.trunc(e.tabindex)))),e?.autofocus&&n.push(pe("autofocus","",{allowEmpty:!0})),n.push(pe("xml:space",e?.xmlSpace??null)),e?.customData)for(let[i,o]of Object.entries(e.customData)){let s=`data-${i}`;Nu.test(s)&&n.push(pe(s,o))}if(e?.foreignAttrs)for(let i of e.foreignAttrs)Nu.test(i.name)&&n.push(pe(i.name,i.value));return n}},{id:"css-clip-path",keys:["cssClipPath"],project:t=>[Ga("clip-path",ze(t("cssClipPath")))]},{id:"css-mask-properties",keys:["cssMaskProperties"],project:t=>Va(t("cssMaskProperties"),"style")},{id:"container-presentation",keys:["containerPresentation"],project:(t,e)=>e.includeContainerPresentation?Va(t("containerPresentation"),"attribute",{ifAbsent:!0}):[]},{id:"authored-attributes",keys:["authoredAttributes"],project:(t,e)=>e.includeAuthoredAttributes?Va(t("authoredAttributes"),"attribute",{ifAbsent:!0}):[]}];function Mu(t,e,n){return t.project(e,n)}function Vo(t,e){return Wa.flatMap(n=>n.project(t,e))}function ur(t){let e=t;return n=>n==="displayAttr"?t.display:e[n]}function Ou(t){return Ua(e=>t[e])}function GS(t){return Ha(e=>t[e])}function VS(t,e){return LS(ur(t),e)}function jS(t,e){return BS(ur(t),e)}var wE=[["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 ue(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Ka(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 l=r.rx??r.cornerRadius??0,c=r.ry??r.cornerRadius??0;(l>0||c>0)&&(e.set("rx",String(l)),e.set("ry",String(c)))}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[l,c]of wE){let u=typeof r[l]=="string"?String(r[l]).trim():"";u&&n.set(c,u)}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 l of Vo(ur(r),{shapeId:t.id,includeAuthoredAttributes:!0})){if(l.channel==="style"){n.delete(l.name),l.value!==null&&l.value!==""&&n.set(l.name,String(l.value));continue}l.ifAbsent&&e.has(l.name)||(e.delete(l.name),!(l.value===null||l.value===""&&!l.allowEmpty)&&e.set(l.name,String(l.value)))}n.size>0&&e.set("style",[...n].map(([l,c])=>`${l}: ${c}`).join("; "));let o=kE(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 US(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 kE(t){return gt(t)}function HS(t,e){let n=t.viewboxes?.[0];return{width:e.width??n?.width??800,height:e.height??n?.height??600}}var zr="https://svgsketch.com/ns/metadata",_i="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Lt="http://purl.org/dc/elements/1.1/",_r="http://creativecommons.org/ns#",RE="http://www.w3.org/2000/svg",Xa={rdf:_i,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:Lt,dcterms:"http://purl.org/dc/terms/",cc:_r,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:zr},Ya=new Set([`${Lt}|creator`,`${Lt}|subject`,`${Lt}|rights`,`${Lt}|description`,`${_r}|license`]);function Fu(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=Xa[n];return i?{ns:i,local:r,prefix:n}:null}var TE={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"},PE={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 WS(t,e){return t==="custom"?e||"":TE[t]||""}function KS(t){return PE[t]||t}function zu(t){return!!(t.author||t.keywords&&t.keywords.length>0||t.license||t.customMetadata&&Object.keys(t.customMetadata).length>0)}function Lu(t){let e=[];if(t.author&&e.push(`<dc:creator>${ue(t.author)}</dc:creator>`),t.keywords&&t.keywords.length>0&&e.push(`<dc:subject>${ue(t.keywords.join(", "))}</dc:subject>`),t.license){let n=WS(t.license,t.licenseUrl);n&&e.push(`<cc:license rdf:resource="${ue(n)}"/>`),e.push(`<dc:rights>${ue(KS(t.license))}</dc:rights>`)}if(t.customMetadata)for(let[n,r]of Object.entries(t.customMetadata)){let i=Fu(n);if(i){if(Ya.has(`${i.ns}|${i.local}`))continue;e.push(`<${i.prefix}:${i.local}>${ue(r??"")}</${i.prefix}:${i.local}>`)}else e.push(`<svgsketch:custom key="${ue(n)}" value="${ue(r??"")}"/>`)}return e.join(`
18
+ `)}function XS(t){let e=Lu(t);return e.length>0?`<rdf:Description svgsketch:managed="true">
19
+ ${e}
20
+ </rdf:Description>`:`<rdf:Description svgsketch:managed="true">
21
+ </rdf:Description>`}function _u(t){let e={rdf:_i,dc:Lt,cc:_r,svgsketch:zr};if(t.customMetadata)for(let r of Object.keys(t.customMetadata)){let i=Fu(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
+ `+XS(t)+`
24
+ </rdf:RDF>
25
+ </metadata>`}var CE=["dc:creator","dc:subject","dc:rights","dc:description","cc:license","svgsketch:custom"];function $E(t){let e=t;for(let n of CE)e=e.replace(new RegExp(`<${n}\\b[^>]*/>\\s*`,"g"),""),e=e.replace(new RegExp(`<${n}\\b[^>]*>[\\s\\S]*?</${n}>\\s*`,"g"),"");return e}function YS(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,l=Lu(e),c=`<rdf:Description svgsketch:managed="true"${o}>`,u;if(s==="/")u=t.slice(0,a)+`${c}
26
+ ${l}
27
+ </rdf:Description>`+t.slice(a+i.length);else{let p=t.lastIndexOf("</rdf:Description>");if(p<=a)return null;let f=$E(t.slice(a+i.length,p));u=t.slice(0,a)+c+f+`${l}
28
+ `+t.slice(p)}let d=[["svgsketch",zr],["dc",Lt],["cc",_r]];return u=u.replace(/<rdf:RDF\b((?:[^>"']|"[^"]*"|'[^']*')*?)>/,(p,f)=>{let g="";for(let[m,h]of d)u.includes(`xmlns:${m}=`)||(g+=` xmlns:${m}="${h}"`);return g?`<rdf:RDF${f}${g}>`:p}),u}function qS(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 Bu(t){return t?.language?` xml:lang="${ue(t.language)}"`:""}function Du(t,e,n){let r=n?` xml:lang="${ue(n)}"`:"";return`<${t}${r}>${ue(e)}</${t}>`}function ZS(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:Du(i.kind,s,i.language))}return!n.title&&t.title&&r.unshift(Du("title",t.title,null)),!n.desc&&t.description&&r.push(Du("desc",t.description,null)),r.join("")}function Fi(t){if(!t)return"";let e="",n=ZS(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${ue(t.title)}</title>`),t.description||t.rawDescription){let r=qS(t.rawDescription??""),i=(t.description??"").trim();e+=t.rawDescription&&r===i?`<desc>${t.rawDescription}</desc>`:`<desc>${ue(t.description??"")}</desc>`}return t.rawMetadata&&(e+=t.rawMetadata),e}function Gu(t){if(!t)return"";let e="",n=ZS(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${ue(t.title)}</title>`),t.description||t.rawDescription){let r=qS(t.rawDescription??""),i=(t.description??"").trim();t.rawDescription&&r===i?e+=`<desc>${t.rawDescription}</desc>`:e+=`<desc>${ue(t.description)}</desc>`}if(t.rawMetadata)if(!t.rawMetadataAuthoritative&&zu(t)&&!t.rawMetadata.includes("svgsketch:managed")){let r=YS(t.rawMetadata,t);e+=r??_u(t)+t.rawMetadata}else e+=t.rawMetadata;else zu(t)&&(e+=_u(t));return t.rawHtmlMetadata&&(e+=t.rawHtmlMetadata),e}var Vu="http://www.w3.org/1999/xhtml",Uu="http://www.w3.org/XML/1998/namespace",EE="http://www.w3.org/1999/xlink",ju="http://www.w3.org/2000/xmlns/",AE=new Set([W,Uu,EE,Vu,ju]),NE=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"]),ME=Object.freeze(Object.fromEntries(Object.entries(Xa).map(([t,e])=>[e,t])));function Hu(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Wu(t){let e=Hu(t,"lang",Uu);return e?e.value:E(t,"lang")}function Fr(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 eb(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function OE(t){return eb(t).replaceAll('"',"&quot;")}function DE(t){switch(t.kind){case"text":return eb(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 zE(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 _E(t,e){let n=zE(e),r=new Map;for(let o of e.attributes)(o.namespaceUri===ju||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===ju||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 tb(t,e=[]){let n=[...e,...t.attributes].map(s=>`${s.name}="${OE(s.value)}"`),r=`<${t.name}${n.length>0?` ${n.join(" ")}`:""}`,i=t.children.map(nb).join(""),o=/\/\s*>\s*$/u.test(t.rawXml??"");return i.length===0&&o?`${r}/>`:`${r}>${i}</${t.name}>`}function nb(t){return t.kind==="element"?tb(t):DE(t)}function jo(t,e){return tb(e,_E(t,e))}function Ku(t,e){return t.children.map(n=>n.kind!=="element"||!e?nb(n):jo(e,n)).join("")}function rb(t,e,n){return e.children.filter(r=>r.kind==="element"&&(r.namespaceUri===W||t.root.namespaceUri===null&&r.namespaceUri===null)&&r.localName.toLowerCase()===n)}function ib(t,e){return Object.freeze(e.children.filter(n=>n.kind==="element"&&(n.namespaceUri===W||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:Wu(n),text:Fr(n).trim(),rawInnerXml:Ku(n),rawXml:jo(t,n)})))}function ob(t){return t.map(({kind:e,language:n,text:r,rawXml:i})=>({kind:e,language:n,text:r,rawXml:i}))}function sb(t){return t.children.some(e=>e.kind==="element")}function FE(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 LE(t,e,n,r,i){let o={};n.length>0&&(o.descriptiveElements=ob(n));let s=E(e,"id");s&&(o.name=s);let a=(E(e,"class")??"").split(/\s+/u).filter(Boolean);a.length>0&&(o.classes=a);let l=n.find(S=>S.kind==="title"),c=n.find(S=>S.kind==="desc");if(l?.text&&(o.title=l.text),c?.text&&(o.description=c.text),c){let S=t.index.element(c.sourceNodeId);S&&sb(S)&&(o.rawDescription=Ku(S,t))}let u=E(e,"role");u&&(o.role=u);let d=E(e,"aria-label");d&&(o.ariaLabel=d);let p={},f={};for(let S of e.attributes)S.namespaceUri===null&&(S.name.startsWith("aria-")&&S.name!=="aria-label"&&S.value&&(p[S.name]=S.value),S.name.startsWith("data-")&&!NE.has(S.name)&&(f[S.name.slice(5)]=S.value));Object.keys(p).length>0&&(o.aria=p),Object.keys(f).length>0&&(o.customData=f);let g=Wu(e);g!==null&&(o.lang=g);let m=E(e,"tabindex");if(m!==null){if(/^[+-]?\d+$/u.test(m.trim())){let S=Number(m);Number.isSafeInteger(S)&&(o.tabindex=S)}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 "${m}" was ignored.`})}if(lt(e,"autofocus")&&(o.autofocus=!0),!["text","tspan","flowroot"].includes(e.localName.toLowerCase())){let S=Hu(e,"space",Uu)?.value;(S==="default"||S==="preserve")&&(o.xmlSpace=S)}let h=e.attributes.filter(S=>S.namespaceUri!==null&&!AE.has(S.namespaceUri)).map(S=>({name:S.name,namespaceURI:S.namespaceUri,value:S.value}));h.length>0&&(o.foreignAttrs=h);let b=rb(t,e,"metadata").map(S=>jo(t,S)).join(`
29
+ `);return b&&(o.rawMetadata=b),FE(o)}function JS(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 QS(t,e,n){return Hu(t,e,n)?.value??null}function BE(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 GE(t){let e=t.flatMap(p=>JS(p).filter(f=>f.namespaceUri===_i&&f.localName==="Description")),n=e.find(p=>QS(p,"managed",zr)==="true")??e[0];if(!n)return{};let r={},i=JS(n),o=i.find(p=>p.namespaceUri===Lt&&p.localName==="creator");o?.children.length&&(r.author=Fr(o).trim());let s=i.find(p=>p.namespaceUri===Lt&&p.localName==="subject");if(s){let p=Fr(s).split(",").map(f=>f.trim()).filter(Boolean);p.length>0&&(r.keywords=p)}let a=i.find(p=>p.namespaceUri===_r&&p.localName==="license"),l=i.find(p=>p.namespaceUri===Lt&&p.localName==="rights"),c=a?QS(a,"resource",_i)??Fr(a).trim():l?Fr(l).trim():"";c&&(r.license=BE(c),r.license==="custom"&&(r.licenseUrl=c));let u={},d=n.children.filter(p=>p.kind==="element");for(let p of d){if(p.namespaceUri===zr&&p.localName==="custom"){let h=E(p,"key");h!==null&&(u[h]=E(p,"value")??"");continue}let f=p.namespaceUri??"";if(Ya.has(`${f}|${p.localName}`))continue;let g=ME[f];if(!g)continue;let m=`${g}:${p.localName}`;m in u||(u[m]=Fr(p).trim())}if(Object.keys(u).length===0)for(let p of d){if(p.namespaceUri!==Lt||p.localName!=="description")continue;let f=Fr(p),g=f.indexOf(":");if(g<=0)continue;let m=f.slice(0,g).trim();m&&(u[m]=f.slice(g+1).trim())}return Object.keys(u).length>0&&(r.customMetadata=u),r}function VE(t){let e=t.root,n=ib(t,e),r=rb(t,e,"metadata"),i=GE(r);n.length>0&&(i.descriptiveElements=ob(n));let o=Wu(e);o!==null&&(i.language=o);let s=n.find(d=>d.kind==="title"),a=n.find(d=>d.kind==="desc");if(s?.text&&(i.title=s.text),a?.text&&(i.description=a.text),a){let d=t.index.element(a.sourceNodeId);d&&sb(d)&&(i.rawDescription=Ku(d,t))}let l=r.map(d=>jo(t,d)).join(`
30
+ `);l&&(i.rawMetadata=l,i.rawMetadataAuthoritative=!0);let c=Object.freeze(e.children.filter(d=>d.kind==="element"&&d.namespaceUri===Vu&&["base","link","meta"].includes(d.localName.toLowerCase())).map(d=>Object.freeze({sourceNodeId:d.sourceNodeId,localName:d.localName.toLowerCase(),namespaceUri:Vu,rawXml:jo(t,d)})));c.length>0&&(i.rawHtmlMetadata=c.map(d=>d.rawXml).join(`
31
+ `));let u=[];for(let d=e.children.length-1;d>=0;d--){let p=e.children[d];if(p.kind==="comment"){u.unshift(p.value);continue}if(!(p.kind==="text"&&!p.value.trim()))break}if(u.length>0&&(i.trailingComments=u),i.keywords&&Object.freeze(i.keywords),i.customMetadata&&Object.freeze(i.customMetadata),i.trailingComments&&Object.freeze(i.trailingComments),i.descriptiveElements){for(let d of i.descriptiveElements)Object.freeze(d);Object.freeze(i.descriptiveElements)}return Object.freeze({sourceNodeId:e.sourceNodeId,metadata:Object.freeze(i),descriptiveElements:n,htmlMetadata:c})}function Xu(t,e){let n=[],r=[];for(let a of t.index.elements){if(a===t.root||a.namespaceUri!==W&&!(t.root.namespaceUri===null&&a.namespaceUri===null))continue;let l=ib(t,a),c=LE(t,a,l,e,n);Object.keys(c).length===0&&l.length===0||r.push(Object.freeze({sourceNodeId:a.sourceNodeId,metadata:c,descriptiveElements:l}))}let i=Object.freeze(r),o=new Map(i.map(a=>[a.sourceNodeId,a]));return{value:Object.freeze({document:VE(t),candidates:i,candidate(a){return o.get(a)??null}}),diagnostics:Object.freeze(n)}}var jE="https://boxy-svg.com",Zu=new Set(["cursive","emoji","fangsong","fantasy","math","monospace","sans-serif","serif","system-ui","ui-monospace","ui-rounded","ui-sans-serif","ui-serif"]);function ab(t){return/[\t\n\f\r ]/u.test(t??"")}function Za(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function UE(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,Za(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 Qa(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,Za(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 l=t.slice(i+1,a).toLowerCase(),c=a,u=null,d=!1,p=0;for(;c<t.length;c++){let g=t[c];if(u){d?d=!1:g==="\\"?d=!0:g===u&&(u=null);continue}if(g==="/"&&t[c+1]==="*"){c=Math.max(c,Za(t,c)-1);continue}if(g==='"'||g==="'"){u=g;continue}if(g==="(")p++;else if(g===")")p=Math.max(0,p-1);else if(p===0&&(g===";"||g==="{"))break}if(c>=t.length)continue;if(t[c]===";"){e.push(Object.freeze({name:l,start:s,end:c+1,preludeStart:a,preludeEnd:c,blockStart:null,blockEnd:null})),i=c;continue}let f=UE(t,c);e.push(Object.freeze({name:l,start:s,end:Math.min(t.length,f+1),preludeStart:a,preludeEnd:c,blockStart:c+1,blockEnd:f}))}return Object.freeze(e)}function el(t){let e=t.trim();if(e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))){let n=e.slice(1,-1);return xo(n)??n}return xo(e)??e}function tl(t){let e=mn(t).find(r=>r.name==="url");if(e)return el(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 Ju(t,e=0){let n=[];for(let r of mn(t)){if(r.name==="url"){n.push(Object.freeze({rawUrl:el(t.slice(r.argumentsStart,r.argumentsEnd)),tokenStart:e+r.tokenStart,tokenEnd:e+r.tokenEnd}));continue}n.push(...Ju(t.slice(r.argumentsStart,r.argumentsEnd),e+r.argumentsStart))}return Object.freeze(n)}function HE(t){let e=Qa(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=tl(t.slice(o.preludeStart,o.preludeEnd));s!==null&&r.push(Object.freeze({url:s,channel:"css-import",tokenIndex:i})),i++}for(let o of Ju(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=nl(e);return Object.freeze(n?{status:"external",requestUrl:n.href}:{status:"blocked",requestUrl:null})}function cb(t){return Lr(t).status==="data"?t:""}var WE=new Set(["feimage","iframe","image","link","mpath","script","textpath","use"]),KE=new Set(["audio","embed","iframe","img","input","script","source","track","video"]);function Qu(t){return t.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;")}function db(t){return Qu(t).replace(/"/gu,"&quot;")}function Yu(t){return t.trim().startsWith("#")?t:cb(t)}function ub(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"?qa(t.value):t.value;return Qu(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 l=a.name.toLowerCase(),c=a.localName.toLowerCase();if(/^on/iu.test(l))continue;let u=a.value;c==="style"?u=qa(u):(l==="href"||l==="xlink:href")&&WE.has(n)||c==="src"&&KE.has(n)||c==="poster"&&n==="video"||c==="data"&&n==="object"?u=Yu(u):c==="srcset"?u="":a.namespaceUri===null&&!l.startsWith("xmlns")&&(u=qa(u)),i.push(`${a.name}="${db(u)}"`)}let o=i.length>0?`<${t.name} ${i.join(" ")}>`:`<${t.name}>`,s=t.children.map(a=>ub(a,n)).join("");return`${o}${s}</${t.name}>`}function XE(t){let e=Sn(t,{source:"svg",entrypoint:"svg-document-import"});if(!e.value)return"";let n=ub(e.value.root,null);return t.trimStart().startsWith("<?xml")?`<?xml version="1.0" encoding="UTF-8"?>
32
+ ${n}`:n}var YE=new Set(["animate","animatemotion","animatetransform","desc","metadata","mpath","set","title"]);function qE(t){switch(t.kind){case"text":return Qu(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 pb(t,e,n){let r=t.sourceNodeId===e,i=new Map(t.attributes.map(d=>[d.name,d.value])),o=t.attributes.map(d=>d.name),s=(d,p)=>{if(p===null){i.delete(d);return}i.has(d)||o.push(d),i.set(d,p)};r&&Object.prototype.hasOwnProperty.call(n,"clipPathUnits")&&s("clipPathUnits",n.clipPathUnits??null),n.clipRule!==void 0&&(r||!YE.has(t.localName.toLowerCase()))&&s("clip-rule",n.clipRule);let a=o.filter((d,p)=>o.indexOf(d)===p&&i.has(d)).map(d=>`${d}="${db(i.get(d))}"`),l=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,c=t.children.map(d=>d.kind==="element"?pb(d,e,n):qE(d)).join(""),u=/\/\s*>\s*$/u.test(t.rawXml??"");return c.length===0&&u?`${l}/>`:`${l}>${c}</${t.name}>`}function ZE(t,e){let n=Sn(`<svg xmlns="${W}">${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:pb(r,r.sourceNodeId,e)}function nl(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 l=e[3]||"/",c=l.indexOf("?"),u=l.indexOf("#",Math.max(0,c)),d=c<0?"":l.slice(c+1,u<0?void 0:u);return Object.freeze({href:`${n}://${o}${s.toLowerCase()}${l}`,hostname:a,query:d})}function lb(t){try{return decodeURIComponent(t.replace(/\+/gu," "))}catch{return t.replace(/\+/gu," ")}}function ep(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,Za(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 JE(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&(ab(t[n])||t[n]===",");)n++;if(n>=t.length)break;let r=n;for(;n<t.length&&!ab(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 tp(t){if(typeof t!="string")return null;let e=el(ep(t)[0]??"").trim();return!e||Zu.has(e.toLowerCase())?null:e}function QE(t){let e=[];for(let n of On(t,";")){let r=t.slice(n.start,n.end),i=On(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 eA(t){let e=mn(t).find(n=>n.name==="format");return e&&el(t.slice(e.argumentsStart,e.argumentsEnd))||null}var tA=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 nA(t){let e={};for(let n of t){let r=tA[n.property];r&&n.value&&(e[r]=n.value)}return Object.keys(e).length>0?Object.freeze(e):void 0}function np(t){let e=[];for(let n of Qa(t)){if(n.name!=="font-face"||n.blockStart===null||n.blockEnd===null)continue;let r=QE(t.slice(n.blockStart,n.blockEnd)),i=tp(r.find(a=>a.property==="font-family")?.value),o=r.find(a=>a.property==="src")?.value;if(!i||!o)continue;let s=nA(r);for(let a of ep(o)){let l=tl(a);if(l===null)continue;let c=Lr(l);c.status!=="external"||!c.requestUrl||e.push(Object.freeze({family:i,url:c.requestUrl,format:eA(a),...s?{descriptors:s}:{}}))}}return Object.freeze(e)}function fb(t){let e=[];for(let n of Qa(t)){if(n.name!=="import")continue;let r=tl(t.slice(n.preludeStart,n.preludeEnd));if(r===null)continue;let i=Lr(r);if(i.status!=="external"||!i.requestUrl)continue;let o=nl(i.requestUrl);if(!o||o.hostname!=="fonts.googleapis.com")continue;let s=o.query.split("&").map(a=>a.split("=",2)).filter(([a])=>lb(a).toLowerCase()==="family").map(([,a])=>lb(a??""));for(let a of s)for(let l of a.split("|")){let c=l.split(":")[0].trim();c&&!Zu.has(c.toLowerCase())&&e.push(c)}}return Object.freeze(e)}function rA(t){return On(t,";").map(e=>{let n=t.slice(e.start,e.end),r=On(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=ep(n.slice(r+1)).filter(a=>{let l=tl(a);return l===null||Lr(l).status==="data"});return`${o} ${s.length>0?s.join(", "):'local("__svgsketch_quarantined_font__")'}`}).join(";")}function qa(t){let e=[];for(let i of Qa(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:rA(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=Ju(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 iA(t,e,n){let r=[];for(let i of e.stylesheets)if(i.applicable){for(let o of fb(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"google-font-import",family:o}));for(let o of np(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!==jE||o.localName!=="fonts"))for(let s of o.value.split(",")){let a=s.replace(/\+/gu," ").trim();!a||a.includes("/")||Zu.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 l=tp(a);l&&r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:i.occurrenceId,origin:"text-font-family",family:l}))};o(i.state.fontFamily);let s=di(i.state);if(s){o(s.baseStyle.fontFamily);for(let a of s.runs)o(a.style.fontFamily)}}return Object.freeze(r)}function Bt(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName.toLowerCase()===e.toLowerCase())?.value??null}function Ja(t){return t.children.map(e=>e.kind==="text"||e.kind==="cdata"?e.value:"").join("")}function rl(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 ln(t,e){let n=Lr(e.href);t.push(Object.freeze({...e,...n}))}function Bi(t,e,n,r=new Set(["css-import","css-url"]),i=()=>!0){for(let o of HE(e))!r.has(o.channel)||!i(o)||o.url.trim().startsWith("#")||ln(t,{...n,occurrenceId:`${n.occurrenceId}:css:${o.tokenIndex}`,channel:o.channel,href:o.url,hrefNamespace:null})}function rp(t,e,n,r){for(let i of rl(e,n.sourceNodeId)){let o=i.localName.toLowerCase(),s=Bt(i,"id"),a={sourceNodeId:i.sourceNodeId,occurrenceId:`${r}:foreign:${i.sourceNodeId}`,sourceId:s,elementName:i.localName},l=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(o)||o==="input"&&Bt(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"&&(Bt(i,"rel")??"").split(/\s+/u).some(d=>d.toLowerCase()==="stylesheet")}];for(let d of l){if(!d.applies)continue;let p=Bt(i,d.attributeName);p!==null&&ln(t,{...a,occurrenceId:`${a.occurrenceId}:${d.attributeName}`,attributeName:d.attributeName,channel:d.channel,href:p,hrefNamespace:null})}let c=Bt(i,"srcset");if(c!==null&&(o==="img"||o==="source"))for(let[d,p]of JE(c).entries())ln(t,{...a,occurrenceId:`${a.occurrenceId}:srcset:${d}`,attributeName:"srcset",channel:"html-srcset",href:p,hrefNamespace:null});let u=Bt(i,"style");u!==null&&Bi(t,u,{...a,attributeName:"style"}),o==="style"&&Bi(t,Ja(i),{...a,attributeName:"textContent"})}}function oA(t,e,n,r){let i=Bt(n,"data-shape-type")?.toLowerCase();if(i==="video"||i==="audio"){let o=rl(e,n.sourceNodeId).find(s=>s.localName.toLowerCase()===i);if(o){let s=Bt(o,"src")??"";if(ln(t,{sourceNodeId:o.sourceNodeId,occurrenceId:`${r}:media:src`,sourceId:Bt(o,"id"),elementName:i,attributeName:"src",channel:"html-src",href:s,hrefNamespace:null}),i==="video"){let a=Bt(n,"data-poster")??Bt(o,"poster");a!==null&&ln(t,{sourceNodeId:n.sourceNodeId,occurrenceId:`${r}:media:poster`,sourceId:Bt(n,"id"),elementName:"video",attributeName:"poster",channel:"html-poster",href:a,hrefNamespace:null})}}return}rp(t,e,n,r)}function sA(t,e,n){let r=[];for(let i of e.occurrences){let o=t.index.element(i.correspondingSourceNodeId);if(!o||o.namespaceUri!==W)continue;let s=o.localName.toLowerCase();if(s==="image"||s==="feimage"){let a=Ee(o)??{value:"",namespace:"svg2"};ln(r,{sourceNodeId:o.sourceNodeId,occurrenceId:i.occurrenceId,sourceId:E(o,"id"),elementName:s==="feimage"?"feImage":"image",attributeName:"href",channel:"svg-href",href:a.value,hrefNamespace:a.namespace})}else s==="foreignobject"&&oA(r,t,o,i.occurrenceId)}for(let i of n.stylesheets)i.applicable&&Bi(r,i.authoredText,{sourceNodeId:i.sourceNodeId,occurrenceId:`style:${i.sourceNodeId}`,sourceId:i.id,elementName:"style",attributeName:"textContent"},new Set(["css-import"]),o=>nl(o.url)?.hostname!=="fonts.googleapis.com");for(let i of n.elements){let o=t.index.element(i.correspondingSourceNodeId);if(!(!o||o.namespaceUri!==W))for(let s of Object.values(i.cascadedValues))Bi(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 mb(t,e,n){let r=[...new Set(t.filter(u=>u.origin==="google-font-import"||u.origin==="boxy-fonts").map(u=>u.family))].sort(),i=[],o=new Set;for(let u of t){if(u.origin!=="external-font-face"||!u.url)continue;let d=`${u.family}\0${u.url}\0${u.format??""}\0${JSON.stringify(u.descriptors??{})}`;o.has(d)||(o.add(d),i.push(Object.freeze({family:u.family,url:u.url,format:u.format??null,...u.descriptors?{descriptors:u.descriptors}:{}})))}i.sort((u,d)=>u.family.localeCompare(d.family)||u.url.localeCompare(d.url)||(u.format??"").localeCompare(d.format??""));let s=[...new Set([...r,...i.map(u=>u.family)])].sort(),a=[...new Set(e.filter(u=>u.status==="external"&&u.requestUrl).map(u=>u.requestUrl))].sort(),l=[];s.length>0&&l.push(Object.freeze({kind:"font-consent",families:s,googleFamilies:r,...i.length>0?{externalSources:i}:{}})),a.length>0&&l.push(Object.freeze({kind:"external-asset-resolution",urls:a})),Object.freeze(s),Object.freeze(r),Object.freeze(i),Object.freeze(a),Object.freeze(l);let c=Object.freeze({fontCandidates:t,assetCandidates:e,effects:l});return Object.freeze({value:c,diagnostics:n})}function ip(t,e,n,r,i){return mb(iA(t,n,r),sA(t,e,n),Object.freeze([]))}function aA(t){let e=t.state,n=e.extra;return typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,...e}:e}function op(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sp(t,e,n){for(let r of fb(e))t.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"google-font-import",family:r}));for(let r of np(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 gb(t,e,n,r){sp(t,n,r),Bi(e,n,{sourceNodeId:r,occurrenceId:r,sourceId:null,elementName:"style",attributeName:"textContent"},void 0,o=>nl(o.url)?.hostname!=="fonts.googleapis.com");let i=new Set(np(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 hb(t,e,n,r,i,o){let s=Sn(`<svg xmlns="${W}"><foreignObject>${n}</foreignObject></svg>`,i);if(!s.value){o.push(...s.diagnostics.map(l=>Object.freeze({...l,severity:"warning",message:`Canonical foreign content could not be inspected for external requests: ${l.message}`,documentPath:r})));return}let a=s.value.index.children(s.value.root.sourceNodeId).find(l=>l.localName.toLowerCase()==="foreignobject");if(a){rp(e,s.value,a,r);for(let l of rl(s.value,a.sourceNodeId))l.localName.toLowerCase()==="style"&&sp(t,Ja(l),`${r}:${l.sourceNodeId}`)}}function ap(t,e,n,r){Bi(t,e,{sourceNodeId:n,occurrenceId:`${n}:${r}`,sourceId:null,elementName:"canonical-state",attributeName:r})}function Uo(t,e,n){if(op(e))for(let[r,i]of Object.entries(e))typeof i=="string"&&ap(t,i,n,r)}function lp(t,e,n,r,i,o){if(Array.isArray(n))for(let[s,a]of n.entries()){if(!op(a))continue;let l=`${r}:filter:${s}`;a.type==="feImage"&&ln(e,{sourceNodeId:r,occurrenceId:l,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"&&Li(t,e,a.svgContent,`${l}:raw`,i,o),lp(t,e,a.primitives,`${l}:primitives`,i,o)}}function qu(t,e,n,r,i,o){!op(n)||typeof n.svgContent!="string"||Li(t,e,n.svgContent,r,i,o)}function lA(t,e,n,r,i,o){let s=aA(n),a=`snapshot:${r}:${n.id}`;if(n.type==="text"){let l=u=>{let d=tp(u);d&&t.push(Object.freeze({sourceNodeId:a,occurrenceId:a,origin:"text-font-family",family:d}))};l(s.fontFamily);let c=di(s);if(c){l(c.baseStyle.fontFamily);for(let u of c.runs)l(u.style.fontFamily)}}n.type==="image"?ln(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"?(ln(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"&&ln(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"&&hb(t,e,s.rawContent,a,i,o),qu(t,e,s.fillGradient,`${a}:fillGradient`,i,o),qu(t,e,s.strokeGradient,`${a}:strokeGradient`,i,o),lp(t,e,s.filters,a,i,o),Uo(e,s.authoredAttributes,`${a}:authored`),Uo(e,s.containerPresentation,`${a}:container-presentation`),Uo(e,s.instancePresentation,`${a}:instance-presentation`),Uo(e,s.cssMaskProperties,`${a}:mask`),typeof s.cssClipPath=="string"&&ap(e,s.cssClipPath,a,"clip-path")}function Li(t,e,n,r,i,o){let s=Sn(`<svg xmlns="${W}">${n}</svg>`,i);if(!s.value){o.push(...s.diagnostics.map(l=>Object.freeze({...l,severity:"warning",message:`Canonical raw definition could not be inspected for external requests: ${l.message}`,documentPath:r})));return}let a=new Set;for(let l of s.value.index.elements){if(l.localName.toLowerCase()!=="foreignobject")continue;let c=`${r}:${l.sourceNodeId}`;rp(e,s.value,l,c);for(let u of rl(s.value,l.sourceNodeId))a.add(u.sourceNodeId),u.localName.toLowerCase()==="style"&&sp(t,Ja(u),`${r}:${u.sourceNodeId}`)}for(let l of s.value.index.elements){if(a.has(l.sourceNodeId))continue;let c=l.localName.toLowerCase();if(l.namespaceUri===W&&(c==="image"||c==="feimage")){let u=Ee(l)??{value:"",namespace:"svg2"};ln(e,{sourceNodeId:`${r}:${l.sourceNodeId}`,occurrenceId:`${r}:${l.sourceNodeId}`,sourceId:Bt(l,"id"),elementName:c==="feimage"?"feImage":"image",attributeName:"href",channel:"canonical-state",href:u.value,hrefNamespace:u.namespace})}c==="style"&&gb(t,e,Ja(l),`${r}:${l.sourceNodeId}:style`);for(let u of l.attributes)u.localName.toLowerCase()==="href"||u.localName.toLowerCase()==="src"||ap(e,u.value,`${r}:${l.sourceNodeId}`,u.name)}}function cA(t,e){let n=[],r=[],i=[];for(let[s,a]of(t.documentStyles??[]).entries())gb(n,r,a.css,`snapshot:documentStyles[${s}]`);Nt(t,{onShape:(s,a)=>lA(n,r,s,a,e,i)});for(let[s,a]of(t.library??[]).entries()){let l=`snapshot:library[${s}]`;a.kind==="pattern"?qu(n,r,a.pattern,`${l}:pattern`,e,i):a.kind==="filter"?lp(n,r,a.filters,`${l}:filters`,e,i):(a.kind==="symbol"||a.kind==="marker")&&Uo(r,a.rootAttributes,`${l}:root`)}for(let[s,a]of(t.customPatterns??[]).entries())Li(n,r,a.svgContent,`snapshot:customPatterns[${s}]`,e,i);let o=t.documentMetadata?.rawHtmlMetadata;typeof o=="string"&&hb(n,r,o,"snapshot:documentMetadata.rawHtmlMetadata",e,i);for(let[s,a]of(t.paintServerDefs??[]).entries())Li(n,r,a.markup,`snapshot:paintServerDefs[${s}]`,e,i);for(let[s,a]of(t.rawPaintServerDefs??[]).entries())Li(n,r,a,`snapshot:rawPaintServerDefs[${s}]`,e,i);for(let[s,a]of(t.clipMaskGroups??[]).entries())a.rawDefinition&&Li(n,r,a.rawDefinition,`snapshot:clipMaskGroups[${s}].rawDefinition`,e,i);return mb(Object.freeze(n),Object.freeze(r),Object.freeze(i))}var yb=Object.freeze({matchesMedia(t){let e=t.trim().toLowerCase();return e===""||e==="all"||e==="screen"},supportsCondition(){return!1}}),dA=new Map([["clippath","clip-path"],["marker","marker"],["mask","mask"],["pattern","pattern"]]);function uA(t){return Object.freeze(t.index.elements.flatMap(e=>{let n=dA.get(e.localName.toLowerCase());return n?[Object.freeze({sourceNodeId:e.sourceNodeId,capability:n})]:[]}))}function pA(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 cp(t,e={}){let n={source:e.source??"svg",entrypoint:e.entrypoint??"svg-document-import"},r=Sn(t,n,e.xmlHost);if(!r.value)return Object.freeze({value:null,diagnostics:r.diagnostics});let i=r.value,o=Pd(i.root,n),s=Object.freeze({width:o.value.viewBoxWidth??300,height:o.value.viewBoxHeight??150}),a=e.rootFontSize??16,l=Dd(i,{...e.claimedIds?{claimedIds:e.claimedIds}:{}}),c=Od(i,n),u=ku(i,n),d=Xu(i,n),p=_d(i,{...n,resourceRoots:uA(i),...e.maxUseDepth!==void 0?{maxDepth:e.maxUseDepth}:{},...e.maxUseOccurrences!==void 0?{maxOccurrences:e.maxUseOccurrences}:{}}),f=qd(i,p,{...n,environment:e.styleEnvironment??yb}),g=ou(i,p,f.value,{...n,viewport:s,rootFontSize:a,...e.textMetricsHost?{textMetricsHost:e.textMetricsHost}:{}}),m=Jd(i,p,f.value,{...n,leafGeometry:g.value}),h=Ld(i,p,f.value,n),b=Vd(i,{...n,appliedDeclarations:f.value.appliedResourceDeclarations}),S=gu(i,p,f.value,b,g.value,{...n,viewport:s,rootFontSize:a}),v=wu(i,p,f.value,b,{...n,viewport:s,rootFontSize:a}),I=hu(i,p,f.value,b,{...n,viewport:s,rootFontSize:a}),x=Su(i,p,f.value,b,{...n,viewport:s,rootFontSize:a}),P=bu(i,p,f.value,b,{...n,viewport:s,rootFontSize:a}),T=xu(i,l,n),k=Cd(i,n),w=$d(i,n),$=jd(i),R=ip(i,p,f.value,g.value,n),C=Ad(i,p,{...n,materializedOccurrenceIds:pA(p,g.value,h)}),A=[...r.diagnostics,...o.diagnostics,...c.diagnostics,...u.diagnostics,...d.diagnostics,...p.diagnostics,...f.diagnostics,...m.diagnostics,...h.diagnostics,...g.diagnostics,...b.diagnostics,...S.diagnostics,...v.diagnostics,...I.diagnostics,...x.diagnostics,...P.diagnostics,...T.diagnostics,...k.diagnostics,...w.diagnostics,...R.diagnostics,...C.diagnostics],D=Object.freeze({sourceDocument:i,rootFrame:o.value,identifiers:l,conditionalProcessing:c.value,scripts:u.value,metadata:d.value,useOccurrences:p,styles:f.value,animations:m.value,symbolUses:h,leafGeometry:g.value,resourceDependencies:b,clipMasks:S.value,filters:v.value,markers:I.value,gradients:x.value,patterns:P.value,paintServerDefinitions:T.value,views:k.value,embeddedFrames:w.value,authoredAttributes:$,externalEffects:R.value,hierarchy:C.value});return Object.freeze({value:D,diagnostics:Object.freeze(A)})}function K(){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:Ct,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 fA(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??K(),type:e,state:i}}function Gi(t,e,n,r,i){return{id:i??K(),x:t,y:e,width:n,height:r}}var mA;function gA(){return mA??=new Set([...se.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 St||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(St)){let s=r[o];s===void 0&&!St[o].required||xA[o](s,i)}return{valid:e.length===0,errors:e,warnings:n}}function Ue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Rt(t,e,n){return Array.isArray(t)?!0:(n.push({path:e,message:`${e} must be an array`,severity:"error"}),!1)}var hA=new Set(["x1","y1","x2","y2","gradientTransform"]),yA=new Set(["cx","cy","fx","fy","r","fr","gradientTransform"]),SA=new Set(["x","y","width","height"]);function xn(t,e,n){t.push({path:e,message:n,severity:"error"})}function bA(t,e,n,r){if(!Ue(t)){xn(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]))&&xn(r,`${e}.${o}`,`${o} must be a finite number`);if(t.fr!==void 0&&(typeof t.fr!="number"||!Number.isFinite(t.fr))&&xn(r,`${e}.fr`,"fr must be a finite number"),t.authoredGeometry!==void 0)if(!Ue(t.authoredGeometry))xn(r,`${e}.authoredGeometry`,"Gradient authoredGeometry must be a plain object");else{let o=n==="linear-gradient"?hA:yA;for(let[s,a]of Object.entries(t.authoredGeometry))o.has(s)?typeof a!="string"&&xn(r,`${e}.authoredGeometry.${s}`,"Authored gradient geometry declarations must be strings"):xn(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)))&&xn(r,`${e}.gradientTransform`,"gradientTransform must be a 6-element finite affine matrix"),Array.isArray(t.stops)?t.stops.forEach((o,s)=>{if(!Ue(o)){xn(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]))&&xn(r,`${e}.stops[${s}].${a}`,`${a} must be a finite number`)}):xn(r,`${e}.stops`,"Gradient stops must be an array")}function vA(t,e,n){if(!Ue(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(!Ue(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))SA.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 xA={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>Ct&&n.push({path:"schemaVersion",message:`schemaVersion ${t} is newer than supported (${Ct})`,severity:"warning"})},shapes:(t,{errors:e,warnings:n})=>{if(!Rt(t,"shapes",e))return;let r=new Set;t.forEach((i,o)=>{up(i,`shapes[${o}]`,e,n,r)})},viewboxes:(t,{errors:e})=>{if(!Rt(t,"viewboxes",e))return;let n=new Set;t.forEach((r,i)=>{$A(r,`viewboxes[${i}]`,e,n)})},guides:(t,{errors:e})=>{Rt(t,"guides",e)&&t.forEach((n,r)=>{EA(n,`guides[${r}]`,e)})},measurements:(t,{errors:e})=>{Rt(t,"measurements",e)&&t.forEach((n,r)=>{let i=`measurements[${r}]`;if(!Ue(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(!Rt(t,"sceneTree",n))return;let i=IA(e.shapes),o=new Set;t.forEach((s,a)=>{wA(s,`sceneTree[${a}]`,n,r,i,o)})},groups:(t,{errors:e})=>{Rt(t,"groups",e)&&t.forEach((n,r)=>{AA(n,`groups[${r}]`,e)})},clipMaskGroups:(t,{errors:e,warnings:n})=>{Rt(t,"clipMaskGroups",e)&&t.forEach((r,i)=>{NA(r,`clipMaskGroups[${i}]`,e,n)})},documentMetadata:(t,{errors:e})=>{Ue(t)||e.push({path:"documentMetadata",message:"documentMetadata must be a plain object",severity:"error"})},documentScripts:(t,{errors:e})=>{Rt(t,"documentScripts",e)&&t.forEach((n,r)=>{let i=`documentScripts[${r}]`;if(!Ue(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})=>{Rt(t,"documentStyles",e)&&t.forEach((n,r)=>{let i=`documentStyles[${r}]`;if(!Ue(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})=>{Rt(t,"templateVariables",e)&&t.forEach((n,r)=>{let i=`templateVariables[${r}]`;if(!Ue(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,{errors:e})=>{if(!Ue(t)){e.push({path:"animationTimeline",message:"animationTimeline must be a plain object",severity:"error"});return}t.tracks!==void 0&&!Array.isArray(t.tracks)&&e.push({path:"animationTimeline.tracks",message:"animationTimeline.tracks must be an array",severity:"error"})},library:(t,{doc:e,errors:n,warnings:r})=>{if(!Rt(t,"library",n))return;let i=new Set;t.forEach((o,s)=>{let a=`library[${s}]`;if(!Ue(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 l=typeof e.schemaVersion=="number"&&e.schemaVersion>=8;if(l)for(let c of["wrapperAttrs","groups","overflow"])o[c]!==void 0&&n.push({path:`${a}.${c}`,message:`Symbol ${c} is schema-v7 migration input only`,severity:"error"});for(let c of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])o[c]!==void 0&&typeof o[c]!="string"&&n.push({path:`${a}.${c}`,message:`Symbol ${c} must be a string when present`,severity:"error"});if(o.rootAttributes!==void 0)if(!Ue(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Symbol rootAttributes must be a plain object",severity:"error"});else for(let[c,u]of Object.entries(o.rootAttributes))l&&["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(c)&&n.push({path:`${a}.rootAttributes.${c}`,message:`Symbol ${c} must use its typed root field`,severity:"error"}),typeof u!="string"&&n.push({path:`${a}.rootAttributes.${c}`,message:"Symbol root attribute values must be strings",severity:"error"})}if(o.kind==="marker"){for(let l of["viewBox","preserveAspectRatio"])o[l]!==void 0&&typeof o[l]!="string"&&n.push({path:`${a}.${l}`,message:`Marker ${l} must be a string when present`,severity:"error"});if(o.authoredGeometry!==void 0)if(!Ue(o.authoredGeometry))n.push({path:`${a}.authoredGeometry`,message:"Marker authoredGeometry must be a plain object",severity:"error"});else for(let[l,c]of Object.entries(o.authoredGeometry))typeof c!="string"&&n.push({path:`${a}.authoredGeometry.${l}`,message:"Marker authored geometry declarations must be strings",severity:"error"});if(o.rootAttributes!==void 0)if(!Ue(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Marker rootAttributes must be a plain object",severity:"error"});else for(let[l,c]of Object.entries(o.rootAttributes))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(l)&&n.push({path:`${a}.rootAttributes.${l}`,message:`Marker ${l} must use its typed root field`,severity:"error"}),typeof c!="string"&&n.push({path:`${a}.rootAttributes.${l}`,message:"Marker root attribute values must be strings",severity:"error"})}if(Array.isArray(o.shapes)){let l=new Set;o.shapes.forEach((c,u)=>{up(c,`${a}.shapes[${u}]`,n,r,l)})}if(o.kind==="symbol"&&Ue(o.variants))for(let[l,c]of Object.entries(o.variants)){if(!Array.isArray(c))continue;let u=new Set;c.forEach((d,p)=>{up(d,`${a}.variants[${l}][${p}]`,n,r,u)})}}(o.kind==="linear-gradient"||o.kind==="radial-gradient")&&bA(o.gradient,`${a}.gradient`,o.kind,n),o.kind==="pattern"&&vA(o.pattern,`${a}.pattern`,n)})},rawPaintServerDefs:(t,{errors:e})=>{Rt(t,"rawPaintServerDefs",e)&&t.forEach((n,r)=>{typeof n!="string"&&e.push({path:`rawPaintServerDefs[${r}]`,message:"rawPaintServerDefs entries must be strings",severity:"error"})})},paintServerDefs:(t,{errors:e})=>{if(!Rt(t,"paintServerDefs",e))return;let n=new Set;t.forEach((r,i)=>{RA(r,`paintServerDefs[${i}]`,e,n)})},customPatterns:(t,{errors:e})=>{dp(t,"customPatterns","Custom pattern",e)},symbols:(t,{errors:e})=>{dp(t,"symbols","Symbol def",e)},markers:(t,{errors:e})=>{dp(t,"markers","Marker def",e)},colorGlyphLibrary:(t,{errors:e})=>{if(!Ue(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})=>{Rt(t,"exportItems",e)&&t.forEach((n,r)=>{let i=`exportItems[${r}]`;if(!Ue(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})=>{Ue(t)||e.push({path:"unknownFields",message:"unknownFields must be a plain object (forward-compat quarantine bag)",severity:"error"})}};function dp(t,e,n,r){Rt(t,e,r)&&t.forEach((i,o)=>{let s=`${e}[${o}]`;if(!Ue(i)){r.push({path:s,message:`${n} must be a non-null object`,severity:"error"});return}(typeof i.id!="string"||i.id.length===0)&&r.push({path:`${s}.id`,message:`${n} id must be a non-empty string`,severity:"error"})})}function IA(t){let e=new Set;if(!Array.isArray(t))return e;for(let n of t)tn(n,{onShape:r=>{typeof r.id=="string"&&r.id.length>0&&e.add(r.id)}});return e}function Sb(t){return t.startsWith("structural:")}function wA(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)&&!Sb(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)&&!Sb(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 kA=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function RA(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"&&kA.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 l=i[a];l!==void 0&&(!Array.isArray(l)||l.some(c=>typeof c!="string"||c.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 up(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}tn(t,{onShape:(o,s)=>{TA(o,`${e}${s}`,n,r,i)}})}function TA(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"}):gA().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;CA(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 PA=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function bb(t){return typeof t=="number"?isFinite(t):typeof t=="string"?PA.test(t):!1}function CA(t,e,n,r){if(t.authoredUseGeometry!==void 0)if(!Ue(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&&!bb(t[s])&&n.push({path:`${e}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"});for(let s of hs){let a=t[s];if(a!=null){if(s==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(l=>typeof l=="number"&&Number.isFinite(l)))&&n.push({path:`${e}.${s}`,message:`${s} must be a 6-element finite affine matrix`,severity:"error"});continue}bb(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 $A(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 EA(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 AA(t,e,n){if(t===null||typeof t!="object"){n.push({path:e,message:"Group 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:"Group id must be a non-empty string",severity:"error"}),r.parentId!==null&&typeof r.parentId!="string"&&n.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function NA(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=i.clipShapeId,a=typeof s=="string"&&s.length>0,l=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&&!a?n.push({path:`${e}.clipShapeIds`,message:"ClipMaskGroup must carry clipShapeIds (or the deprecated clipShapeId)",severity:"error"}):Array.isArray(o)&&o.length===0&&!a&&!l&&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 Wo(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 l=n.get(a.id);l&&l!==a?r.add(a.id):l||n.set(a.id,a);let c=a.state.children;if(Array.isArray(c))for(let u=c.length-1;u>=0;u--){let d=c[u];d&&typeof d=="object"&&typeof d.id=="string"&&o.push(d)}}let s=new Map(n);for(let a of r)s.delete(a);return{ordered:e,uniqueById:s,duplicateIds:r}}function Ko(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 MA(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 Xo(t,e){let n=gt(t,e);if(n)return{matrix:rn(t,e),attribute:n,owner:"canonical"};let r=MA(t);return r?{matrix:Dt(r),attribute:r,owner:"group-data"}:{matrix:Oe,attribute:null,owner:"none"}}function $t(t){let e=t.transformMatrix;return Yn(e)&&!Kt(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 il(t,e){let n=e?{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2}:void 0;return Xo(t,n)}var OA=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,DA=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)px$/i,zA=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)%$/;function Yo(t,e,n,r){let i=t.trim();if(OA.test(i))return Number(i);let o=DA.exec(i);if(o)return Number(o[1]);let s=zA.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 _A(t){let e=t.state.authoredUseGeometry;return e&&typeof e=="object"?e:{}}function Gr(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 FA(t,e){if(t===void 0)return;let n=Xe(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 vb(t,e,n,r,i,o){if(e===void 0){if(i.legacyNumericGeometry){let a=Number(t.state[n]??0);return Number.isFinite(a)?a:0}return 0}return Yo(e,{axis:n,percentBasis:n==="x"?r?.width:r?.height},i,o)??0}function xb(t,e,n,r,i,o,s){let a=n==="width"?i?.width:i?.height,l=[r,Gr(e,n)];for(let c of l){if(c===void 0||c.trim().toLowerCase()==="auto")continue;let u=Yo(c,{axis:n,percentBasis:a},o,s);if(u!==null){if(u<0){s.push({code:"invalid-symbol-length",message:`Negative symbol ${n} ${c} is invalid and falls back to auto.`});continue}return u}}if(a!==void 0)return a;if(o.legacyNumericGeometry){let c=Number(t.state[n]);if(Number.isFinite(c)&&c>=0)return c}return s.push({code:"unresolved-symbol-viewport",message:`Symbol ${n} is auto and needs a containing viewport basis.`}),null}function Ib(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 Yo(t,{axis:e,percentBasis:e==="refX"?n?.width:n?.height},r,i)??void 0}function qo(t,e,n,r={}){let i=[],o=_A(t),s=vb(t,o.x,"x",n,r,i),a=vb(t,o.y,"y",n,r,i),l=_e(s,a),c=Gr(e,"transform"),u=c?Dt(c):Oe;if((e.defKind??"symbol")==="group")return{kind:"group",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:de(l,u),childPercentBasis:n??null,viewport:null,diagnostics:i};let d=xb(t,e,"width",o.width,n,r,i),p=xb(t,e,"height",o.height,n,r,i),f=Gr(e,"x"),g=Gr(e,"y"),m=f!==void 0?Yo(f,{axis:"x",percentBasis:n?.width},r,i)??0:0,h=g!==void 0?Yo(g,{axis:"y",percentBasis:n?.height},r,i)??0:0,b=FA(e.viewBox,i),S=Ti({width:d,height:p,...b?{viewBoxX:b.x,viewBoxY:b.y,viewBoxWidth:b.width,viewBoxHeight:b.height}:{},preserveAspectRatio:Gr(e,"preserveAspectRatio")},n);for(let k of S.diagnostics)i.push({code:k.code==="unresolved-viewport-size"?"unresolved-symbol-viewport":"invalid-symbol-viewbox",message:k.message.replace("Nested SVG","Symbol")});if(d===null||p===null||!S.renders||!S.contentMatrix)return{kind:"symbol",renders:!1,useX:s,useY:a,useAttributes:o,contentMatrix:de(l,u),childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i};let v=Ib(Gr(e,"refX"),"refX",S.childPercentBasis,r,i),I=Ib(Gr(e,"refY"),"refY",S.childPercentBasis,r,i),x=Be(S.contentMatrix,{x:v??0,y:I??0}),P=_e(m-(v===void 0?0:x.x),h-(I===void 0?0:x.y)),T=de(de(de(l,u),P),S.contentMatrix);return{kind:"symbol",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:T,childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i}}function yp(){return{bounds:null,status:"empty",diagnostics:[]}}function ji(t,e,n){return n.resolveOwnTransform?.(t,e)??e}function dn(t,e){return{bounds:null,status:t,diagnostics:[e]}}function sl(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 mp(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 Sp(t,e){return mp([Be(e,{x:t.minX,y:t.minY}),Be(e,{x:t.maxX,y:t.minY}),Be(e,{x:t.maxX,y:t.maxY}),Be(e,{x:t.minX,y:t.maxY})])}function wb(t,e,n,r,i){return n<0||r<0?null:Sp({minX:t,minY:e,maxX:t+n,maxY:e+r},i)}function kb(t,e,n,r,i){if(n<0||r<0)return null;let o=Be(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 LA(t,e){let n=Array.isArray(t)?t:[t],r=null;for(let i of n)r=sl(r,Sp(i,e));return r}function pp(t,e,n){return dn("unsupported",{code:e,shapeId:t.id,message:`Object bounds for ${n} require a document resolver policy.`,path:[t.id]})}function gp(t,e,n={}){let r=Zt(t);if(!r)return dn("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=kb(r.cx,r.cy,r.r,r.r,e);break;case"ellipse":i=kb(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=sn(r.pathData,e);else if(r.rx>0&&r.ry>0){let o=Zd(r.x,r.y,r.width,r.height,r.rx,r.ry);i=o?sn(o,e):null}else i=wb(r.x,r.y,r.width,r.height,e);break;case"line":if(r.boundsPolicy==="linked-line")return pp(t,"deferred-tree-kind","linked line");i=mp([Be(e,{x:r.x1,y:r.y1}),Be(e,{x:r.x2,y:r.y2})]);break;case"text":{let o=n.measureText?.(t,r)??null;if(!o)return pp(t,"deferred-tree-kind","text");i=LA(o,e);break}case"path":{let o=r.placement?de(e,_e(r.placement.x,r.placement.y)):e;i=sn(r.d,o);break}case"polyline":{let o=r.points.length>0?r.points:[{x:0,y:0}];i=mp(o.map(s=>Be(e,s)));break}case"positioning-rect":i=wb(r.x,r.y,r.width,r.height,e);break;case"view":return yp();case"container":case"embedded-svg":case"shape-reference":case"symbol-instance":return pp(t,"deferred-tree-kind",r.kind)}return i?{bounds:i,status:"resolved",diagnostics:[]}:{bounds:null,status:"empty",diagnostics:[]}}function hp(t){let e=t.state.children;return Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}function Vr(t){let e=Wo(t.shapes),n=Ko(t.library),r=t.sceneTree??[];if(r.length===0)return{roots:()=>t.shapes,shape:c=>e.uniqueById.get(c),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:c=>n.definition(c),duplicateLibraryIds:()=>n.duplicateIds,schemaVersion:()=>t.schemaVersion,children:hp};let i=new Map,o=new Set;for(let c of r){let u=i.get(c.parentId)??[];i.set(c.parentId,[...u,c]),e.uniqueById.has(c.id)&&o.add(c.id)}let s=c=>{let u=[],d=new Set,p=f=>{for(let g of it([...i.get(f)??[]])){let m=e.uniqueById.get(g.id);if(m){u.push(m);continue}d.has(g.id)||(d.add(g.id),p(g.id),d.delete(g.id))}};return p(c),u};return{roots:()=>[...s(null),...t.shapes.filter(c=>!o.has(c.id))],shape:c=>e.uniqueById.get(c),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:c=>n.definition(c),duplicateLibraryIds:()=>n.duplicateIds,schemaVersion:()=>t.schemaVersion,children:c=>[...s(c.id),...hp(c).filter(u=>!o.has(u.id))]}}function Rb(t,e){return`${e.identityPrefixes.at(-1)??"document"}\0${t.id}`}var BA=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"]),fp=new Set(["block","inline","run-in"]),GA=new Set(["flow","flow-root","table","flex","grid","ruby"]);function VA(t){let e=t.trim().toLowerCase();if(BA.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=>fp.has(i)).length<=1&&r.filter(i=>i==="flow"||i==="flow-root").length<=1&&r.every(i=>fp.has(i)||i==="flow"||i==="flow-root")}return n.length===2&&n.some(r=>fp.has(r))&&n.some(r=>GA.has(r))}function jA(t){if(!t)return null;let e=null;for(let n of yi(t,";")){let r=yi(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();VA(s)&&(!e||o||!e.important)&&(e={value:s,important:o})}return e}function Tb(t,e){let n=jA(typeof e=="string"?e:void 0);return n?n.value!=="none":typeof t!="string"||t.trim().toLowerCase()!=="none"}function Jo(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 Tb(r,n?.style)?e.participatesInRendering?.(t)??!0:!1}function UA(t,e,n){let r=t.rootAttributes;return Tb(r?.display,r?.style)?n.participatesSymbolDefinition?.(t,e)??!0:!1}function HA(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 jr(t,e,n={}){let r=Zt(t);if(!r||r.kind!=="embedded-svg")return{matrix:Oe,attribute:null,pivotRequired:!1,pivotResolved:!1,viewport:Ti({})};let i=Ti(HA(r,n),e),o=$t(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:rn(t.state,s),attribute:gt(t.state,s),pivotRequired:o,pivotResolved:!o||s!==void 0,viewport:i}}function Pb(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 ol(t,e,n,r){let i=null,o=[],s=n.forceInlineChildren>0?hp(t):n.view.children(t);for(let a of s){if(!Jo(a,n.host))continue;let l=Qo(a,e,n,r);i=sl(i,l.bounds),o.push(...l.diagnostics)}return cn(i,o)}function Cb(t,e){return{...t,diagnostics:t.diagnostics.map(n=>n.path.includes(e)?n:{...n,path:[e,...n.path]})}}function WA(t,e,n,r,i={}){let o=jr(t,r,i),s=Pb(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 legacy 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=Rb(t,n);n.active.add(a),n.path.push(t.id);let c=t.state.isRootSvg===!0?e:de(de(e,ji(t,o.matrix,n.host)),o.viewport.contentMatrix??Oe),u=ol(t,c,n,o.viewport.childPercentBasis??r);return n.path.pop(),n.active.delete(a),cn(u.bounds,[...s,...u.diagnostics],u.status)}function KA(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let u=typeof e=="string"?e:e.id;return dn("unresolved",{code:"unresolved-shape",shapeId:u,message:`Shape ${u} is not present in the document bounds view.`,path:[u]})}let o=Zt(i);if(!o||o.kind!=="embedded-svg")return dn("unsupported",{code:"unsupported-shape",shapeId:i.id,message:`Shape ${i.id} is not an embedded SVG viewport.`,path:[i.id]});let s=jr(i,n.parentViewport),a=Pb(i,s.viewport,[]);if(!s.viewport.frame||s.pivotRequired&&!s.pivotResolved)return cn(null,a,"unresolved");let l=de(n.toTarget??Oe,ji(i,s.matrix,r)),c=s.viewport.frame;return{bounds:Sp({minX:c.x,minY:c.y,maxX:c.x+c.width,maxY:c.y+c.height},l),status:"resolved",diagnostics:a}}function $b(t,e,n){let r=n.view.duplicateShapeIds?.().has(e)??!1;return dn("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 XA(t,e){let n=[...e.path,t.id];return dn("cycle",{code:"reference-cycle",shapeId:t.id,message:`Shape reference cycle detected: ${n.join(" -> ")}.`,path:n})}function Eb(t,e,n,r,i){if(!$t(t.state))return{matrix:rn(t.state),attribute:gt(t.state),pivotRequired:!1,pivotResolved:!0,diagnostics:[],contentBounds:null};let s=_e(e.offsetX,e.offsetY),a={width:e.width,height:e.height},l=Cb(Qo(n,s,r,i,a),t.id),c=l.diagnostics.some(d=>d.code==="unsupported-shape"||d.code==="deferred-tree-kind"||d.code==="unresolved-reference-pivot"),u=l.bounds&&!c?{x:(l.bounds.minX+l.bounds.maxX)/2,y:(l.bounds.minY+l.bounds.maxY)/2}:null;if(!u){let d=l.bounds===null&&(l.status==="empty"||l.status==="cycle"||l.status==="unresolved"),p={code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has legacy rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`,path:[...r.path]};return{matrix:rn(t.state),attribute:gt(t.state),pivotRequired:!0,pivotResolved:d,diagnostics:d?l.diagnostics:[...l.diagnostics,p],contentBounds:l}}return{matrix:rn(t.state,u),attribute:gt(t.state,u),pivotRequired:!0,pivotResolved:!0,diagnostics:[],contentBounds:l}}function YA(t,e,n,r,i){if(r.activeReferences.has(t.id))return XA(t,r);r.activeReferences.add(t.id),r.path.push(t.id);let o=d=>(r.path.pop(),r.activeReferences.delete(t.id),d),s=e.targetShapeId?.trim()??"",a=s?r.view.shape(s):void 0;if(!a)return o($b(t,s,r));if(!Jo(a,r.host))return o(yp());let l=Eb(t,e,a,r,i);if(l.pivotRequired&&!l.pivotResolved)return o(cn(null,[...l.diagnostics],"unresolved"));if(l.contentBounds?.bounds===null&&l.pivotResolved)return o(l.contentBounds);let c=de(de(n,ji(t,l.matrix,r.host)),_e(e.offsetX,e.offsetY)),u=Cb(Qo(a,c,r,i,{width:e.width,height:e.height}),t.id);return o({...u,diagnostics:[...l.diagnostics,...u.diagnostics]})}function Vi(t,e){let n=t.state.instancePresentation?.transform,r=typeof n=="string"&&n.trim()?n.trim():null,i=rn(t.state,e),o=gt(t.state,e);return r?{matrix:de(Dt(r),i),attribute:o?`${r} ${o}`:r}:{matrix:i,attribute:o}}function Zo(t,e,n,r){return{code:n,shapeId:t.id,message:r,path:[...e.path,t.id]}}function Ab(t,e,n,r,i,o=!1){let s=Ii(e,t),a=qo(t,e,i,{resolveLength:r.host.resolveSymbolLength,legacyNumericGeometry:(r.view.schemaVersion?.()??8)<8}),l=[...s.diagnostics.map(m=>Zo(t,r,m.code,m.message)),...a.diagnostics.map(m=>Zo(t,r,m.code==="invalid-symbol-length"||m.code==="invalid-symbol-viewbox"?"invalid-symbol-viewport":"unresolved-symbol-viewport",m.message))];if(!a.renders){let m=a.viewport?.status==="zero-disabled";return{...cn(null,l,m?"empty":"unresolved"),transform:{...Vi(t),pivotRequired:$t(t.state),pivotResolved:!0,diagnostics:l}}}if(!UA(e,t,r.host))return{...yp(),transform:{...Vi(t),pivotRequired:$t(t.state),pivotResolved:!0,diagnostics:l}};if(r.activeSymbols.has(s.materializationKey)){let m=Zo(t,r,"symbol-cycle",`Symbol instance cycle detected through ${e.id}.`);return{...dn("cycle",m),transform:{...Vi(t),pivotRequired:$t(t.state),pivotResolved:!0,diagnostics:[m]}}}r.activeSymbols.add(s.materializationKey),r.identityPrefixes.push(s.materializationKey),r.forceInlineChildren++,r.path.push(t.id);let c=m=>{let h=null,b=[];for(let S of s.shapes){if(!Jo(S,r.host))continue;let v=Qo(S,m,r,a.childPercentBasis??i);h=sl(h,v.bounds),b.push(...v.diagnostics)}return cn(h,b)},u=$t(t.state),d=Vi(t),p=!u,f=[];if(u){let m=c(a.contentMatrix),h=m.diagnostics.some(S=>S.code==="unsupported-shape"||S.code==="deferred-tree-kind"||S.code==="unresolved-symbol-viewport"),b=m.bounds&&!h?{x:(m.bounds.minX+m.bounds.maxX)/2,y:(m.bounds.minY+m.bounds.maxY)/2}:void 0;if(b)d=Vi(t,b),p=!0;else{let S=m.bounds===null&&(m.status==="empty"||m.status==="cycle"||m.status==="unresolved");p=S,S||(f=[Zo(t,r,"unresolved-symbol-pivot",`Symbol instance ${t.id} needs unavailable contextual geometry or measurement for its legacy transform pivot.`)]),S&&!o&&(f=[...m.diagnostics])}}let g;if(u&&!p)g=cn(null,[...l,...f],"unresolved");else{let m=de(de(n,ji(t,d.matrix,r.host)),a.contentMatrix),h=c(m);g=cn(h.bounds,[...l,...f,...h.diagnostics],h.status)}return r.path.pop(),r.forceInlineChildren--,r.identityPrefixes.pop(),r.activeSymbols.delete(s.materializationKey),{...g,transform:{...d,pivotRequired:u,pivotResolved:p,diagnostics:[...l,...f]}}}function qA(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 dn("unresolved",Zo(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=Ab(t,s,e,n,r),{transform:l,...c}=a;return c}function Qo(t,e,n,r,i={}){let o=Rb(t,n);if(n.active.has(o)){if(!n.collectDiagnostics)return{bounds:null,status:"cycle",diagnostics:[]};let c=[...n.path,t.id];return dn("cycle",{code:"container-cycle",shapeId:t.id,message:`Container cycle detected: ${c.join(" -> ")}.`,path:c})}let s=Zt(t);if(!s)return gp(t,e,n.host);if(s.kind==="shape-reference")return YA(t,s,e,n,r);if(s.kind==="embedded-svg")return WA(t,e,n,r,i);if(s.kind==="symbol-instance")return qA(t,e,n,r);if(s.kind!=="container"){let c=rn(t.state,s.defaultPivot??void 0);return gp(t,de(e,ji(t,c,n.host)),n.host)}n.active.add(o),n.path.push(t.id);let a=Xo(t.state).matrix;if($t(t.state)){let c=n.collectDiagnostics;n.collectDiagnostics=!1;let u=ol(t,Oe,n,r);n.collectDiagnostics=c;let d=u.diagnostics.some(p=>p.code==="unsupported-shape"||p.code==="deferred-tree-kind");a=il(t.state,d?null:u.bounds).matrix}let l=ol(t,de(e,ji(t,a,n.host)),n,r);return n.path.pop(),n.active.delete(o),l}function es(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let o=typeof e=="string"?e:e.id;return dn("unresolved",{code:"unresolved-shape",shapeId:o,message:`Shape ${o} is not present in the document bounds view.`,path:[o]})}return Qo(i,n.toTarget??Oe,{view:t,host:r,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},n.parentViewport)}function bp(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let s=typeof e=="string"?e:e.id;return dn("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?Oe:r.resolveOwnTransform?.(s,a)??a};return es(t,i,{parentViewport:n.parentViewport},o)}function vp(t,e,n={},r){let i=Zt(e);if(!i||i.kind!=="shape-reference")return{matrix:Oe,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||!Jo(a,n)){let c=$t(e.state);return{matrix:rn(e.state),attribute:gt(e.state),pivotRequired:c,pivotResolved:!0,diagnostics:a?[]:$b(e,s,o).diagnostics}}let l=Eb(e,i,a,o,r);return{matrix:l.matrix,attribute:l.attribute,pivotRequired:l.pivotRequired,pivotResolved:l.pivotResolved,diagnostics:l.diagnostics}}function xp(t,e,n={},r){let i=$t(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"?{...Vi(e),pivotRequired:i,pivotResolved:!0,diagnostics:[]}:Ab(e,a,Oe,{view:t,host:n,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},r,!0).transform}function ZA(t,e={},n={}){let r=null,i=[];for(let o of t.roots()){if(!Jo(o,n))continue;let s=es(t,o,e,n);r=sl(r,s.bounds),i.push(...s.diagnostics)}return cn(r,i)}function Ip(t,e={}){if(!$t(t.state))return{transform:Xo(t.state),contentBounds:null,pivotRequired:!1,pivotResolved:!0};let i={view:Vr({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=ol(t,Oe,i),a=o.diagnostics.some(l=>l.code==="unsupported-shape"||l.code==="deferred-tree-kind")?null:o.bounds;return{transform:il(t.state,a),contentBounds:o,pivotRequired:!0,pivotResolved:a!==null||o.status==="empty"}}var JA=new Set(["class","height","href","id","preserveaspectratio","style","transform","viewbox","width","x","xlink:href","y"]),QA=new Set(["color","color-interpolation","display","fill","fill-opacity","fill-rule","filter","marker","marker-end","marker-mid","marker-start","mask","opacity","paint-order","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","vector-effect","visibility"]);function al(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 wp(t){if(t===null)return;let e=t.trim(),n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/u.exec(e),r=n?Number(n[1])/100:al(e);return r===void 0?void 0:Math.min(1,Math.max(0,r))}function eN(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 ll(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 tN(t,e,n){let r=t.metadata.candidate(e.correspondingSourceNodeId)?.metadata;if(!r||Object.keys(r).length===0)return;let i=structuredClone(r);if(typeof i.name=="string"&&e.usePath.length>0){let o=(n.get(i.name)??0)+1;n.set(i.name,o),i.name=`${i.name}-use-${o}`}return i}function nN(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 rN(t,e){let n={};for(let r of t.authoredAttributes.forElement(e)){let i=r.name.toLowerCase();r.classification==="namespace"||JA.has(i)||r.classification==="geometry"||r.classification==="metadata"||r.classification==="element-specific"||(n[r.name]=ll(t,r.value))}return n}function iN(t,e){let n=l=>t.styles.value(e,l),r={},i=n("fill"),o=n("stroke");i!==null&&(r.fillColor=ll(t,i),i.trim().toLowerCase()==="none"&&(r.fillType="none")),o!==null&&(r.borderColor=ll(t,o),o.trim().toLowerCase()==="none"&&(r.strokeType="none"));let s=[["fillOpacity","fill-opacity",wp],["strokeOpacity","stroke-opacity",wp],["opacity","opacity",wp],["borderWidth","stroke-width",al],["strokeMiterlimit","stroke-miterlimit",al],["dashOffset","stroke-dashoffset",al],["fillRule","fill-rule",l=>l??void 0],["strokeLinecap","stroke-linecap",l=>l??void 0],["strokeLinejoin","stroke-linejoin",l=>l??void 0],["strokeDasharray","stroke-dasharray",l=>l??void 0],["paintOrder","paint-order",l=>l??void 0],["vectorEffect","vector-effect",l=>l??void 0],["blendMode","mix-blend-mode",l=>l??void 0]];for(let[l,c,u]of s){let d=u(n(c));d!==void 0&&(r[l]=d)}n("display")?.trim().toLowerCase()==="none"&&(r.display="none");let a=n("visibility")?.trim();return(a==="hidden"||a==="collapse")&&(r.visibility=a),r}function oN(t,e){let n={},r=t.styles.style(e);if(!r)return n;for(let[i,o]of Object.entries(r.cascadedValues))QA.has(i)&&(n[i]=ll(t,o.value));return n}function sN(t,e){let n=t.symbolUses.use(e.occurrenceId);if(e.role==="use-carrier"&&n){let s=n.transform.matrix??[1,0,0,1,0,0],a=de(s,_e(n.geometry.x,n.geometry.y));return Kt(a)?void 0:at(a)}let r=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!r)return;let i=t.styles.style(e.occurrenceId)?.cascadedValues.transform?.value??E(r,"transform");if(!i||i.trim().toLowerCase()==="none")return;let o=Xt(i);return o&&!Kt(o)?at(o):void 0}function Nb(t,e,n){let r=iN(t,e.occurrenceId),i=tN(t,e,n),o=nN(t,e.correspondingSourceNodeId),s=rN(t,e.correspondingSourceNodeId),a=t.conditionalProcessing.condition(e.correspondingSourceNodeId),l=sN(t,e);return i&&(r.metadata=i),o&&(r.scripts=o),Object.keys(s).length>0&&(r.authoredAttributes=s),a&&a.systemLanguage!==null&&(r.systemLanguage=a.systemLanguage),a&&a.requiredExtensions!==null&&(r.requiredExtensions=a.requiredExtensions),l&&(r.transformMatrix=l),r}function aN(t,e,n,r){let i=Nb(t,e,r),o=oN(t,e.occurrenceId);Object.keys(o).length>0&&(i.containerPresentation=o);let s=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!s)return i;if(n==="hyperlink"){let a=E(s,"href"),l=s.attributes.find(c=>c.name==="xlink:href")?.value;a!==null?i.href=a:l!==void 0&&(i.hrefXlink=l);for(let[c,u]of[["target","linkTarget"],["download","linkDownload"],["ping","linkPing"],["rel","linkRel"],["hreflang","linkHreflang"],["type","linkType"],["referrerpolicy","linkReferrerPolicy"]]){let d=E(s,c);d!==null&&(i[u]=d)}}else if(n==="switch"){let a=t.conditionalProcessing.condition(s.sourceNodeId);a&&(i.switchSystemLanguage=a.systemLanguage,i.switchRequiredExtensions=a.requiredExtensions)}else if(n==="embedded-svg"){let a=t.embeddedFrames.find(l=>l.sourceNodeId===s.sourceNodeId);a&&Object.assign(i,a.state)}return i}function lN(t){return t==="embedded-svg"?"svg":t}function cN(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 dN(t){return{severity:"error",code:"application-rolled-back",source:"svg",entrypoint:"svg-document-import",capability:"geometry",message:t}}function Mb(t){let e=new Map(t.useOccurrences.occurrences.map(w=>[w.occurrenceId,w])),n=new Map(t.hierarchy.containers.map(w=>[w.occurrenceId,w])),r=new Map(t.leafGeometry.candidates.filter(w=>w.status==="materialized").map(w=>[w.occurrenceId,w])),i=[...new Set([...t.hierarchy.containers.map(w=>w.occurrenceId),...t.hierarchy.placements.map(w=>w.occurrenceId)])].map(w=>e.get(w)).filter(w=>w!==void 0).sort((w,$)=>eN(w.orderKey,$.orderKey)||w.productIndex-$.productIndex||w.occurrenceId.localeCompare($.occurrenceId)),o=new Map;i.forEach((w,$)=>{o.set(w.occurrenceId,`svg-node-${$+1}`)});let s=new Map,a=[];for(let w of i){let $=o.get(w.occurrenceId),R=n.get(w.occurrenceId);if(R){a.push({id:$,type:lN(R.kind),state:aN(t,w,R.kind,s)});continue}let C=r.get(w.occurrenceId);C?.canonicalType&&a.push({id:$,type:C.canonicalType,state:{...structuredClone(C.state),...Nb(t,w,s)}})}for(let[w,$]of t.views.entries())a.push({id:`svg-view-${w+1}`,type:"view",state:{...$.state}});let l=new Map,c=[];for(let w of i){let $=o.get(w.occurrenceId);if(!$||!a.some(O=>O.id===$))continue;let R=n.get(w.occurrenceId),C=t.hierarchy.placements.find(O=>O.occurrenceId===w.occurrenceId),A=R?.parentContainerOccurrenceId??C?.parentContainerOccurrenceId??null,D=A?o.get(A)??null:null,_=l.get(D)??0;l.set(D,_+1),c.push({id:$,parentId:D,index:_})}for(let w of a.filter($=>$.type==="view")){let $=l.get(null)??0;l.set(null,$+1),c.push({id:w.id,parentId:null,index:$})}let u=t.rootFrame,d=u.viewBoxWidth??u.width??300,p=u.viewBoxHeight??u.height??150,f=Ho({shapes:a,viewboxes:[Gi(u.viewBoxX??0,u.viewBoxY??0,Math.max(d,1),Math.max(p,1),"svg-viewbox-1")],metadata:t.metadata.document.metadata});f.sceneTree=c;let g=Vr(f),m=new Map,h=new Map;for(let w of i){let $=o.get(w.occurrenceId),R=$?a.find(C=>C.id===$):void 0;R&&(m.set(w.occurrenceId,R),h.has(w.correspondingSourceNodeId)||h.set(w.correspondingSourceNodeId,R.id))}let b=w=>{let $=[];for(let[R,C]of m){let A=e.get(R)?.parentOccurrenceId??null;for(;A;){if(A===w){$.push(C);break}A=e.get(A)?.parentOccurrenceId??null}}return $},S=w=>{let $=e.get(w)?.parentOccurrenceId??null;for(;$;){let R=m.get($);if(R?.type==="svg"){let C=R.state,A=C.svgViewBoxWidth,D=C.svgViewBoxHeight;if(typeof A=="number"&&typeof D=="number"&&A>0&&D>0)return{x:typeof C.svgViewBoxX=="number"?C.svgViewBoxX:0,y:typeof C.svgViewBoxY=="number"?C.svgViewBoxY:0,width:A,height:D};if(typeof C.svgWidth=="number"&&typeof C.svgHeight=="number"&&C.svgWidth>=0&&C.svgHeight>=0)return{x:0,y:0,width:C.svgWidth,height:C.svgHeight}}$=e.get($)?.parentOccurrenceId??null}return{x:u.viewBoxX??0,y:u.viewBoxY??0,width:u.viewBoxWidth??u.width??300,height:u.viewBoxHeight??u.height??150}},v=w=>({shapeId:w.id,shapeType:w.type,state:w.state}),I=hd(t,{shapeIdForOccurrence:w=>m.get(w)?.id??null,shapeStateForOccurrence:w=>m.get(w)?.state??null,shapeIdForSourceNode:w=>h.get(w)??null,shapeBindingsForOccurrence:w=>{let $=m.get(w);return $?[v($)]:[]},descendantShapeBindingsForOccurrence:w=>b(w).map(v),cssTransformContextForOccurrence:(w,$)=>{let R=m.get(w),C=($==="fill-box"||$==="content-box")&&R?bp(g,R).bounds:null,A=S(w);return{viewportWidth:A.width,viewportHeight:A.height,...$==="view-box"?{boxX:A.x,boxY:A.y,boxWidth:A.width,boxHeight:A.height}:{},...C?{boxX:C.minX,boxY:C.minY,boxWidth:C.maxX-C.minX,boxHeight:C.maxY-C.minY}:{}}}});I&&(f.animationTimeline=I);let x=cN(t);x&&(f.documentStyles=x);let P=t.scripts.documentScripts.map(w=>({...w.script,customAttrs:w.script.customAttrs?{...w.script.customAttrs}:void 0}));P.length>0&&(f.documentScripts=P);let T=t.paintServerDefinitions.definitions();T.length>0&&(f.paintServerDefs=T.map(w=>structuredClone(w)));let k=Br(f);return k.errors.length>0?{value:null,diagnostics:k.errors.map(w=>dN(`${w.path}: ${w.message}`))}:{value:f,diagnostics:[]}}var cl=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 Ob(t,e={}){let n=cp(t,e);if(!n.value)return{value:null,diagnostics:n.diagnostics};let r=Mb(n.value);return{value:r.value,diagnostics:Object.freeze([...n.diagnostics,...r.diagnostics])}}function kp(t,e={}){let n=Ob(t,e);if(!n.value||n.diagnostics.some(r=>r.severity==="error"))throw new cl(n.diagnostics);return n.value}var M=(t,e)=>({action:t,by:e}),Ye=t=>({action:"exempt",reason:t}),Ve=t=>t,Ce="DocumentSerializer canonical snapshot restore",be="policy-driven SVG plan materializer",bt="policy-driven clipboard plan materializer",ge="policy-driven fragment plan materializer",je="SceneGraph hierarchy and source-order projection",dl={schemaVersion:Ve({"native-document-open":M("derived","parseDocument migration and schema stamping"),"full-snapshot-restore":M("derived","snapshot migration and schema stamping"),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),shapes:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("append","fragment-scoped pattern materializer"),"vectorized-svg-fragment":M("append","path-only vectorized materializer")}),viewboxes:Ve({"native-document-open":M("derived",je),"full-snapshot-restore":M("derived",je),"svg-document-import":M("derived",je),"external-svg-paste":M("derived",je),"internal-clipboard-paste":M("derived",je),"plugin-svg-fragment":M("derived",je),"pattern-fragment":M("derived",je),"vectorized-svg-fragment":M("derived",je)}),guides:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),measurements:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),sceneTree:Ve({"native-document-open":M("derived",je),"full-snapshot-restore":M("derived",je),"svg-document-import":M("derived",je),"external-svg-paste":M("derived",je),"internal-clipboard-paste":M("derived",je),"plugin-svg-fragment":M("derived",je),"pattern-fragment":M("derived",je),"vectorized-svg-fragment":M("derived",je)}),groups:Ve({"native-document-open":Ye("Legacy group sidecar is migrated into SceneGraph structure before restoration."),"full-snapshot-restore":Ye("Legacy group sidecar is migrated into SceneGraph structure before restoration."),"svg-document-import":M("derived",je),"external-svg-paste":M("derived",je),"internal-clipboard-paste":M("derived",je),"plugin-svg-fragment":M("derived",je),"pattern-fragment":M("derived",je),"vectorized-svg-fragment":M("derived",je)}),clipMaskGroups:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":M("preserve-host","path-only vectorized materializer")}),documentMetadata:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("replace",be),"external-svg-paste":M("merge",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),documentScripts:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("replace",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),documentStyles:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("replace",be),"external-svg-paste":M("merge",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),templateVariables:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("replace",be),"external-svg-paste":M("merge",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),animationTimeline:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),library:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":M("preserve-host","path-only vectorized materializer")}),rawPaintServerDefs:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":M("preserve-host","path-only vectorized materializer")}),paintServerDefs:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("append",be),"external-svg-paste":M("append",be),"internal-clipboard-paste":M("append",bt),"plugin-svg-fragment":M("append",ge),"pattern-fragment":M("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":M("preserve-host","path-only vectorized materializer")}),customPatterns:Ve({"native-document-open":M("derived","v1 to v2 pattern library migration"),"full-snapshot-restore":M("derived","v1 to v2 pattern library migration"),"svg-document-import":Ye("Deprecated compatibility field is never authored by SVG ingestion."),"external-svg-paste":Ye("Deprecated compatibility field is never authored by SVG ingestion."),"internal-clipboard-paste":Ye("Deprecated compatibility field is never authored by clipboard ingestion."),"plugin-svg-fragment":Ye("Deprecated compatibility field is never authored by plugin ingestion."),"pattern-fragment":Ye("Deprecated compatibility field is never authored by pattern fragments."),"vectorized-svg-fragment":Ye("Deprecated compatibility field is never authored by vectorized ingestion.")}),symbols:Ve({"native-document-open":M("derived","v1 symbol library compatibility migration"),"full-snapshot-restore":M("derived","v1 symbol library compatibility migration"),"svg-document-import":Ye("Deprecated compatibility field is represented through the unified library."),"external-svg-paste":Ye("Deprecated compatibility field is represented through the unified library."),"internal-clipboard-paste":Ye("Deprecated compatibility field is represented through the unified library."),"plugin-svg-fragment":Ye("Deprecated compatibility field is represented through the unified library."),"pattern-fragment":Ye("Deprecated compatibility field is represented through the unified library."),"vectorized-svg-fragment":Ye("Deprecated compatibility field is represented through the unified library.")}),markers:Ve({"native-document-open":M("derived","v1 marker library compatibility migration"),"full-snapshot-restore":M("derived","v1 marker library compatibility migration"),"svg-document-import":Ye("Deprecated compatibility field is represented through the unified library."),"external-svg-paste":Ye("Deprecated compatibility field is represented through the unified library."),"internal-clipboard-paste":Ye("Deprecated compatibility field is represented through the unified library."),"plugin-svg-fragment":Ye("Deprecated compatibility field is represented through the unified library."),"pattern-fragment":Ye("Deprecated compatibility field is represented through the unified library."),"vectorized-svg-fragment":Ye("Deprecated compatibility field is represented through the unified library.")}),colorGlyphLibrary:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),exportItems:Ve({"native-document-open":M("replace",Ce),"full-snapshot-restore":M("replace",Ce),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)}),unknownFields:Ve({"native-document-open":M("replace","forward-compatible quarantine restore"),"full-snapshot-restore":M("replace","forward-compatible quarantine restore"),"svg-document-import":M("preserve-host",be),"external-svg-paste":M("preserve-host",be),"internal-clipboard-paste":M("preserve-host",bt),"plugin-svg-fragment":M("preserve-host",ge),"pattern-fragment":M("preserve-host",ge),"vectorized-svg-fragment":M("preserve-host",ge)})};function ga(t,e){return dl[t][e]}function Db(t=$o,e=dl){let n=Object.keys(St);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(St,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 uN=["renderToSvg","codegen","dxf","mermaid","pdf","editor-dom"],St={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"}}},groups:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{exempt:"Retired legacy hierarchy sidecar. The serializer emits it EMPTY (see document-serializer.ts serializeSnapshot); parentage rides sceneTree plus the inline state.children projection. `groups:set` still exists inbound for pre-retirement writers."},rendered:{renderToSvg:{exempt:"Retired legacy hierarchy sidecar emitted empty by the serializer; renderToSvg consumes inline children instead."},codegen:{exempt:"Retired legacy hierarchy sidecar emitted empty by the serializer; component backends consume inline children instead."},dxf:{exempt:"Retired legacy hierarchy sidecar emitted empty by the serializer; DXF walks inline child containers instead."},mermaid:{exempt:"Retired legacy hierarchy sidecar emitted empty by the serializer; Mermaid uses the shape and connector records instead."},pdf:{exempt:"Retired legacy hierarchy sidecar is empty; PDF consumes the rendered SVG hierarchy produced from inline child containers."},"editor-dom":{exempt:"Retired legacy hierarchy sidecar is not live editor state; the SceneGraph owns and projects current structure."}}},clipMaskGroups:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["clipmasks:set","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"}}},rawPaintServerDefs:{serialization:{kind:"verbatim"},precision:"opaque",required:!1,collab:{ops:["rawPaintServerDefs:set"]},rendered:{renderToSvg:{by:"renderer/paint-server-defs.ts lifts legacy fragments through typed-channel rules into defs"},codegen:{by:"buildRenderPlan paint-server channels carry reachable legacy fragments to every component backend"},dxf:{exempt:"Raw SVG paint-server markup has no DXF entity representation; the exporter operates on shape geometry rather than defs markup."},mermaid:{exempt:"Raw SVG paint-server markup has no Mermaid syntax representation; export operates on graph topology and labels."},pdf:{by:"The rendered SVG page carries reachable legacy paint-server fragments into the svg2pdf conversion boundary"},"editor-dom":{by:"ImportExportManager and paint-server definition ownership preserve and mount reachable raw fragments in 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"}}},customPatterns:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,deprecated:"Superseded by `library` pattern defs (v1 \u2192 v2 migration).",collab:{exempt:"Deprecated v1 field superseded by `library` pattern defs. Read-only inbound (see the v1->v2 migration that lifts it); the serializer never writes it, because emitting a tile through two channels with two owners is what let the Patterns panel and the fill dropdown disagree."},rendered:{renderToSvg:{exempt:"Deprecated v1 field lifted into library by migrateV1toV2 before renderToSvg runs; it is never a direct render source."},codegen:{exempt:"Deprecated v1 field lifted into library during codegen input migration; component backends never read it directly."},dxf:{exempt:"Deprecated v1 paint field is migrated into library before the editor builds live shapes; DXF never reads it directly."},mermaid:{exempt:"Deprecated v1 paint field is migrated into library before the editor builds live shapes; Mermaid never reads it directly."},pdf:{exempt:"Deprecated v1 paint data is migrated into library before the rendered SVG page reaches PDF conversion."},"editor-dom":{exempt:"Deprecated v1 paint field is migrated into LibraryRegistry before live DOM projection and has no separate editor owner."}}},symbols:{serialization:{kind:"id-sorted-array"},precision:"shape-trees",required:!1,deprecated:"Superseded by `library` symbol defs (v1 \u2192 v2 migration).",collab:{exempt:"Deprecated v1 field superseded by `library`. Read-only inbound; the serializer never writes it."},rendered:{renderToSvg:{by:"librarySymbols provides the v1 compatibility fallback when library has no symbol defs"},codegen:{by:"buildRenderPlan uses librarySymbols as the same v1 compatibility fallback for component backend symbol defs"},dxf:{exempt:"Deprecated symbol definitions are reusable SVG content with no DXF entity equivalent in the geometry exporter."},mermaid:{exempt:"Deprecated symbol definitions are reusable SVG content rather than Mermaid graph nodes or connectors."},pdf:{by:"Legacy symbol definitions are resolved into the rendered SVG page before that page crosses the svg2pdf conversion boundary"},"editor-dom":{by:"LibraryRegistry adopts legacy symbol definitions when no modern library symbol entry supersedes them"}}},markers:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,deprecated:"Superseded by `library` marker defs (v1 \u2192 v2 migration).",collab:{exempt:"Deprecated v1 field superseded by `library`. Read-only inbound; the serializer never writes it."},rendered:{renderToSvg:{by:"libraryMarkers provides the v1 compatibility fallback when library has no marker defs"},codegen:{by:"buildRenderPlan uses libraryMarkers as the same v1 compatibility fallback for component backend marker defs"},dxf:{exempt:"Deprecated SVG marker definitions are presentation attached to paths and have no DXF entity equivalent in this exporter."},mermaid:{exempt:"Deprecated SVG marker definitions are presentation rather than Mermaid node or connector records."},pdf:{by:"Legacy marker definitions are resolved into the rendered SVG page before that page crosses the svg2pdf conversion boundary"},"editor-dom":{by:"LibraryRegistry adopts legacy marker definitions when no modern library marker entry supersedes them"}}},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."}}}},Rp=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","exportItems","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","unknownFields","shapes"],pN=["id","type","state"];function Tp(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ts(t){let e=t,n=e.unknownFields;if(!Tp(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 ns(t){let e=t,n=Tp(e.unknownFields)?e.unknownFields:void 0;for(let r of Object.keys(e)){if(r==="unknownFields"||r in St)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 Pp(t){let e=t,n,r=e.unknownFields;if(Tp(r))for(let[i,o]of Object.entries(r))i==="unknownFields"||i in St||o===void 0||((n??={})[i]=o);for(let i of Object.keys(e)){if(i==="unknownFields"||i in St)continue;let o=e[i];o!==void 0&&((n??={})[i]=o)}return n}var fN=[["splinePoints","pathPoints"],["splineClosed","pathClosed"],["splineCurveType","pathCurveType"],["splineTension","pathTension"],["splineArcParams","pathArcParams"],["splineControlBounds","pathControlBounds"]];function Cp(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 fN)Object.prototype.hasOwnProperty.call(n,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=n[i]),n[i]=void 0,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 mN(t){let e=0;for(let n of t)Cp(n)&&e++;return e}function rs(t){return Nt(t,{onShape:e=>{Cp(e)}}),t}function zb(t){return typeof t=="string"&&t.length>0?t:null}function gN(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 hN(t){let e=gN(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 _b(t,e){let n=t.state.children;if(Array.isArray(n))for(let r of n)e.add(r.id),_b(r,e)}function Fb(t,e=!1){let n=t.state,r=n.children;return e&&delete n.groupId,Array.isArray(r)&&(n.children=r.map(i=>Fb(i,!0))),t}function yN(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 pr(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=>Fb(h)),s=new Set;for(let h of o)_b(h,s);let a=new Map,l=new Map;o.forEach((h,b)=>{s.has(h.id)||l.has(h.id)||(a.set(h.id,b),l.set(h.id,h))});for(let h of r){if(s.has(h.id)||l.has(h.id))continue;let b=hN(h);a.set(b.id,Number.POSITIVE_INFINITY),l.set(b.id,b)}let c=new Map,u=new Map;for(let h of l.values()){let b=h.state,S=i.get(h.id),v=zb(b.groupId)??(h.type==="group"?zb(S?.parentId):null),I=c.get(v)??[];u.set(h.id,v),I.push({shape:h,flatOrder:a.get(h.id)??Number.POSITIVE_INFINITY,siblingIndex:h.type==="group"?S?.siblingIndex:void 0}),c.set(v,I)}let d=new Set,p=h=>{if(d.has(h.id))return null;d.add(h.id);let b=h.state,S=Array.isArray(b.children)?b.children:[],v=f(h.id),I=new Set(S.map(P=>P.id)),x=[...S,...v.filter(P=>!I.has(P.id))];return x.length>0?b.children=x:delete b.children,delete b.groupId,h},f=h=>{let b=[];for(let S of yN(c.get(h)??[])){let v=p(S);v&&b.push(v)}return b},g=f(null),m=h=>{if(!h)return;let b=p(h);b&&g.push(b)};for(let h of l.values()){let b=u.get(h.id);b&&!l.has(b)&&m(h)}for(let h of r)m(l.get(h.id));for(let h of l.values())m(h);return g}function Gb(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,l=t.cy;if(typeof a=="number"&&typeof l=="number")return{x:a,y:l};let c=t.x1,u=t.y1,d=t.x2,p=t.y2;if(typeof c=="number"&&typeof u=="number"&&typeof d=="number"&&typeof p=="number")return{x:(c+d)/2,y:(u+p)/2};let f=t.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let g=t.polylinePoints;if(g?.[0])return{x:g[0].x,y:g[0].y}}function SN(t){return Nt(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||Xg(n,Gb(n))}}),t.schemaVersion=3,t}function $p(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 bN(t,e){let n=t.translateX??0,r=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",o=_e(n,r);if(i)return at(de(o,Dt(i)));let s=t.rotation??0,a=t.skewX??0,l=t.skewY??0;if(s!==0||a!==0||l!==0){let d=$p(t.customPivot)??e??$p(t.scaleAnchor);d&&(o=de(o,_e(d.x,d.y)),s!==0&&(o=de(o,wo(s))),a!==0&&(o=de(o,js(a))),l!==0&&(o=de(o,Us(l))),o=de(o,_e(-d.x,-d.y)))}let c=t.scaleX??1,u=t.scaleY??1;if(c!==1||u!==1){let d=$p(t.scaleAnchor)??e;d&&(o=de(o,_e(d.x,d.y)),o=de(o,bi(c,u)),o=de(o,_e(-d.x,-d.y)))}return at(o)}function vN(t){return Nt(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||!("scaleAnchor"in n)||(e.type==="text"&&!Yn(n.transformMatrix)&&(n.transformMatrix=bN(n,Gb(n))),delete n.scaleAnchor)}}),t.schemaVersion=4,t}function xN(t){let e=Array.isArray(t.library)?[...t.library]:[],n=new Set(e.map(l=>l.id));if(Array.isArray(t.symbols))for(let l of t.symbols)!l||n.has(l.id)||(e.push({...l,kind:"symbol"}),n.add(l.id));if(Array.isArray(t.markers))for(let l of t.markers)!l||n.has(l.id)||(e.push({...l,kind:"marker"}),n.add(l.id));let r=new Map,i=(l,c)=>{let{id:u,sourceId:d,...p}=l,f=JSON.stringify({kind:c,...p}),g=r.get(f);if(g)return g;let m=n.has(l.id)?`grd-${ul()}`:l.id;n.add(m),r.set(f,m);let h=c==="linear-gradient"?{kind:"linear-gradient",id:m,name:l.sourceId??m,sourceId:l.sourceId,gradient:Lb(l)}:{kind:"radial-gradient",id:m,name:l.sourceId??m,sourceId:l.sourceId,gradient:Lb(l)};return e.push(h),m},o=new Map;if(Array.isArray(t.customPatterns))for(let l of t.customPatterns){if(!l)continue;let c=n.has(l.id)?`pat-${ul()}`:l.id;n.add(c),o.set(l.id,c),e.push(Wn(l,c))}let s=l=>{if(l.customPatternId){let b=o.get(l.customPatternId);if(b)return b}let{id:c,sourceId:u,customPatternId:d,...p}=l,f=JSON.stringify({kind:"pattern",...p}),g=r.get(f);if(g)return g;let m=n.has(l.id)?`pat-${ul()}`:l.id;n.add(m),r.set(f,m);let h={kind:"pattern",id:m,name:l.sourceId??m,sourceId:l.sourceId,pattern:p};return e.push(h),m};for(let l of t.shapes??[]){let c=l.state;if(!c)continue;let u=c.fillGradient;u&&(u.type==="linear-gradient"||u.type==="radial-gradient"?c.fillLibraryId=i(u,u.type):u.type==="pattern"&&(c.fillLibraryId=s(u)));let d=c.strokeGradient;d&&(d.type==="linear-gradient"||d.type==="radial-gradient"?c.strokeLibraryId=i(d,d.type):d.type==="pattern"&&(c.strokeLibraryId=s(d)));let p=c.filters;if(Array.isArray(p)&&p.length>0){let f=a(p,c,l.id);c.filterLibraryIds=[f]}}return t.library=e,t;function a(l,c,u){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}),f=r.get(p);if(f)return f;let g=`filter-${u}`,m=n.has(g)?`flt-${ul()}`:g;n.add(m),r.set(p,m);let h={kind:"filter",id:m,name:m,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(h),m}}function Lb(t){let{id:e,sourceId:n,...r}=t;return r}var Ep=0;function ul(){return Ep=Ep+1&65535,`${Date.now().toString(36)}-${Ep.toString(36)}`}function IN(t){return Nt(t,{onState:e=>{Is(e)}}),t.schemaVersion=5,t}function wN(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=ci(n))}function kN(t){return Nt(t,{onState:e=>wN(e)}),t.schemaVersion=6,t}function Bb(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function pl(t){let e=new Set,n=new Set,r=new Map;Nt(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=Bb(`view-${s+1}`,e);e.add(a);let l=Bb(o.id||`legacy-view-${s+1}`,n);n.add(l),i.push({id:l,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 RN=["svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio"];function TN(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 RN)delete e[i];return}delete e.svgViewBoxX,delete e.svgViewBoxY,delete e.svgViewBoxWidth,delete e.svgViewBoxHeight}function Vb(t){return Nt(t,{onShape:TN}),pl(t),t.schemaVersion=7,t}var PN=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function CN(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 $N(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 PN){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=pr(r.shapes,r.groups),r.variants)for(let[s,a]of Object.entries(r.variants))r.variants[s]=pr(a,r.groups);let o=r;delete o.wrapperAttrs,delete o.groups,delete o.overflow}return Nt(t,{onShape:n=>CN(n,e)}),t.schemaVersion=8,t}var jb=Object.freeze({1:xN,2:SN,3:vN,4:IN,5:kN,6:Vb,7:$N});function EN(t){let e=t.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function is(t,e=jb){let n=JSON.parse(JSON.stringify(t)),r=EN(n);if(r>Ct)return n;if(r===Ct)return n.schemaVersion=Ct,n;for(;r<Ct;){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 ${Ct}.`);n=i(n),r+=1}return n.schemaVersion=Ct,n}function os(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 hc(n){return[...n].sort((e,t)=>e.id.localeCompare(t.id))}function nt(n){if(n==null)return n;if(Array.isArray(n))return n.map(nt);if(typeof n!="object")return n;let e={},t=Object.keys(n).sort();for(let r of t)e[r]=nt(n[r]);return e}function gc(n){let e={};return e.id=n.id,e.type=n.type,e.state=nt(n.state),e}var Pe=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Wr(n,e){return n.replace(Pe,(t,r)=>{let i=e[r];return i!==void 0?String(i):t})}function Hr(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)kn(i.state,t);if(r.documentMetadata){let i=r.documentMetadata;kn(i,t)}return r}function kn(n,e){for(let t of Object.keys(n)){let r=n[t];if(typeof r=="string"){if(Pe.lastIndex=0,Pe.test(r)){Pe.lastIndex=0;let i=Wr(r,e);if(yc(r)){let s=Number(i);if(!isNaN(s)&&Sc(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"?(Pe.lastIndex=0,Pe.test(r[i])&&(Pe.lastIndex=0,r[i]=Wr(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&kn(r[i],e);else r!==null&&typeof r=="object"&&kn(r,e)}}function yc(n){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(n)}var bc=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...qt,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Sc(n){return bc.has(n)}function jr(n){let e=n.templateVariables??[],t=new Set(e.map(s=>s.name)),r=new Set;for(let s of n.shapes)Tn(s.state,r);n.documentMetadata&&Tn(n.documentMetadata,r);let i=[...r].filter(s=>!t.has(s)).sort();return{defined:[...e],undeclared:i}}function Tn(n,e){for(let t of Object.values(n))if(typeof t=="string"){let r;for(Pe.lastIndex=0;(r=Pe.exec(t))!==null;)e.add(r[1])}else if(Array.isArray(t))for(let r of t)if(typeof r=="string"){let i;for(Pe.lastIndex=0;(i=Pe.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&Tn(r,e);else t!==null&&typeof t=="object"&&Tn(t,e)}function xc(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 $c=3,vc=12;function kc(n){return n==null||!Number.isFinite(n)?3:n<0?0:n>12?12:Math.floor(n)}function Xr(n,e){if(!Number.isFinite(n))return n;let t=Math.pow(10,e);return Math.round(n*t)/t}var Tc=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function Ka(n,e){return n.replace(Tc,t=>{let r=parseFloat(t);return Number.isFinite(r)?String(Xr(r,e)):t})}var wc=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),Pc=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function Me(n,e,t){if(e==null)return e;if(typeof e=="number")return Xr(e,t);if(typeof e=="string")return wc.has(n)?Ka(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Me(n,r,t));if(typeof e=="object"){if(Pc.has(n))return e;if(n==="symbolOverrides"){let i={};for(let[s,o]of Object.entries(e))i[s]=Me("state",o,t);return i}let r={};for(let[i,s]of Object.entries(e))r[i]=Me(i,s,t);return r}return e}function Kr(n,e){return{id:n.id,type:n.type,state:Me("state",n.state,e)}}function _c(n,e){let t={...n,shapes:n.shapes.map(r=>Kr(r,e)),viewboxes:n.viewboxes.map(r=>Me("viewbox",r,e))};return n.guides&&(t.guides=n.guides.map(r=>Me("guide",r,e))),n.measurements&&(t.measurements=n.measurements.map(r=>Me("measurement",r,e))),n.animationTimeline&&(t.animationTimeline=Me("animationTimeline",n.animationTimeline,e)),n.symbols&&(t.symbols=n.symbols.map(r=>({...r,shapes:r.shapes.map(i=>Kr(i,e))}))),n.markers&&(t.markers=n.markers.map(r=>Me("marker",r,e))),n.customPatterns&&(t.customPatterns=n.customPatterns.map(r=>Me("customPattern",r,e))),t}function Pn(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 Zr(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 Jr(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 Qr(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 ei(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 ti(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,ne;K<1e-6?(C=-T,ne=w):(C=-L/K,ne=D/K),f.push({x:$.x-C*a,y:$.y-ne*a}),d.push({x:$.x+C*a,y:$.y+ne*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 ni(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 ri(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)),ne=P.x+K/L*B,Q=P.y+K/L*D,Z=-D/L,me=B/L,Y={x:ne+Z*C,y:Q+me*C},W={x:ne-Z*C,y:Q-me*C};return Y.x*Y.x+Y.y*Y.y>W.x*W.x+W.y*W.y?Y: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,ne=B-K/2,Q={x:P.x+R*Math.cos(C),y:P.y+R*Math.sin(C)},Z={x:P.x+R*Math.cos(ne),y:P.y+R*Math.sin(ne)},Y=Q.x*Q.x+Q.y*Q.y>Z.x*Z.x+Z.y*Z.y?L:-K;for(let W=0;W<$;W++){let de=W/$,he=B+de*Y;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 Ce(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 ii(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 si(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 Rc=.2;function Xa(n,e,t,r=0){let i=e*(t/100),s=e,o=e-i,a=2*Math.PI/n,l=a*Rc/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 ai(n,e,t,r=0,i=0,s="evenodd",o=0){let a=Xa(n,e,t,o),l=Math.min(r,e*.1),c=Ce(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 oi(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+=wn(h,f,n+t,e,"tr"),k+=` L${n+t},${e+r-d}`,k+=wn(g,d,n+t,e+r,"br"),k+=` L${n+p},${e+r}`,k+=wn(b,p,n,e+r,"bl"),k+=` L${n},${e+c}`,k+=wn(m,c,n,e,"tl"),k+=" Z",k}function wn(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 li(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 rt(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 Cc(n,t,r);case"BASIS":case"basis":return Dc(n,t);case"ARC":case"arc":return i&&i.length>0?Ac(n,t,i):Wt(n,t,"CUBIC");case"LINEAR":case"linear":return Wt(n,t,"LINEAR");case"QUADRATIC":case"quadratic":return Wt(n,t,"QUADRATIC");case"CUBIC":case"cubic":return Wt(n,t,"CUBIC");default:return Wt(n,t)}}function Ac(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 Wt(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+=Yr(l,d,d.segmentType,s,o,t),r+=" Z"}r+=` M ${c.x} ${c.y}`,i=a+1,s=null,o=null;continue}r+=Yr(l,c,c.segmentType,s,o,t);let f=Mc(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+=Yr(a,l,l.segmentType,s,o,t)),r+=" Z"}return r}var Ic=.001;function xt(n,e){return Math.abs(n-e)<Ic}function Mc(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 Yr(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")&&xt(n.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&xt(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&&xt(c.x,2*n.x-i.x)&&xt(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&&xt(n.handleOut.x,2*n.x-n.handleIn.x)&&xt(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 Cc(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 Dc(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+=qr(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+=qr(r[s],r[s+1],r[s+2]);return i+=qr(r[t-2],r[t-1],r[t-1]),i+=` L ${r[t-1].x} ${r[t-1].y}`,i}function qr(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 Ht(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 Fc=[["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 q(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Ec(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 _n(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=Fc.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=Ec(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=Ht(f,d,p);m&&(e.set("stroke-dasharray",m),f==="dotted"&&e.set("stroke-linecap","round"));let h=Oc(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 Ya(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 Oc(n){return Gt(n)}function De(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}="${q(String(e))}"`}function An(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 Lc(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 Nc(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 Bc(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 zc(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 qa(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 Za(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 Ja(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 Gc(n,e,t){return`<feDiffuseLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("diffuseConstant",n.diffuseConstant)}${u("lighting-color",n.color)}${u("result",t)}>`+Ja(n.lightSource)+"</feDiffuseLighting>"}function Vc(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)}>`+Ja(n.lightSource)+"</feSpecularLighting>"}function Uc(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 Wc(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 Hc(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 jc(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 Kc(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 Xc(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 Yc(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 qc(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 Zc(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 Jc(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 Qc(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 ed(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 td(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 nd(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 rd(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 id(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 sd(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 ad(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 od(n,e,t){let{shadowColor:r,highlightColor:i}=n,s=An(r),o=An(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 ld(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 ud(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 cd(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 dd(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 fd(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 pd(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 md(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 gd(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 yd(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}=An(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 bd(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}=An(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 ui(n){switch(n.type){case"feBlend":return Sd(n);case"feColorMatrix":return xd(n);case"feComponentTransfer":return $d(n);case"feComposite":return vd(n);case"feConvolveMatrix":return kd(n);case"feDiffuseLighting":return Td(n);case"feSpecularLighting":return wd(n);case"feDisplacementMap":return Pd(n);case"feDropShadow":return _d(n);case"feFlood":return Rd(n);case"feGaussianBlur":return Ad(n);case"feImage":return Id(n);case"feMerge":return Md(n);case"feMorphology":return Cd(n);case"feOffset":return Dd(n);case"feTile":return Fd(n);case"feTurbulence":return Ed(n)}}function le(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 ue(n){return n.animations&&n.animations.length>0?n.animations.join(""):""}function Sd(n){let e=`<feBlend${le(n)}${u("in2",n.in2)}${u("mode",n.mode)}`;n.noComposite&&(e+=' no-composite="no-composite"');let t=ue(n);return t?`${e}>${t}</feBlend>`:`${e}/>`}function xd(n){let e=`<feColorMatrix${le(n)}${u("type",n.matrixType)}${u("values",n.values)}`,t=ue(n);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function Rn(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 $d(n){let e="";return e+=Rn("R",n.funcR),e+=Rn("G",n.funcG),e+=Rn("B",n.funcB),e+=Rn("A",n.funcA),e+=ue(n),`<feComponentTransfer${le(n)}>${e}</feComponentTransfer>`}function vd(n){let e=`<feComposite${le(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=ue(n);return t?`${e}>${t}</feComposite>`:`${e}/>`}function kd(n){let e=`<feConvolveMatrix${le(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=ue(n);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function Qa(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 Td(n){let e=`<feDiffuseLighting${le(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+=Qa(n.lightSource)),t+=ue(n),`${e}>${t}</feDiffuseLighting>`}function wd(n){let e=`<feSpecularLighting${le(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+=Qa(n.lightSource)),t+=ue(n),`${e}>${t}</feSpecularLighting>`}function Pd(n){let e=`<feDisplacementMap${le(n)}`;e+=u("in2",n.in2),e+=u("scale",n.scale),e+=u("xChannelSelector",n.xChannelSelector),e+=u("yChannelSelector",n.yChannelSelector);let t=ue(n);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function _d(n){let e=`<feDropShadow${le(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=ue(n);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function Rd(n){let e=`<feFlood${le(n)}${u("flood-color",n.floodColor)}${u("flood-opacity",n.floodOpacity)}`,t=ue(n);return t?`${e}>${t}</feFlood>`:`${e}/>`}function Ad(n){let e=`<feGaussianBlur${le(n)}${u("stdDeviation",n.stdDeviation)}${u("edgeMode",n.edgeMode)}`,t=ue(n);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function Id(n){let e=`<feImage${le(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=ue(n);return t?`${e}>${t}</feImage>`:`${e}/>`}function Md(n){let e="";for(let t of n.nodes)e+=`<feMergeNode${u("in",t.in)}/>`;return e+=ue(n),`<feMerge${le(n)}>${e}</feMerge>`}function Cd(n){let e=`<feMorphology${le(n)}${u("operator",n.operator)}${u("radius",n.radius)}`,t=ue(n);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function Dd(n){let e=`<feOffset${le(n)}${u("dx",n.dx)}${u("dy",n.dy)}`,t=ue(n);return t?`${e}>${t}</feOffset>`:`${e}/>`}function Fd(n){let e=`<feTile${le(n)}`,t=ue(n);return t?`${e}>${t}</feTile>`:`${e}/>`}function Ed(n){let e=`<feTurbulence${le(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=ue(n);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function eo(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>${q(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${q(e.filterDescription)}</desc>`);for(let r of e.primitives)t+=ui(r);if(e.filterAnimations)for(let r of e.filterAnimations)t+=r;return t+="</filter>",t}function to(n,e,t,r){switch(n.type){case"drop-shadow":return Lc(n,e,t);case"inner-shadow":return Nc(n,e,t);case"gaussian-blur":return Bc(n,e,t);case"motion-blur":return zc(n,e,t);case"point-light":{let i=n;return qa(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,t)}case"spot-light":{let i=n;return Za(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 Gc(n,e,t);case"specular-lighting":return Vc(n,e,t);case"outline":return Uc(n,e,t);case"sharpen":return Wc(n,e,t);case"pixelate":return Hc(n,e,t);case"warp":return jc(n,e,t);case"morphology":return Kc(n,e,t);case"contouring-discrete":return Xc(n,e,t);case"contouring-table":return Yc(n,e,t);case"round-edges":return qc(n,e,t);case"grayscale":return Zc(n,e,t);case"channel-painter":return Jc(n,e,t);case"brightness":return Qc(n,e,t);case"contrast":return ed(n,e,t);case"opacity":return td(n,e,t);case"invert":return nd(n,e,t);case"hue-rotate":return rd(n,e,t);case"saturate":return id(n,e,t);case"black-and-white":return sd(n,e,t);case"sepia":return ad(n,e,t);case"duotone":return od(n,e,t);case"xray":return ld(n,e,t);case"noise":return ud(n,e,t);case"emboss":return cd(n,e,t);case"film-grain":return dd(n,e,t);case"watercolor":return fd(n,e,t);case"gouache":return pd(n,e,t);case"ink-blot":return md(n,e,t);case"crumpled-plastic":return hd(n,e,t);case"riddled":return gd(n,e,t);case"glow":return yd(n,e,t);case"inner-glow":return bd(n,e,t);case"raw-svg":return n.svgContent;case"svg-primitive-chain":return n.primitives.map(ui).join("");default:return H(e,t)}}function Od(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 ci(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 eo(n,x)}let a=r.some(x=>x.type==="gaussian-blur"&&x.quality==="high"||x.type==="motion-blur"&&x.quality==="high"),l=Od(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+=to(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 Ld(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+=ci(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 di(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(#${q(s)})`).join(" ")}"`:` filter="url(#filter-${q(n)})"`}function Nd(n){if(n instanceof Map)return n;let e=new Map;for(let t of n)e.set(t.id,t);return e}function Bd(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 no(n,e,t,r){let i=Nd(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 Bd(p))c(m)}}var zd=[],Gd=[];function Mn(n,e,t){no(n,Gd,e,t)}function Vd(n,e,t){no(zd,n,e,t)}function Ud(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(In(o));let a=t.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(In(a))}function In(n){return`line-marker-${n}`}function Wd(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 Cn(n,e=[]){let t=new Set,r=new Set;return Mn(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 Hd(n,e){let{ids:t,legacyEndpoints:r}=Cn(n,e);for(let i of r)t.add(In(i));return t}function Dn(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 jd(n){let e=Object.entries(n.attrs).map(([t,r])=>` ${t}="${r}"`).join("");return`<${n.tag}${e}/>`}function fi(n,e,t,r,i){let s=10*e,o="";o+=`<rect width="${s}" height="${s}" fill="${r}"/>`;let a=Dn(n,s,t,i);for(let l of a)o+=jd(l);return{svgContent:o,width:s,height:s}}var Fn="0 0 10 10",pi=6,mi=6;function $t(){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 ro={"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"},Kd={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function Xd(){return $t().map(n=>{let e=ro[n.id]??n.id;return{kind:"marker",id:e,name:Kd[e]??e,viewBox:Fn,refX:n.refX,refY:n.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function Yd(n){return n.replace(/[^a-zA-Z0-9_-]/g,"_")}function qd(n){let e=n.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function jt(n){let e=n.state.symbolId??"",t=n.state.variantKey??"";return qd(n)?`${e}--ovr-${n.id}`:t?`${e}--${Yd(t)}`:e}function hi(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 En(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 Zd=[["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 Kt(n){return Zd.map(([e,t])=>{let r=n[e],i=typeof r=="string"?r.trim():"";return i?`${t}: ${i}`:""}).filter(Boolean).join("; ")}function gi(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=Kt(n);i&&i!==Kt(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}="${q(String(e))}"`}function vt(n,e){return e==null?"":` ${n}="${q(e)}"`}function Jd(n){let e=n.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?y("style",e):""}function Qd(n,e){return typeof e=="number"&&e>0?`${n}: ${e}px`:""}function ef(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 io(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 so(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 tf(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 Re(n,e){return Gt(n,e)}function nf(n,e,t){return Ba(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 sf(n){if(typeof n.strokeDasharray=="string")return n.strokeDasharray;let e=n.lineStyle??"solid",t=n.dashLength??8,r=n.gapLength??4;return Ht(e,t,r)}function On(n,e){let t=n[e];return t!==void 0?t:n.extra?.[e]}function af(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":On(n,"linearGradient")?"linear-gradient":On(n,"radialGradient")?"radial-gradient":"solid")}function of(n){return n.fillGradient??On(n,"linearGradient")??On(n,"radialGradient")??void 0}function _e(n,e){let t=y("data-shape-id",e),r=af(n),i=of(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=sf(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+=di(e,n.filters,n.filterLibraryIds),t+=vt("systemLanguage",n.systemLanguage),t+=vt("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 yi(n){let e=n.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${q(e.title)}</title>`),e.description&&(t+=`<desc>${q(e.description)}</desc>`),t}function lf(n,e){let t=yi(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 bi(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 ao(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.radius??50,s=Re(e,{x:t,y:r});return`<circle${y("cx",t)}${y("cy",r)}${y("r",i)}${_e(e,n.id)}${s?y("transform",s):""}/>`}function oo(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=Re(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):""}${_e(e,n.id)}${a?y("transform",a):""}/>`}function lo(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=Re(e,p);if(f!=="round"||d==="non-uniform"){let h=oi(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)}${_e(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)}`:""}${_e(e,n.id)}${m?y("transform",m):""}/>`}function uo(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=Re(e,o),l={...e,fillType:"none"};return`<line${y("x1",t)}${y("y1",r)}${y("x2",i)}${y("y2",s)}${_e(l,n.id)}${bi(e)}${a?y("transform",a):""}/>`}function co(n){let e=n.state,t=e.x??0,r=e.y??0,i=En(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=Re(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=Kt(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+=Jd([P,M,Qd("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+=_e(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}`,ne=e.textPathMethod,Q=e.textPathSpacing,Z=e.textPathLengthAdjust,me=e.textPathLength,Y="";if(D.length>=2)if(K==="right"){let W=D[D.length-1];Y=`M ${W.x} ${W.y}`;for(let de=D.length-1;de>0;de--){let he=D[de],Te=D[de-1],$e=he.handleIn??he,lt=Te.handleOut??Te;Y+=` C ${$e.x} ${$e.y}, ${lt.x} ${lt.y}, ${Te.x} ${Te.y}`}}else{Y=`M ${D[0].x} ${D[0].y}`;for(let W=0;W<D.length-1;W++){let de=D[W],he=D[W+1],Te=de.handleOut??de,$e=he.handleIn??he;Y+=` C ${Te.x} ${Te.y}, ${$e.x} ${$e.y}, ${he.x} ${he.y}`}}return`<defs><path id="${q(C)}"${y("d",Y)} fill="none"/></defs><text${b}><textPath href="#${q(C)}"${y("startOffset",`${L}%`)}${y("method",ne)}${y("spacing",Q)}${y("lengthAdjust",Z)}${y("textLength",me)}>${q(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let D=e.charOffsets.map(ef),L=i.split(`
12
- `),K=e.linePositions??[],C=s*m,ne="",Q=0;return L.forEach((Z,me)=>{let Y=Array.from(Z).length,W=D.slice(Q,Q+Y),de=K[me],he=de?t+de.x:me>0?t:NaN,Te=de?de.dy:me>0?C:NaN,$e="",lt=io(W,"x");if(Number.isFinite(he)||lt.length>0){let Qn=lt.length>0?lt.slice():[];Number.isFinite(he)&&(Qn[0]=Qn[0]??he),$e+=y("x",Qn.join(" "))}let Ts=io(W,"y");Ts.length>0&&($e+=y("y",Ts.join(" ")));let ws=so(W,"dx");ws.length>0&&($e+=y("dx",ws.join(" ")));let Ps=so(W,"dy"),Ge=Ps.length>0||Number.isFinite(Te)?Ps.slice():[];for(Number.isFinite(Te)&&(Ge[0]=(Ge[0]??0)+Te);Ge.length>0&&Ge[Ge.length-1]===0;)Ge.pop();Ge.length>0&&($e+=y("dy",Ge.join(" ")));let _s=tf(W);_s.length>0&&($e+=y("rotate",_s.join(" "))),ne+=`<tspan${$e}>${q(Z)}</tspan>`,Q+=Y+1}),`<text${b}>${ne}</text>`}let B=kr(e);if(B){let D=je(B),L=e.linePositions,K=s*D.lineHeight,C="";return D.lines.forEach((ne,Q)=>{ne.segments.forEach((Z,me)=>{let Y="";if(me===0){let W=L?.[Q];W?((Math.abs(W.x)>.001||Q>0)&&(Y+=y("x",t+W.x)),(Math.abs(W.dy)>.001||Q>0)&&(Y+=y("dy",W.dy))):Q>0&&(Y+=y("x",t),Y+=y("dy",`${K}px`))}for(let{name:W,value:de}of gi(Z.style,D.baseStyle))Y+=y(W,de);Y+=' xml:space="preserve"',C+=`<tspan${Y}>${q(En(Z.text,Z.style.textTransform))}</tspan>`})}),`<text${b}>${C}</text>`}return`<text${b}>${q(i)}</text>`}function fo(n){let e=n.state,t=e.pathPoints??[],r=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,s=e.pathTension??.5,o=e.pathArcParams,a=rt(t,r,i,s,o),l=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=l?Re(e,l):null;return`<path${y("d",a)}${_e(e,n.id)}${bi(e)}${c?y("transform",c):""}/>`}function po(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?Re(e,s):null;return`<${r?"polygon":"polyline"}${y("points",i)}${_e(e,n.id)}${bi(e)}${o?y("transform",o):""}/>`}function mo(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=Re(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):""}${_e(e,n.id)}${f?y("transform",f):""}/>`}function Ln(n){return!n||n.length===0?"":n.map(e=>fe(e)).join("")}function ho(n){let e=n.state,t="",r=Re(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}="${q(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}="${q(c)}"`);return t}function uf(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+=ho(n),i+=y("data-shape-id",n.id),i+=">",i+=yi(e),i+=Ln(e.children),i+="</a>",i}function cf(n){let e=n.state,t="<switch";return t+=vt("systemLanguage",e.switchSystemLanguage),t+=vt("requiredExtensions",e.switchRequiredExtensions),t+=ho(n),t+=y("data-shape-id",n.id),t+=">",t+=yi(e),t+=Ln(e.children),t+="</switch>",t}function df(n){let e=n.state,t=Re(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+=Ln(e.children),r+="</g>",r}function ff(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 pf(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+=Ln(e.children),d+="</svg>",d}function mf(n){let e=n.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${q(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 go(n){let e=n.state,t=jt(n),r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100;return`<use href="#${q(t)}" x="${r}" y="${i}" width="${s}" height="${o}"/>`}function hf(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+=vt("systemLanguage",e.systemLanguage),p+=vt("requiredExtensions",e.requiredExtensions),f!==void 0&&f<1&&(p+=y("opacity",f)),p+=">",p+=d,p+="</foreignObject>",p}function yo(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=Re(e,o),l=li(n.type,t,r,i,s,{slantPercent:e.slantPercent,topWidthPercent:e.topWidthPercent,capHeightPercent:e.capHeightPercent,waveAmplitudePercent:e.waveAmplitudePercent});return`<path${y("d",l)}${_e(e,n.id)}${a?y("transform",a):""}/>`}function bo(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=nf(e,t,r),c="";switch(n.type){case"triangle":c=Ce(Pn(3,i,o),s,i);break;case"ngon":{let d=e.sides??6;c=Ce(Pn(d,i,o),s,i);break}case"star":{let d=e.arms??5,p=e.innerRadiusPercent??50;c=Ce(Zr(d,i,p,o),s,i);break}case"cross":{let d=e.armWidthPercent??40;c=Ce(Jr(i,d,o),s,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=ii(i,d,a);break}case"spiral":{let d=e.turns??3,p=e.thicknessPercent??20,m=e.spiralDirection??1;c=si(i,d,p,m,o);break}case"gear":{let d=e.teeth??8,p=e.toothDepthPercent??30,m=e.holeRadiusPercent??0;c=ai(d,i,p,s,m,a,o);break}case"arrow":{let d=e.headWidthPercent??100,p=e.headLengthPercent??30,m=e.shaftWidthPercent??40;c=Ce(Qr(i,d,p,m,o),s,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,p=e.tailLengthPercent??40,m=e.tailWidthPercent??25;c=Ce(ei(i,d,p,m,o),s,i);break}case"lightning":{let d=e.boltSegments??3,p=e.boltJaggednessPercent??40,m=e.boltWidthPercent??30;c=Ce(ti(i,d,p,m,o),s,i);break}case"heart":{let d=e.lobeRadiusPercent??50,p=e.cleftDepthPercent??25;c=ni(i,d,p,o);break}case"cloud":{let d=e.cloudBumps??5,p=e.cloudPuffinessPercent??60;c=ri(i,d,p,o);break}default:return`<!-- unsupported polygon shape: ${q(n.type)} -->`}let f="";return(n.type==="ring"||n.type==="gear")&&(f=y("fill-rule",a)),`<path${y("d",c)}${f}${_e(e,n.id)}${y("transform",l)}/>`}function fe(n){let e;switch(n.type){case"circle":e=ao(n);break;case"ellipse":e=oo(n);break;case"rectangle":case"square":e=lo(n);break;case"line":e=uo(n);break;case"text":e=co(n);break;case"path":e=fo(n);break;case"polyline":e=po(n);break;case"image":e=mo(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=bo(n);break;case"diamond":case"parallelogram":case"trapezoid":case"terminator":case"cylinder":case"document-shape":e=yo(n);break;case"hyperlink":e=uf(n);break;case"switch":e=cf(n);break;case"container":case"group":e=df(n);break;case"view":e=ff(n);break;case"svg":e=pf(n);break;case"shape-reference":e=mf(n);break;case"symbol-instance":e=go(n);break;case"audio":case"video":e=hf(n);break;default:return`<!-- unsupported shape type: ${q(n.type)} -->`}return lf(e,n.state)}function So(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 xo(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 $o(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+=gf(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 gf(n,e,t){return Dn(n,e,t).map(i=>{let s=Object.entries(i.attrs).map(([o,a])=>y(o,a)).join("");return`<${i.tag}${s}/>`}).join("")}function Be(n,e=[]){let t=Array.isArray(n)?Cn(n,e):n;if(t.ids.size===0&&t.legacyEndpoints.size===0)return"";let r="",i=$t();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",Fn)}${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 ze=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),vo=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function ko(n){switch(n.kind){case"symbol":return To(n);case"marker":return wo(n);case"linear-gradient":return Po(n);case"radial-gradient":return _o(n);case"pattern":return Ro(n);case"filter":return Ao(n)}}function To(n){let e=n.shapes.map(i=>fe(i)).join(""),t=n.viewBox?` viewBox="${ze(n.viewBox)}"`:"",r=n.overflow?` overflow="${ze(n.overflow)}"`:"";return`<symbol id="${ze(n.id)}"${t}${r}>${e}</symbol>`}function wo(n){let e;if(n.builtIn){let s=$t().find(o=>n.id.includes(o.id)||n.id===o.id);if(s){let o=Object.entries(s.element.attrs).map(([a,l])=>` ${a}="${ze(String(l))}"`).join("");e=`<${s.element.tag}${o}/>`}else e=""}else e=n.shapes.map(s=>fe(s)).join("");let t=typeof n.orient=="number"?String(n.orient):n.orient,r=n.viewBox?` viewBox="${ze(n.viewBox)}"`:"",i=n.overflow?` overflow="${ze(n.overflow)}"`:"";return`<marker id="${ze(n.id)}"${r} refX="${n.refX}" refY="${n.refY}" markerWidth="${n.markerWidth}" markerHeight="${n.markerHeight}" markerUnits="${ze(n.markerUnits)}" orient="${ze(t)}"${i}>${e}</marker>`}function Po(n){let e={...n.gradient,type:"linear-gradient",id:n.id};return So(n.id,e)}function _o(n){let e={...n.gradient,type:"radial-gradient",id:n.id};return xo(n.id,e)}function Ro(n){let e={...n.pattern,type:"pattern",id:n.id};return $o(n.id,e)}function Ao(n){return ci(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 Nn(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 vo){let i=e.get(r);if(i)for(let s of i)t+=ko(s)}return t}function it(n,e){let t=Bn(n,e);return t.length===0?"":Nn(t)}function Bn(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 Mn(n,e,a),Array.from(r.values())}function Io(n){return n.easing==="custom-bezier"&&n.customBezier?n.customBezier:tr[n.easing]??null}function Mo(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 Co(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 xe(n){return!Number.isFinite(n)||Math.abs(n)<1e-9?"0":Math.abs(n-1)<1e-9?"1":parseFloat(n.toFixed(6)).toString()}function Si([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 Do(n){return n.length>0&&n.every(e=>e==="0 0 1 1")}function Gn(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 xi(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 st(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 kt(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 $i(n){return n.keyframes.length===1&&n.cycleDuration===void 0}function vi(n){return n.calcMode!=="discrete"?!1:n.sourceSmilElement==="set"?!0:!n.sourceSmilElement&&!n.cycleInfinite&&n.keyframes.every(e=>e.easing!=="steps")}function ki(n,e){if(e<=0)return kt(n);if(kt(n)==="indefinite")return"indefinite";let t=n.keyframes[e]?.time??0;return t!==0?`${t}s`:""}function Ti(n){return n.cycleInfinite?"indefinite":n.cycleRepeats&&n.cycleRepeats>1?String(n.cycleRepeats):null}function Tt(n){return n.cycleInfinite||n.fill==="remove"?null:"freeze"}function wi(n){return n.additive==="sum"?"sum":null}function Pi(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 yf(n){let e=t=>Math.max(0,Math.min(1,t));return[n[0],e(n[1]),n[2],e(n[3])]}function bf(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 Sf(n,e,t,r,i,s){let o=typeof n.value=="number"&&typeof e.value=="number",a=Ye(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(xe(t(S))),s.push("0 0 1 1")}return}r.push(a),i.push(xe(t(e.time))),s.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(xe(t(e.time))),s.push("0 0 1 1");return}let l=Io(e);if(!l){r.push(a),i.push(xe(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(xe(t(e.time))),s.push(Si(l));return}if(!o){r.push(a),i.push(xe(t(e.time))),s.push(Si(yf(l)));return}let p=bf(l),m=n.value,h=e.value,g=e.time-n.time;for(let b of p){let $=Mo(l[0],l[1],l[2],l[3],b),k=n.time+g*b,S=m+(h-m)*$;r.push(S),i.push(xe(t(k))),s.push("0 0 1 1")}}function Ye(n){return Array.isArray(n)?n.join(" "):n}function xf(n,e,t){let r=[],{count:i,position:s}=t,o=e.time-n.time,a=Ye(n.value),l=Ye(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 $f(n,e){let t=[],r=[],i=(s,o)=>{t.push(s),r.push(xe(e(o)))};i(Ye(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=xf(o,a,a.stepsParams);for(let c of l)i(c.value,c.time)}else i(Ye(a.value),a.time)}return{values:t,keyTimes:r}}function zn(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=>xe(1-parseFloat(l))),a=t.slice().reverse().map(Co);return{values:[...n,...s],keyTimes:[...e,...o],keySplines:[...t,...a],calcMode:r}}function at(n){let e=n.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let t=st(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}=$f(e,i);return zn(c,f,[],"discrete",n)}if(n.calcMode==="discrete"){let c=e.map(d=>Ye(d.value)),f=e.map(d=>xe(i(d.time)));return zn(c,f,[],"discrete",n)}if(n.calcMode==="paced"){let c=e.map(d=>Ye(d.value)),f=e.map(d=>xe(i(d.time)));return zn(c,f,[],"paced",n)}let o=[Ye(e[0].value)],a=[xe(i(e[0].time))],l=[];for(let c=1;c<e.length;c++)Sf(e[c-1],e[c],i,o,a,l);return zn(o,a,l,"spline",n)}function Vn(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&&!Do(n.keySplines);return Gn(n.keyTimes)||(r.keyTimes=n.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=n.keySplines.join(";")),r}function Fo(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 _i(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)||!Fo(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 Ri(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 Oo={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"},Lo=new Set(["transformMatrix","rotation","skewX","skewY"]),No=new Set(["translateX","translateY","scaleX","scaleY"]);function Un(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j(n,e){return e==null?"":` ${n}="${Un(e)}"`}function Ai(n,e){let t=Vn(n,e);return j("keyTimes",t.keyTimes)+j("calcMode",t.calcMode)+j("keySplines",t.keySplines)}function Wn(n,e){return j("dur",`${e}s`)+j("begin",kt(n)||null)+j("repeatCount",Ti(n))}function vf(n){let e=Oo[n.property];if(!e)return"";let t=st(n);if(t<=0)return"";let r=at(n);return r.values.length<2?"":"<animate"+j("attributeName",e)+j("values",r.values.join(";"))+Ai(r)+Wn(n,t)+j("fill",Tt(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=st(n);if(t<=0)return"";let r=at(n),i=e==="matrix"?r.values.map(o=>wf(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(";"))+Ai(r)+Wn(n,t)+j("additive",wi(n))+j("fill",Tt(n))+"/>"}function Tf(n,e,t){let r=n.property==="scaleX"||n.property==="scaleY",i=n.property==="translateY"||n.property==="scaleY",s=r?"scale":"translate",o=st(n);if(o<=0)return"";let a=at(n);if(a.values.length<2)return"";let l=e?at(e):void 0,c=Ri(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(";"))+Ai(a)+Wn(n,o)+j("additive",f)+j("fill",Tt(n))+"/>"}function wf(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 Pf(n){if(!n.motionPath)return"";let e=st(n);if(e<=0)return"";let t=at(n),r=Pi(n),i=!!n.motionPathRef&&(n.motionPathRef.mode??"trackShape")==="curveTemplate",s=Vn(t,{defaultCalcMode:"paced"}),o=xi(r)&&Gn(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+=Wn(n,e),a+=j("fill",Tt(n)),n.motionRotate!==void 0&&(a+=j("rotate",typeof n.motionRotate=="number"?String(n.motionRotate):n.motionRotate)),i?a+=`><mpath href="#${Un(n.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function Eo(n,e){if(Lo.has(n.property)||No.has(n.property)||n.property==="pathMotion")return"";let t=Oo[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",ki(n,e)||null)+"/>":""}function _f(n){let e=kt(n);return e?`<discard begin="${Un(e)}"/>`:"<discard/>"}function Ii(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=_i(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="${Un(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,_f(a),a);continue}if($i(a)){o(a.shapeId,Eo(a,0),a);continue}if(vi(a)){for(let c=0;c<a.keyframes.length;c++)o(a.shapeId,Eo(a,c),a);continue}if(a.keyframes.length<2)continue;let l="";a.property==="pathMotion"&&a.motionPath?l=Pf(a):Lo.has(a.property)?(l=kf(a),l&&s.add(a.shapeId)):No.has(a.property)?(l=Tf(a,r.partner.get(a.id),s.has(a.shapeId)),l&&s.add(a.shapeId)):l=vf(a),o(a.shapeId,l,a)}return e}function Xt(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=Mf(n),b=Cf(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=Bn(h,$),S=k.length>0?Nn(k):"",x=Be(h,$),v=Df(g,h,new Set(k.map(D=>D.id))),w=Rf(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?Ii(n.animationTimeline):null,N=h.map(D=>{let L=fe(D),K=M?.get(D.id);return K&&K.length>0&&(L=Ff(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 Rf(n){if(n.length===0)return"";let e=[];for(let t of n){let r=Af(t);if(!r)continue;let i=If(r);e.push(`<path id="${Bo(t.id)}" d="${Bo(i)}"/>`)}return e.join("")}function Af(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 If(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 Bo(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Mf(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="symbol");return t.length>0?t:n.symbols??[]}function Cf(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="marker");return t.length>0?t:n.markers}var Mi=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Df(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=jt(c);if(s.has(p))continue;s.add(p);let m=hi(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=>fe(h)).join(""),p=c.viewBox?` viewBox="${Mi(c.viewBox)}"`:"",m=c.overflow?` overflow="${Mi(c.overflow)}"`:"";a.push(`<symbol id="${Mi(l)}"${p}${m}>${d}</symbol>`)}return a.join("")}function Ff(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 wt=Math.PI*2;function Ef(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 Of(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 Lf(n,e,t,r){let i=1-r;return i*i*n+2*i*r*e+r*r*t}function Ci(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=[];Ef(o,a,l,c);for(let f of c){let d=Of(n,e,t,r,f);d<i&&(i=d),d>s&&(s=d)}return{min:i,max:s}}function Di(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=Lf(n,e,t,o);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function zo(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 Uo(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,ne=(-$-N)/f,Q=zo(1,0,L,K),Z=zo(L,K,C,ne);return!o&&Z>0?Z-=wt:o&&Z<0&&(Z+=wt),{cx:B,cy:D,rx:c,ry:f,phi:d,theta1:Q,deltaTheta:Z}}function Nf(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 Bf(n,e,t){if(t>=0){let i=(n-e)%wt;return i<0&&(i+=wt),i<=t}let r=(e-n)%wt;return r<0&&(r+=wt),r<=-t}function Wo(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=Uo(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(!Bf(b,f.theta1,f.deltaTheta))continue;let $=Nf(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 zf="MmLlHhVvCcSsQqTtAaZz";function Hn(n){return n>=48&&n<=57}function Gf(n){return n===32||n===9||n===10||n===12||n===13}var Fi=class{constructor(e){this.d=e}d;i=0;skipWsp(){for(;this.i<this.d.length&&Gf(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&&zf.indexOf(e)>=0?(this.i++,e):null}nextIsNumber(){this.skipCommaWsp();let e=this.d.charCodeAt(this.i);return Hn(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&&Hn(e.charCodeAt(r));)r++,s++;if(e.charCodeAt(r)===46)for(r++;r<e.length&&Hn(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&&Hn(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 jn(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 Ei(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 Go(n,e,t,r,i,s,o,a,l){let c=Ci(e,r,s,a),f=Ci(t,i,o,l);Ei(n,{minX:c.min,maxX:c.max,minY:f.min,maxY:f.max})}function Vo(n,e,t,r,i,s,o){let a=Di(e,r,s),l=Di(t,i,o);Ei(n,{minX:a.min,maxX:a.max,minY:l.min,maxY:l.max})}function Ho(n){if(!n)return null;let e=new Fi(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,jn(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,jn(t,r,i),c=null;break}case"H":case"h":{let g=e.readNumber();if(g===null)return p();r=h?r+g:g,jn(t,r,i),c=null;break}case"V":case"v":{let g=e.readNumber();if(g===null)return p();i=h?i+g:g,jn(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;Go(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;Go(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;Vo(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;Vo(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;Ei(t,Wo(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 Vf(n,e,t=!1,r=.5,i){return n.length===0?null:Ho(rt(n,e,t,r,i))}function Oi(n,e){let t=De(n,e);return Xt(n,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function Uf(n){return n==="class"?"className":n==="for"?"htmlFor":n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function jo(n){return n.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${Uf(t)}=`)}function Li(n,e){let t=e.componentName??"SvgComponent",r=De(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=it(s,a),c=Be(s,a),f=l+c,d=f.length>0,p=s.map(h=>{let g=fe(h);return`${i}${i}${i}${jo(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}${jo(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 Ni(n,e){let t=e.componentName??"SvgComponent",r=De(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=it(s,a),c=Be(s,a),f=l+c,d=f.length>0,p=s.map(h=>`${i}${i}${fe(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 Wf=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Ko(n){return n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Xo(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Hf(n){if(!Wf.has(n.type))return!0;let e=n.state.metadata;return!!(e?.title||e?.description||n.type==="text"&&n.state.isTextPath)}function Bi(n,e){let t=e.componentName??"createSvg",r=De(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=it(s,l),f=Be(s,l),d=`${c}${f}`;d.length>0&&(a.push(`${i}svg.append('defs').html(\`${Xo(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}`:""}`),Hf(m)){a.push(`${i}svg.append('g').html(\`${Xo(fe(m))}\`);`),a.push("");continue}let h=Ya(m),g=_n(m),b=`shape${p+1}`;a.push(`${i}const ${b} = svg.append('${h}')`);for(let[$,k]of g)a.push(`${i}${i}.attr('${$}', '${Ko(k)}')`);m.type==="text"&&m.state.text&&a.push(`${i}${i}.text('${Ko(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 Yo(n,e){let t=n.state.metadata?.name;return t?t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${n.type}-${e+1}`}var jf=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function zi(n,e){let t=De(n,e),r=e.indent??" ",i=n.shapes??[],s=[];for(let l=0;l<i.length;l++){let c=i[l],f=Yo(c,l),d=_n(c),p=[];for(let[m,h]of d)jf.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}))}var AN=["migration","validation","normalization","canonical-node-construction","document-section-staging"];function Ap(t){let e=structuredClone(t);return e.shapes=pr(e.shapes,e.groups),e.groups=[],e}function Ub(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)=>Ub(s,e,n,t.id,a))}function NN(t){let e=new Map,n=new Map,r=new Map,i=(s,a)=>{let l=a?n:e,c=l.get(s.id)??[];c.push(s),l.set(s.id,c),r.set(s.id,(r.get(s.id)??0)+1);let u=s.state.children;Array.isArray(u)&&u.forEach(d=>i(d,!0))};t.shapes.forEach(s=>i(s,!1));let o=new Set;for(let[s,a]of e){if(a.length!==1||r.get(s)!==2)continue;let l=n.get(s)??[];if(l.length!==1||(o.add(s),JSON.stringify(a[0])!==JSON.stringify(l[0])))continue;let c=[],u=p=>{c.push(p.id);let f=p.state.children;Array.isArray(f)&&f.forEach(u)};u(a[0]);let d=new Set(c);d.size===c.length&&([...d].some(p=>r.get(p)!==2)||d.forEach(p=>o.add(p)))}return o}function MN(t,e){let n=new Map,r=[];t.shapes.forEach((c,u)=>Ub(c,n,r,null,u));let i=new Map(r.map(c=>[c.id,c])),o=new Set,s=[];for(let c of t.sceneTree??[])o.has(c.id)||(o.add(c.id),s.push(structuredClone(c)));for(let c of r)o.has(c.id)||(o.add(c.id),s.push(structuredClone(c)));let a=new Set(s.map(c=>c.id)),l=new Map;for(let c of s){let u=i.get(c.id),d=e||c.parentId===null||a.has(c.parentId)?c.parentId:u?.parentId??null,p=l.get(d)??[];p.push({...c,parentId:d}),l.set(d,p)}t.sceneTree=[...l.values()].flatMap(c=>it(c).map((u,d)=>{let p={...u,index:d};return p.orderKey===void 0&&delete p.orderKey,p.updatedAt===void 0&&delete p.updatedAt,p.clientId===void 0&&delete p.clientId,p}))}function ON(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function DN(t){let e=t.shapes.filter(a=>a.type==="view"&&a.state.isHomeView===!0);if(e.length===0)return;let n=e[0].state,r=n.viewBoxWidth??0,i=n.viewBoxHeight??0,o=t.shapes.find(a=>a.type==="svg"&&a.state.isRootSvg===!0);if(o){let a=o.state,l=Number(a.svgViewBoxWidth??0),c=Number(a.svgViewBoxHeight??0);!(l>0&&c>0)&&r>0&&i>0&&(a.svgViewBoxX=n.viewBoxX??0,a.svgViewBoxY=n.viewBoxY??0,a.svgViewBoxWidth=r,a.svgViewBoxHeight=i,Number(a.svgWidth??0)>0||(a.svgWidth=r),Number(a.svgHeight??0)>0||(a.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 zN(t,e){if(e===!1||t.shapes.find(d=>d.type==="svg"&&d.state.isRootSvg===!0))return;let r=new Set((t.sceneTree??[]).filter(d=>d.parentId===null).map(d=>d.id)),i=(t.sceneTree?.length??0)>0;if(t.shapes.some(d=>d.type==="svg"&&d.state.isRootSvg!==!0&&(!i||r.has(d.id))))return;let s=e?.width??800,a=e?.height??600,l=new Set,c=d=>{for(let p of d){l.add(p.id);let f=p.state.children;Array.isArray(f)&&c(f)}};c(t.shapes);let u=ON(e?.idBase??"document-root",l);t.shapes.unshift({id:u,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:u,parentId:null,index:0},...t.sceneTree.map(d=>d.parentId===null?{...d,index:d.index+1}:d)])}function _N(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 Hb(t,e){MN(t,e.preserveUnresolvedParents),e.materializeClipMaskStructure&&vr(t),fi(t),_N(t)}function FN(t){let e=Ap(t);return Hb(e,{materializeClipMaskStructure:!1,preserveUnresolvedParents:!0}),e}function LN(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 BN=/^structural:(clip|mask):(.+):(group|path|content)$/;function GN(t,e,n,r){let i=new yr,o=LN(t.shapes);for(let s of o.values()){let a=e===null||e.has(s.type),l=structuredClone(s);a&&l.state.children&&delete l.state.children;let c=Ut.fromSerialized(l);a||(c.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(c)}for(let s of t.sceneTree??[]){if(i.getNode(s.id))continue;let a=BN.exec(s.id);if(!a)continue;let[,l,c,u]=a,d=t.clipMaskGroups?.find(f=>f.type===l&&f.id===c),p={structural:!0};u==="group"&&d&&(p.clipMaskDefId=kt(d)),i.addNode(Ut.fromSerialized({id:s.id,type:`${l}-${u}-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 VN(t,e={}){let n=null,r=null;try{let i=structuredClone(t);i=ts(i),i=is(i),e.injectFault?.("migration"),i=rs(i),i=ns(i);let o=NN(i);os(i,"full-snapshot-restore",{includeWarnings:!1,ignoreError:u=>{let d=/^Duplicate shape id: "(.+)"$/.exec(u.message);return d?o.has(d[1]):!1}}),i=Ap(i),pl(i),DN(i),zN(i,e.rootFrame),Hb(i,{materializeClipMaskStructure:!0,preserveUnresolvedParents:!1});let s=os(i,"full-snapshot-restore").filter(u=>u.code!=="unavailable-shape-descriptor");e.injectFault?.("validation"),e.injectFault?.("normalization");let a=[],l=e.availableShapeTypes?new Set(e.availableShapeTypes):null;n=GN(i,l,s,a),e.injectFault?.("canonical-node-construction"),r=new kr(n),r.loadSections(i),e.injectFault?.("document-section-staging");let c=gi.own(r,e.identity);return c.assertCoherent(),{document:c,snapshot:structuredClone(i),diagnostics:Object.freeze(structuredClone(s)),unavailableNodeIds:Object.freeze([...a])}}catch(i){throw r?r.dispose():n?.dispose(),i}}var jN=["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"],Y=t=>({mode:"supported",by:t}),fr=t=>({mode:"diagnostic",signal:"warning",by:t}),ce=t=>({mode:"outside-contract",reason:t}),qe=t=>t,Wb=ce("DXF is a static CAD geometry contract and has no representation for this SVG behavior."),Kb=ce("Mermaid is a static graph-structure contract and has no representation for this SVG behavior."),Xb=ce("PDF export produces a static page from the current editor SVG projection and does not promise animation playback."),UN={"unknown-shape-diagnostic":qe({renderToSvg:fr("renderShape reports UNSUPPORTED_SHAPE_TYPE through renderToSvgWithDiagnostics"),codegen:fr("buildRenderPlan carries UNSUPPORTED_SHAPE_TYPE into generateCodeWithDiagnostics"),dxf:fr("DxfExportStats records unsupported types and the DXF export UI reports them"),mermaid:fr("exportMermaidWithDiagnostics records unsupported nodes and both Mermaid UIs report them"),pdf:ce("PDF conversion consumes an already-projected editor SVG; unknown model nodes never enter its input."),"editor-dom":ce("Unknown nodes are preserved for round-trip but require a registered shape implementation for projection.")}),"symbol-variants-overrides":qe({renderToSvg:Y("buildRenderPlan materializes symbol variants and per-instance overrides before emission"),codegen:Y("every component backend consumes buildRenderPlan symbol materialization"),dxf:fr("DXF unsupported-shape accounting reports symbol instances without a lowering"),mermaid:fr("Mermaid node-skip diagnostics report symbol instances without a lowering"),pdf:Y("the editor projects SymbolInstance content into the SVG consumed by svg2pdf"),"editor-dom":Y("SymbolInstance projects resolved library variants and overrides")}),"smil-timeline":qe({renderToSvg:Y("buildRenderPlan injects renderAnimationElements output into shape markup"),codegen:Y("component backends preserve SMIL children in planned shape markup"),dxf:Wb,mermaid:Kb,pdf:Xb,"editor-dom":Y("AnimationManager and the shared SMIL kernel project live playback")}),"motion-only-partition":qe({renderToSvg:Y("buildRenderPlan diverts motionOnly templates into defs outside visible paint"),codegen:Y("component backends consume the render plan visible and motion-def partitions"),dxf:Wb,mermaid:Kb,pdf:Xb,"editor-dom":ce("The authoring DOM retains motion templates for editing instead of applying export partitioning.")}),"paint-server-references":qe({renderToSvg:Y("plan defs and shapes use one library-first paint-server reference resolver"),codegen:Y("buildShapeAttrs and plan defs use the library-first reference resolver"),dxf:ce("DXF promises geometry and basic entity colors, not SVG paint-server definition graphs."),mermaid:ce("Mermaid graph syntax has no SVG gradient or pattern paint-server model."),pdf:Y("the cloned SVG carries paint-server definitions and references into svg2pdf"),"editor-dom":Y("GradientManager maintains live defs matching shape paint references")}),"filter-references":qe({renderToSvg:Y("renderFilterDefs and filterReferenceValue emit matching identifiers"),codegen:Y("planned filter defs and buildShapeAttrs share filter reference resolution"),dxf:ce("DXF entity geometry has no SVG filter graph or filter-reference representation."),mermaid:ce("Mermaid graph syntax has no SVG filter graph or filter-reference representation."),pdf:Y("the cloned SVG carries filter definitions and references into svg2pdf"),"editor-dom":Y("FilterManager maintains live filter definitions and shape references")}),"document-definition-context":qe({renderToSvg:Y("buildRenderPlan consumes the full snapshot definition and style context"),codegen:Y("component codegen accepts snapshot context and clipboard supplies its definitions"),dxf:ce("DXF consumes resolved shapes and does not serialize SVG document definition sections."),mermaid:ce("Mermaid consumes graph nodes and does not serialize SVG definition sections."),pdf:Y("PDF receives a cloned SVG document with its referenced definition context"),"editor-dom":Y("the document aggregate and managers project referenced resources into defs")}),"inline-child-containers":qe({renderToSvg:Y("renderShape recursively renders INLINE_CHILD_CONTAINER_TYPES children"),codegen:Y("component backends preserve recursively rendered plan container markup"),dxf:Y("DXF walks INLINE_CHILD_CONTAINER_TYPES with transforms and cycle guards"),mermaid:fr("unsupported container nodes are counted by exportMermaidWithDiagnostics"),pdf:Y("the cloned editor SVG preserves nested containers for svg2pdf"),"editor-dom":Y("registered containers project managed children into nested SVG elements")}),"isolated-flowchart-nodes":qe({renderToSvg:ce("Isolated-node declarations are a Mermaid graph concern, not an SVG branch."),codegen:ce("Isolated-node declarations are a Mermaid graph concern, not component SVG output."),dxf:ce("DXF emits geometry independently and has no connector-enrolment requirement."),mermaid:Y("exportMermaid declares mapped nodes before emitting connector edges"),pdf:ce("PDF paints SVG geometry independently and has no graph-node declaration requirement."),"editor-dom":ce("The live SVG projects shapes independently and has no graph-node declaration requirement.")}),"text-path":qe({renderToSvg:Y("renderText emits textPath markup and its referenced path definition"),codegen:Y("component backends preserve planned textPath markup and definitions"),dxf:ce("DXF text entities do not reproduce SVG textPath layout along arbitrary paths."),mermaid:ce("Mermaid labels do not reproduce SVG textPath layout along arbitrary paths."),pdf:fr("ExportPanel.generatePdfBlob detects textPath content and shows its localized warning"),"editor-dom":Y("Text projects textPath attributes and maintains its referenced path")}),"common-presentation":qe({renderToSvg:Y("commonAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),codegen:Y("buildShapeAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),dxf:ce("DXF is not an SVG presentation-attribute serialization contract."),mermaid:ce("Mermaid is not an SVG presentation-attribute serialization contract."),pdf:Y("svg2pdf consumes common presentation attributes from the cloned SVG"),"editor-dom":Y("COMMON_PROP_RENDERERS derives its dispatch from PRESENTATION_SEMANTICS")}),"gradient-definition-envelope":qe({renderToSvg:Y("gradient renderers serialize the shared typed definition envelopes"),codegen:Y("render plan defs contain gradients serialized from shared typed envelopes"),dxf:ce("DXF has no SVG linearGradient or radialGradient definition envelope."),mermaid:ce("Mermaid has no SVG linearGradient or radialGradient definition envelope."),pdf:Y("the cloned SVG supplies shared-envelope gradient definitions to svg2pdf"),"editor-dom":Y("GradientManager projects shared gradient envelopes into live defs")}),"filter-definition-envelope":qe({renderToSvg:Y("renderFilterElement serializes filterDefinitionEnvelope for each wrapper kind"),codegen:Y("render plan defs contain filters serialized from shared typed envelopes"),dxf:ce("DXF has no SVG filter element or primitive graph envelope representation."),mermaid:ce("Mermaid has no SVG filter element or primitive graph envelope representation."),pdf:Y("the cloned SVG supplies shared-envelope filter definitions to svg2pdf"),"editor-dom":Y("FilterManager projects filterDefinitionEnvelope before primitive emission")}),"export-precision-rounding":qe({renderToSvg:Y("finalizeRenderPlan rounds markup coordinates at the effective documentMetadata.coordinatePrecision"),codegen:ce("Codegen backends consume the un-finalized render plan; component output precision is a code-style concern, not an export boundary."),dxf:ce("DXF numeric precision is owned by the DXF writer, not the SVG export boundary."),mermaid:ce("Mermaid emits graph syntax rather than SVG coordinate attribute streams."),pdf:Y("PDF viewbox pages consume the plan-assembled string (core rounding); selection pages pass through SvgExportFinalizer.roundSvgAttributes"),"editor-dom":Y("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":qe({renderToSvg:Y("finalizeRenderPlan collapses content-identical gradient/pattern/marker defs and rewrites references"),codegen:ce("Codegen backends consume the un-finalized render plan; def duplication in generated components is a code-size concern outside the export contract."),dxf:ce("DXF output has no shared-definition graph in which duplicates could exist."),mermaid:ce("Mermaid output has no shared-definition graph in which duplicates could exist."),pdf:Y("PDF viewbox pages consume the plan-assembled string (core dedup); selection pages pass through SvgExportFinalizer.deduplicateDefsForExport"),"editor-dom":Y("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":qe({renderToSvg:Y("finalizeRenderPlan restores uncontested library sourceIds and rewrites references"),codegen:ce("Generated components keep collision-safe runtime ids; source ids are a document round-trip concern."),dxf:ce("DXF entities carry no SVG id namespace for source ids to be restored into."),mermaid:ce("Mermaid nodes carry no SVG id namespace for source ids to be restored into."),pdf:ce("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":Y("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":qe({renderToSvg:Y("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:Y("component backends consume the same demand-driven plan def channels"),dxf:ce("DXF output has no defs graph from which orphans could need excluding."),mermaid:ce("Mermaid output has no defs graph from which orphans could need excluding."),pdf:Y("the editor SVG consumed by svg2pdf passes through pruneOrphanedDefs"),"editor-dom":Y("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":qe({renderToSvg:Y("finalizeRenderPlan ships @font-face CSS from the injected resolveFontEmbedCss hook (core is platform-free; binary resolution is the caller environment responsibility)"),codegen:ce("Generated components inherit the host page font pipeline; embedding binaries in component source is out of contract."),dxf:ce("DXF text styling is font-name based; the format has no font binary embedding."),mermaid:ce("Mermaid delegates font resolution entirely to the rendering host page."),pdf:Y("svg2pdf consumes the editor SVG after embedFontsInClone inlined @font-face CSS"),"editor-dom":Y("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":qe({renderToSvg:Y("finalizeRenderPlan drops redundant spec initials and product defaults under an initial-valued cascade (elideInitialValuesInPlan)"),codegen:ce("Codegen backends consume the un-finalized plan; explicit values in component source are a readability choice, not an export-boundary concern."),dxf:ce("DXF entities carry explicit CAD attributes with no SVG initial-value cascade."),mermaid:ce("Mermaid emits graph syntax; SVG presentation initial values never appear in its output."),pdf:Y("PDF viewbox pages consume the plan-assembled string (core elision); selection pages pass through SvgExportFinalizer.stripDefaultPaintAttributes"),"editor-dom":Y("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":qe({renderToSvg:Y("finalizeRenderPlan declares used prefixes on the root via a well-known URI table (declareUsedNamespacePrefixes); unresolvable prefixes warn undeclarable-namespace-prefix"),codegen:ce("Generated components render into a host document whose framework owns namespace handling; JSX/Vue templates have no xmlns declaration surface to complete."),dxf:ce("DXF is not XML and has no namespace prefixes to declare or complete."),mermaid:ce("Mermaid graph syntax is not XML; no namespace declarations exist."),pdf:Y("svg2pdf consumes the editor SVG string whose serializer declared every namespace it uses"),"editor-dom":Y("static string exports complete declarations through core declareUsedNamespacePrefixes; the raster/selection clone sinks rely on XMLSerializer plus hoistForeignNamespaceDecls")})};function Ur(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}async function Mp(t,e,n,r){let i=t[e];typeof i=="string"&&(t[e]=await r(i,n))}async function Np(t,e){Ur(t)&&await Mp(t,"svgContent","svgMarkup",e)}async function Op(t,e){if(!Ur(t))return;await Mp(t,"href","href",e),await Np(t.fillGradient,e),await Np(t.strokeGradient,e);let n=t.children;if(Array.isArray(n))for(let r of n)Ur(r)&&await Op(r.state,e)}async function HN(t,e){if(!Ur(t))return;let n=t.shapes;if(Array.isArray(n))for(let o of n)Ur(o)&&await Op(o.state,e);let r=t.library;if(Array.isArray(r))for(let o of r)Ur(o)&&o.kind==="pattern"&&await Np(o.pattern,e);let i=t.customPatterns;if(Array.isArray(i))for(let o of i)Ur(o)&&await Mp(o,"svgContent","svgMarkup",e)}function Dp(t,e={}){let{indent:n=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=Br(t);if(!a.valid){let l=a.errors.map(c=>` ${c.path}: ${c.message}`).join(`
35
+ `);throw new Error(`Invalid document:
36
+ ${l}`)}}let o={};for(let a of Rp){let l=a==="unknownFields"?Pp(t):t[a];l!==void 0&&(o[a]=WN(St[a].serialization,l))}let s=JSON.stringify(o,null,n);return r?s+`
37
+ `:s}function WN(t,e){switch(t.kind){case"verbatim":return e;case"shape-array":return e.map(n=>YN(oc(structuredClone(n))));case"id-sorted-array":return XN(e).map(Ui);case"ordered-array":return e.map(Ui);case"deep-sorted-object":case"unknown-bag":return Ui(e);default:return KN(t)}}function KN(t){throw new Error(`Unhandled serialization kind: ${JSON.stringify(t)}`)}function zp(t,e={}){return Yb(t,e).value}function Yb(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=ts(o),r&&(o=is(o),o=rs(o)),o=ns(o);let s=[];return n&&s.push(...os(o,"native-document-open")),{value:o,diagnostics:s}}function XN(t){return[...t].sort((e,n)=>e.id.localeCompare(n.id))}function Ui(t){if(t==null)return t;if(Array.isArray(t))return t.map(Ui);if(typeof t!="object")return t;let e={},n=Object.keys(t).sort();for(let r of n)e[r]=Ui(t[r]);return e}function YN(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]=Ui(t[r]);return e}var un=/\{\{\s*([\w.\-]+)\s*\}\}/g;function _p(t,e){return t.replace(un,(n,r)=>{let i=e[r];return i!==void 0?String(i):n})}function fl(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 Fp(r,n),r}function Fp(t,e){for(let n of Object.keys(t)){let r=t[n];if(typeof r=="string"){if(un.lastIndex=0,un.test(r)){un.lastIndex=0;let i=_p(r,e);if(qN(r)){let o=Number(i);if(!isNaN(o)&&JN(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"?(un.lastIndex=0,un.test(r[i])&&(un.lastIndex=0,r[i]=_p(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&Fp(r[i],e);else r!==null&&typeof r=="object"&&Fp(r,e)}}function qN(t){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(t)}var ZN=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...hs,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function JN(t){return ZN.has(t)}function Bp(t){let e=t.templateVariables??[],n=new Set(e.map(o=>o.name)),r=new Set;Lp(t,r);let i=[...r].filter(o=>!n.has(o)).sort();return{defined:[...e],undeclared:i}}function Lp(t,e){for(let n of Object.values(t))if(typeof n=="string"){let r;for(un.lastIndex=0;(r=un.exec(n))!==null;)e.add(r[1])}else if(Array.isArray(n))for(let r of n)if(typeof r=="string"){let i;for(un.lastIndex=0;(i=un.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&Lp(r,e);else n!==null&&typeof n=="object"&&Lp(n,e)}function QN(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 ml=3,Gp=12;function Vp(t){return t==null||!Number.isFinite(t)?ml:t<0?0:t>Gp?Gp:Math.floor(t)}function In(t,e){if(!Number.isFinite(t))return t;let n=Math.pow(10,e);return Math.round(t*n)/n}var eM=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function gl(t,e){return t.replace(eM,n=>{let r=parseFloat(n);return Number.isFinite(r)?String(In(r,e)):n})}var tM=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),nM=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function Hr(t,e,n){if(e==null)return e;if(typeof e=="number")return In(e,n);if(typeof e=="string")return tM.has(t)?gl(e,n):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Hr(t,r,n));if(typeof e=="object"){if(nM.has(t))return e;if(t==="symbolOverrides"){let i={};for(let[o,s]of Object.entries(e))i[o]=Hr("state",s,n);return i}let r={};for(let[i,o]of Object.entries(e))r[i]=Hr(i,o,n);return r}return e}function qb(t,e){return{id:t.id,type:t.type,state:Hr("state",t.state,e)}}function rM(t,e){let n=t,r={...n};for(let i of Object.keys(St)){let o=n[i];if(o!==void 0)switch(St[i].precision){case"opaque":break;case"numeric-leaves":r[i]=Hr(i,o,e);break;case"animation-timeline":r[i]=iM(o,e);break;case"shape-trees":r[i]=oM(i,o,e);break}}return r}function iM(t,e){return{...t,tracks:t.tracks.map(n=>({...n,...n.motionPathMatrix?{motionPathMatrix:n.motionPathMatrix.map(r=>In(r,e))}:{},...n.ancestorMatrix?{ancestorMatrix:n.ancestorMatrix.map(r=>In(r,e))}:{},...n.transformOrigin?{transformOrigin:{x:In(n.transformOrigin.x,e),y:In(n.transformOrigin.y,e)}}:{},...n.pasteOffset?{pasteOffset:{x:In(n.pasteOffset.x,e),y:In(n.pasteOffset.y,e)}}:{},...typeof n.motionRotate=="number"?{motionRotate:In(n.motionRotate,e)}:{},keyframes:n.keyframes.map(r=>({...r,value:Hr("value",r.value,e)}))}))}}function oM(t,e,n){return Array.isArray(e)?t==="shapes"?e.map(r=>qb(r,n)):e.map(r=>Hr("libraryDef",r,n)):e}function sM(t){return{text:t.text,style:{...t.style}}}function hl(t){return{segments:[{text:"",style:t}]}}function aM(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 lM(t,e){if(e<=0)return t;let n=t.width-e*2;return n>0?{x:t.x+e,width:n}:null}function Zb(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 Jb(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 cM(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),l=[],c=[],u=new Map,d=x=>{if(!s)return t.inlineSize;let P=t.baseStyle.fontSize*t.lineHeight,T=s.bounds.minY+t.baseStyle.fontSize+x*P;if(T>s.bounds.maxY)return c.push(s.bounds.minX),0;let k=Math.round(T*256),w=u.get(k);if(w===void 0){let $=s.getSpanAtY(T);w=$?lM($,a):null,u.set(k,w)}return w?(c.push(w.x),w.width):(c.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 P of aM(t.lines[x])){let T=/^\s+$/.test(P.text);p.push({text:n&&T?" ":P.text,style:P.style,modelLen:P.text.length,isHardBreak:!1,isWhitespace:T})}}if(n)for(let x=p.length-1;x>0;x--){let P=p[x],T=p[x-1];P.isWhitespace&&!P.isHardBreak&&T.isWhitespace&&!T.isHardBreak&&(T.modelLen+=P.modelLen,p.splice(x,1))}let f=[],g=[],m=0,h=0,b=[],S=0,v=d(0),I=!0;for(let x of p){if(x.isHardBreak){b.length===0&&(g.push(m),h++,s&&c.length<=l.length&&d(l.length)),f.push(h),m++,l.push(b.length>0?{segments:b}:hl(t.baseStyle)),b=[],S=0,v=d(l.length),I=!0;continue}if(n&&x.isWhitespace&&I){for(let k=0;k<x.modelLen;k++)f.push(-1),m++;continue}let P=Zb(e,x.text,x.style);if(i&&v>0&&S+P>v&&S>0&&(o&&(Jb(b,f,g,h),h=g.length),l.push(b.length>0?{segments:b}:hl(t.baseStyle)),b=[],S=0,v=d(l.length),I=!0,x.isWhitespace)){for(let k=0;k<x.modelLen;k++)f.push(-1),m++;continue}if(i&&v>0&&P>v&&t.overflowWrap!=="normal"){for(let w of x.text){let $=Zb(e,w,x.style);S+$>v&&S>0&&(l.push(b.length>0?{segments:b}:hl(t.baseStyle)),b=[],S=0,v=d(l.length)),f.push(h),g.push(m),m++,h++;let R=b[b.length-1];R&&Un(R.style,x.style)?b[b.length-1]={...R,text:R.text+w}:b.push({text:w,style:{...x.style}}),S+=$}let k=x.modelLen-x.text.length;for(let w=0;w<k;w++)f.push(-1),m++;I=!1;continue}for(let k of x.text)f.push(h),g.push(m),m++,h++;for(let k=x.text.length;k<x.modelLen;k++)f.push(-1),m++;let T=b[b.length-1];T&&Un(T.style,x.style)?b[b.length-1]={...T,text:T.text+x.text}:x.text&&b.push(sM(x)),S+=P,I=!1}return n&&b.length>0&&Jb(b,f,g,h),b.length===0&&p.length===0&&g.push(m),l.push(b.length>0?{segments:b}:hl(t.baseStyle)),{lines:l,modelToSvgMap:f,svgToModelMap:g,shapeInsideLineXOffsets:c}}var yl=class{constructor(e){this.measurementHost=e}measurementHost;layout(e){return cM(e,this.measurementHost)}};var Up=["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"],Hi=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]}},jp=[];function Sl(t,e){jp.push(t);try{return e()}finally{jp.pop()}}function Tt(t){for(let e of jp)e.report(t)}var bl="0 0 10 10",Hp=6,Wp=6;function Wi(){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 vl={"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"},dM={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function uM(){return Wi().map(t=>{let e=vl[t.id]??t.id;return{kind:"marker",id:e,name:dM[e]??e,viewBox:bl,refX:t.refX,refY:t.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function xl(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 pM=[["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 ss(t){return pM.map(([e,n])=>{let r=t[e],i=typeof r=="string"?r.trim():"";return i?`${n}: ${i}`:""}).filter(Boolean).join("; ")}function Kp(t,e){let n=[],r=(a,l)=>{l!==""&&n.push({name:a,value:l})};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=ss(t);i&&i!==ss(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 as(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 N(t,e){return e==null||e===""?"":` ${t}="${ue(String(e))}"`}function tv(t){let e=Ip(t);return e.pivotRequired&&!e.pivotResolved&&Tt({severity:"warning",code:"unresolved-container-pivot",shapeId:t.id,message:`Container ${t.id} has legacy 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 vt(t,e){let n=Zt(t);if(!n||n.kind!==e)throw new Error(`Shape geometry registry mismatch for ${t.type}: expected ${e}`);return n}function Ki(t,e){return e==null?"":` ${t}="${ue(e)}"`}function fM(t){let e=t.map(n=>(n??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?N("style",e):""}function mM(t,e){return typeof e=="number"&&e>0?`${t}: ${e}px`:""}function gM(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 Qb(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 ev(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 hM(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 wn(t,e){return gt(t,e)}function yM(t,e,n){return Yg(t,e,n)}function SM(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 Qt(t,e,n=[]){return N("data-shape-id",e)+nv(Vo(ur(t),{shapeId:e}),n)}function nv(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?Ki(o.name,String(o.value)):N(o.name,o.value);return(e.length>0||i.size>0)&&(n+=fM([...e,...[...i].map(([o,s])=>`${o}: ${s}`)])),n}var bM=new Set(["element-opacity","system-language","required-extensions","visibility","display","metadata","container-presentation","authored-attributes"]);function wl(t){let e=t.metadata;return Fi(e)}function vM(t,e){let n=wl(e);if(!n)return t;let r=as(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 xM(t,e){if(e.length===0)return t;let n=e.join(""),r=as(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 l=o.lastIndexOf(`</${a[1]}>`);return i+o.slice(0,l)+n+o.slice(l)}function Xp(t){let e="",n=t.startEndpoint,r=t.endEndpoint;return n&&n!=="none"&&!t.markerStart&&(e+=N("marker-start",`url(#line-marker-${n})`)),r&&r!=="none"&&!t.markerEnd&&(e+=N("marker-end",`url(#line-marker-${r})`)),e}function rv(t){let e=t.state,{cx:n,cy:r,r:i,defaultPivot:o}=vt(t,"circle"),s=wn(e,o??void 0);return`<circle${N("cx",n)}${N("cy",r)}${N("r",i)}${Qt(e,t.id)}${s?N("transform",s):""}/>`}function iv(t){let e=t.state,{cx:n,cy:r,rx:i,ry:o,pathLength:s,defaultPivot:a}=vt(t,"ellipse"),l=wn(e,a??void 0);return`<ellipse${N("cx",n)}${N("cy",r)}${N("rx",i)}${N("ry",o)}${s!==void 0?N("pathLength",s):""}${Qt(e,t.id)}${l?N("transform",l):""}/>`}function ov(t){let e=t.state,{x:n,y:r,width:i,height:o,rx:s,ry:a,pathData:l,defaultPivot:c}=vt(t,"rectangle"),u=wn(e,c??void 0);return l?`<path${N("d",l)}${Qt(e,t.id)}${u?N("transform",u):""}/>`:`<rect${N("x",n)}${N("y",r)}${N("width",i)}${N("height",o)}${s>0||a>0?`${N("rx",s)}${N("ry",a)}`:""}${Qt(e,t.id)}${u?N("transform",u):""}/>`}function sv(t){let e=t.state,{x1:n,y1:r,x2:i,y2:o,defaultPivot:s}=vt(t,"line"),a=wn(e,s??void 0),l={...e,fillType:"none"};return`<line${N("x1",n)}${N("y1",r)}${N("x2",i)}${N("y2",o)}${Qt(l,t.id)}${Xp(e)}${a?N("transform",a):""}/>`.replace(' fill="none"',"")}function av(t,e){let n=t.state,{x:r,y:i,defaultPivot:o}=vt(t,"text"),s=xl(n.text??"",n.textTransform),a=n.fontSize??16,l=n.fontFamily??"sans-serif",c=n.fontWeight??"normal",u=n.fontStyle??"normal",d=n.textAnchor??"start",p=SM(n.textDecoration),f=n.letterSpacing,g=n.wordSpacing,m=n.lineHeight??1.25,h=wn(n,o??void 0),S=n.isTextPath&&n.textPathPoints?"":N("x",r)+N("y",i);S+=N("font-size",a),S+=N("font-family",l),c!=="normal"&&c!=="400"&&(S+=N("font-weight",c)),u!=="normal"&&(S+=N("font-style",u)),d!=="start"&&(S+=N("text-anchor",d)),p&&(S+=N("text-decoration",p)),f&&(S+=N("letter-spacing",f)),g&&(S+=N("word-spacing",g));let v=n.baselineShift;v&&v!=="baseline"&&(S+=N("baseline-shift",v));let I=n.dominantBaseline;I&&I!=="auto"&&(S+=N("dominant-baseline",I));let x=n.writingMode;x&&x!=="horizontal-tb"&&(S+=N("writing-mode",x));let P=n.textLength;P!==void 0&&P>0&&(S+=N("textLength",P),n.lengthAdjust==="spacingAndGlyphs"&&(S+=N("lengthAdjust","spacingAndGlyphs")));let T=n.textDirection;T&&T!=="ltr"&&(S+=N("direction",T));let k=n.unicodeBidi;k&&k!=="normal"&&(S+=N("unicode-bidi",k));let w=n.shapeInsideRef,$="",R="";if(w){$=`shape-inside: url(#${e?.shapeInsideTargetElementId?.(w)??w})`;let V=n.shapePadding;V!==void 0&&V>0&&(R=`shape-padding: ${V}`)}let C=ss(n),A=n.fontVariationSettings,D="";A&&Object.keys(A).length>0&&(D=`font-variation-settings: ${Object.entries(A).map(([V,H])=>`'${V}' ${H}`).join(", ")}`);let _=n.inlineSize!==void 0||w!==void 0||typeof n.overflowWrap=="string",O=typeof n.lineHeight=="number"&&n.lineHeight!==1.2,L=[C,D,mM("inline-size",n.inlineSize),$,R,typeof n.overflowWrap=="string"?`overflow-wrap: ${n.overflowWrap}`:"",typeof n.whiteSpace=="string"?`white-space: ${n.whiteSpace}`:"",_&&O?`line-height: ${n.lineHeight}`:""];if(S+=Qt(n,t.id,L),h&&(S+=N("transform",h)),n.isTextPath&&n.textPathPoints){let F=n.textPathPoints,V=n.textPathStartOffset??0,H=n.textPathSide,X=`text-path-${t.id}`,z=n.textPathMethod,G=n.textPathSpacing,q=n.textPathLengthAdjust,te=n.textPathLength,ie="";if(F.length>=2)if(H==="right"){let J=F[F.length-1];ie=`M ${J.x} ${J.y}`;for(let ke=F.length-1;ke>0;ke--){let Fe=F[ke],Le=F[ke-1],Ze=Fe.handleIn??Fe,wt=Le.handleOut??Le;ie+=` C ${Ze.x} ${Ze.y} ${wt.x} ${wt.y} ${Le.x} ${Le.y}`}}else{ie=`M ${F[0].x} ${F[0].y}`;for(let J=0;J<F.length-1;J++){let ke=F[J],Fe=F[J+1],Le=ke.handleOut??ke,Ze=Fe.handleIn??Fe;ie+=` C ${Le.x} ${Le.y} ${Ze.x} ${Ze.y} ${Fe.x} ${Fe.y}`}}return`<defs><path id="${ue(X)}"${N("d",ie)} fill="none"/></defs><text${S}><textPath href="#${ue(X)}"${N("startOffset",`${V}%`)}${N("method",z)}${N("spacing",G)}${N("lengthAdjust",q)}${N("textLength",te)}>${ue(s)}</textPath></text>`}if(n.charOffsets&&Array.isArray(n.charOffsets)&&n.charOffsets.length>0){let F=n.charOffsets.map(gM),V=s.split(`
38
+ `),H=n.linePositions??[],X=a*m,z="",G=0;return V.forEach((q,te)=>{let ie=Array.from(q).length,J=F.slice(G,G+ie),ke=H[te],Fe=ke?r+ke.x:te>0?r:NaN,Le=ke?ke.dy:te>0?X:NaN,Ze="",wt=Qb(J,"x");if(Number.isFinite(Fe)||wt.length>0){let pt=wt.length>0?wt.slice():[];Number.isFinite(Fe)&&(pt[0]=pt[0]??Fe),Ze+=N("x",pt.join(" "))}let to=Qb(J,"y");to.length>0&&(Ze+=N("y",to.join(" ")));let B=ev(J,"dx");B.length>0&&(Ze+=N("dx",B.join(" ")));let ve=ev(J,"dy"),Re=ve.length>0||Number.isFinite(Le)?ve.slice():[];for(Number.isFinite(Le)&&(Re[0]=(Re[0]??0)+Le);Re.length>0&&Re[Re.length-1]===0;)Re.pop();Re.length>0&&(Ze+=N("dy",Re.join(" ")));let nt=hM(J);nt.length>0&&(Ze+=N("rotate",nt.join(" "))),z+=`<tspan${Ze}>${ue(q)}</tspan>`,G+=ie+1}),`<text${S}>${z}</text>`}let ee=di(n);if(ee){let F=Hn(ee),V=e?.textShapeInsideGeometry?.(t)??null,X=!!e?.textMeasurementHost&&(typeof n.inlineSize=="number"||V!==null||n.whiteSpace==="normal"||n.whiteSpace==="nowrap"||n.whiteSpace==="pre-line")?new yl(e.textMeasurementHost).layout({lines:F.lines,baseStyle:F.baseStyle,lineHeight:F.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:V,shapePadding:typeof n.shapePadding=="number"?n.shapePadding:0}):null,z=X?.lines??F.lines,G=n.linePositions,q=a*F.lineHeight,te="";return z.forEach((ie,J)=>{ie.segments.forEach((ke,Fe)=>{let Le="";if(Fe===0){let Ze=X?.shapeInsideLineXOffsets[J];if(V&&Ze!==void 0)Le+=N("x",Ze),Le+=N("y",V.bounds.minY+a+J*q);else if(G?.[J]){let wt=G[J];(Math.abs(wt.x)>.001||J>0)&&(Le+=N("x",r+wt.x)),(Math.abs(wt.dy)>.001||J>0)&&(Le+=N("dy",wt.dy))}else J>0&&(Le+=N("x",r),Le+=N("dy",`${q}px`))}for(let{name:Ze,value:wt}of Kp(ke.style,F.baseStyle))Le+=N(Ze,wt);Le+=' xml:space="preserve"',te+=`<tspan${Le}>${ue(xl(ke.text||(X?"\u200B":""),ke.style.textTransform))}</tspan>`})}),`<text${S}>${te}</text>`}return`<text${S}>${ue(s)}</text>`}function lv(t){let e=t.state,n=vt(t,"path"),r=n.defaultPivot?wn(e,n.defaultPivot):null;return`<path${N("d",n.d)}${Qt(e,t.id)}${Xp(e)}${r?N("transform",r):""}/>`}function cv(t){let e=t.state,{points:n,closed:r,defaultPivot:i}=vt(t,"polyline"),o=n.map(l=>`${l.x},${l.y}`).join(" "),s=i?wn(e,i):null;return`<${r?"polygon":"polyline"}${N("points",o)}${Qt(e,t.id)}${Xp(e)}${s?N("transform",s):""}/>`}function dv(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=vt(t,"positioning-rect"),a=e.href??"",l=e.imageOpacity,c=e.specPreserveAspectRatio||(e.preserveAspectRatio?"xMidYMid meet":"none"),u=wn(e,s??void 0);return`<image${N("x",n)}${N("y",r)}${N("width",i)}${N("height",o)}${N("href",a)}${N("preserveAspectRatio",c)}${l!==void 0&&l<1?N("opacity",l):""}${Qt(e,t.id)}${u?N("transform",u):""}/>`}function uv(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=vt(t,"positioning-rect"),a=e.rawContent??"",l=wn(e,s??void 0);return`<foreignObject${N("x",n)}${N("y",r)}${N("width",i)}${N("height",o)}${Qt(e,t.id)}${l?N("transform",l):""}>${a}</foreignObject>`}function kl(t,e){return!t||t.length===0?"":t.map(n=>pn(n,e)).join("")}function pv(t){let e=t.state,n="",r=ur(e),i=Wa.filter(o=>bM.has(o.id)).flatMap(o=>Mu(o,r,{shapeId:t.id,includeAuthoredAttributes:!0,includeContainerPresentation:!0}));return n+=nv(i),n}function fv(t){let e=tv(t);return(e?N("transform",e):"")+pv(t)}function IM(t,e){let n=t.state,r=n.href,i=n.hrefXlink,o="<a";return r!==void 0&&(o+=N("href",r)),i!==void 0&&(o+=N("xlink:href",i)),o+=N("target",n.linkTarget),o+=N("rel",n.linkRel),n.linkDownload===""?o+=' download=""':o+=N("download",n.linkDownload),o+=N("ping",n.linkPing),o+=N("hreflang",n.linkHreflang),o+=N("type",n.linkType),o+=N("referrerpolicy",n.linkReferrerPolicy),o+=fv(t),o+=N("data-shape-id",t.id),o+=">",o+=wl(n),o+=kl(n.children,e),o+="</a>",o}function wM(t,e){let n=t.state,r="<switch";return r+=Ki("systemLanguage",n.switchSystemLanguage),r+=Ki("requiredExtensions",n.switchRequiredExtensions),r+=fv(t),r+=N("data-shape-id",t.id),r+=">",r+=wl(n),r+=kl(n.children,e),r+="</switch>",r}function kM(t,e){let n=t.state,r=tv(t),i="<g";i+=N("data-shape-id",t.id),r&&(i+=N("transform",r)),n.opacity!==void 0&&n.opacity<1&&(i+=N("opacity",n.opacity)),n.visibility&&(i+=N("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+=N("clip-path",a.clipPath)),a.mask&&(i+=N("mask",a.mask)),a.filter&&(i+=N("filter",a.filter)),a.fill&&(i+=N("fill",a.fill)),a.fillOpacity&&(i+=N("fill-opacity",a.fillOpacity)),a.strokeOpacity&&(i+=N("stroke-opacity",a.strokeOpacity)),a.opacity&&n.opacity===void 0&&(i+=N("opacity",a.opacity)),Array.isArray(a.classes)&&a.classes.length>0&&(i+=N("class",a.classes.join(" "))),a.attributes)for(let[l,c]of Object.entries(a.attributes))/^[A-Za-z_][\w:.-]*$/.test(l)&&(i+=N(l,c));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+=N("style",s.join(";"))),i+=">",i+=kl(n.children,e),i+="</g>",i}function RM(t){let e=t.state,n=vt(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,l="<view";return l+=N("id",t.id),l+=N("viewBox",a),l+=N("preserveAspectRatio",n.preserveAspectRatio),l+=N("zoomAndPan",e.viewZoomAndPan),l+=N("viewTarget",e.viewTarget),e.viewName&&(l+=N("data-view-name",e.viewName)),l+="/>",l}function TM(t,e){let n=t.state,r=vt(t,"embedded-svg"),i=jr(t);i.pivotRequired&&!i.pivotResolved&&Tt({severity:"warning",code:"unresolved-svg-viewport",shapeId:t.id,message:`Embedded SVG ${t.id} has legacy 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,l=r.height,c=r.viewBoxX,u=r.viewBoxY,d=r.viewBoxWidth,p=r.viewBoxHeight,f=c!==void 0&&u!==void 0&&d!==void 0&&p!==void 0?`${c} ${u} ${d} ${p}`:void 0,g="<svg";return g+=N("xmlns","http://www.w3.org/2000/svg"),g+=N("x",o),g+=N("y",s),g+=N("width",a),g+=N("height",l),g+=N("viewBox",f),r.preserveAspectRatio!==void 0&&(g+=Ki("preserveAspectRatio",r.preserveAspectRatio)),i.attribute&&(g+=N("transform",i.attribute)),g+=pv(t),g+=N("data-shape-id",t.id),g+=">",g+=wl(n),g+=kl(n.children,e),g+="</svg>",g}function PM(t,e){let n=t.state,r=vt(t,"shape-reference"),i=r.targetShapeId;if(!i?.trim())return Tt({severity:"warning",code:"unresolved-reference",shapeId:t.id,message:`Shape reference ${t.id} has no targetShapeId and was not rendered.`}),`<!-- shape-reference ${ue(t.id)} has no targetShapeId -->`;let o=r.offsetX,s=r.offsetY,a=e?.shapeReferenceTargetElementId?.(i);if(a===null)return Tt({severity:"error",code:"duplicate-shape-id",shapeId:t.id,message:`Shape reference ${t.id} targets ambiguous duplicate id ${i}.`}),`<!-- shape-reference ${ue(t.id)} has ambiguous target ${ue(i)} -->`;let l=a??i,c=e?.shapeReferenceBounds?.(t),u=c?.diagnostics.find(h=>h.code==="reference-cycle");if(u&&Tt({severity:"warning",code:"reference-cycle",shapeId:t.id,message:u.message}),c?.status==="cycle"&&c.bounds===null)return`<!-- cyclic shape-reference ${ue(t.id)} was not rendered -->`;let d=e?.shapeReferenceTransform?.(t),p=d?.pivotRequired??$t(t.state),f=d?.pivotResolved??!p;p&&!f&&Tt({severity:"warning",code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has legacy rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`});let g=d?.attribute??gt(t.state),m="<use";return m+=N("href",`#${l}`),m+=N("x",o),m+=N("y",s),r.width!==void 0&&(m+=N("width",r.width)),r.height!==void 0&&(m+=N("height",r.height)),m+=N("data-shape-id",t.id),g&&(m+=N("transform",g)),n.opacity!==void 0&&n.opacity<1&&(m+=N("opacity",n.opacity)),m+="/>",m}function mv(t,e){let n=t.state,r=vt(t,"symbol-instance"),i=e?.symbolInstanceTargetElementId?.(t),o=i===void 0?r.targetId:i;if(o===null)return`<!-- Invalid symbol instance: ${ue(t.id)} -->`;let s=e?.symbolDefKind?.(r.symbolId),a=`<use href="#${ue(o)}"`,l=n.authoredUseGeometry;l&&typeof l=="object"?(l.x!==void 0&&(a+=N("x",l.x)),l.y!==void 0&&(a+=N("y",l.y)),s!=="group"&&(l.width!==void 0&&(a+=N("width",l.width)),l.height!==void 0&&(a+=N("height",l.height)))):e?.legacySymbolNumericGeometry&&(a+=N("x",r.x),a+=N("y",r.y),s!=="group"&&(a+=N("width",r.width),a+=N("height",r.height))),a+=N("data-shape-id",t.id);let c=n.instancePresentation;if(c)for(let[m,h]of Object.entries(c))m!=="transform"&&(h==null||h===""||/^[A-Za-z_][\w:.-]*$/.test(m)&&(a+=N(m,h)));let u=e?.symbolInstanceTransform?.(t),d=gt(n),p=c?.transform?.trim(),f=p?d?`${p} ${d}`:p:d,g=u?.attribute??f;return g&&(a+=N("transform",g)),`${a}/>`}function CM(t){let e=t.state,n=vt(t,"positioning-rect"),r=e.mediaKind??t.type,i=e.href??"",o=e.mediaMimeType,s=e.posterHref,a=e.mediaOpacity,l=`<${r} xmlns="http://www.w3.org/1999/xhtml"`;l+=N("src",i),o&&(l+=N("type",o)),s&&r==="video"&&(l+=N("poster",s)),e.muted&&(l+=' muted=""'),e.loop&&(l+=' loop=""'),e.playbackRate!==void 0&&(l+=N("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(l+=N("data-volume",e.volume)),l+=' preload="auto" playsinline=""',l+=r==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let c="<foreignObject";return c+=N("x",n.x),c+=N("y",n.y),c+=N("width",n.width),c+=N("height",n.height),c+=N("data-shape-id",t.id),c+=N("data-media-kind",r),e.naturalDuration!==void 0&&(c+=N("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(c+=N("data-begin",e.begin)),e.trimStart!==void 0&&(c+=N("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(c+=N("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(c+=N("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(c+=N("data-fade-out",e.fadeOutDuration)),c+=Ki("systemLanguage",e.systemLanguage),c+=Ki("requiredExtensions",e.requiredExtensions),a!==void 0&&a<1&&(c+=N("opacity",a)),c+=">",c+=l,c+="</foreignObject>",c}function gv(t){let e=t.state,n=vt(t,"path"),r=n.defaultPivot?wn(e,n.defaultPivot):null;return`<path${N("d",n.d)}${Qt(e,t.id)}${r?N("transform",r):""}/>`}function hv(t){let e=t.state;if(Po(t.type)?.renderer!=="polygon")return Tt({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: ${ue(t.type)} -->`;let r=vt(t,"path"),i=r.placement??{x:0,y:0},o=yM(e,i.x,i.y),s=r.fillRule?N("fill-rule",r.fillRule):"";return`<path${N("d",r.d)}${s}${Qt(e,t.id)}${N("transform",o)}/>`}var $M={circle:rv,ellipse:iv,rectangle:ov,line:sv,text:av,path:lv,polyline:cv,image:dv,polygon:hv,flowchart:gv,hyperlink:IM,switch:wM,container:kM,view:RM,svg:TM,"shape-reference":PM,"symbol-instance":mv,media:CM,"foreign-object":uv};function pn(t,e){let n=Po(t.type);if(!n)return Tt({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: ${ue(t.type)} -->`;let r=$M[n.renderer](t,e);r=AM(r,t),r=vM(r,t.state),e?.forcedElementIds?.has(t.id)&&(r=yv(r,t.id));let i=e?.elementIdForShape?.(t);i&&(r=EM(r,i));let o=e?.animationElementsForShape?.(t);o&&o.length>0&&(r=xM(r,o));let s=t.state?.leadingComments;return Array.isArray(s)&&s.length>0&&(r=s.map(l=>`<!--${l.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")+r),r}function yv(t,e){let n=as(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)}${N("id",e)}${t.slice(i)}`}function EM(t,e){let n=as(t);if(!n)return t;let r=t.slice(n.openStart,n.openEnd),i=/\sid=("[^"]*"|'[^']*')/.exec(r);if(!i)return yv(t,e);let o=n.openStart+i.index;return`${t.slice(0,o)}${N("id",e)}${t.slice(o+i[0].length)}`}function AM(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,l="";for(let[c,u]of Object.entries(n))u===null||!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(c)||new RegExp(`\\s${c}\\s*=`).test(s)||(l+=` ${c}="${ue(u)}"`);return l?`<${o}${s}${l}${a}>`+t.slice(i.length):t}function NM(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=Ou(o),a=GS(o),l=o.strokeType??"solid",c=o.strokeGradient;if(s==="linear-gradient"&&a){let u=r(a)??`gradient-fill-${i.id}`;n.has(u)||(e+=ls(u,a),n.add(u))}if(s==="radial-gradient"&&a){let u=r(a)??`gradient-fill-${i.id}`;n.has(u)||(e+=cs(u,a),n.add(u))}if(s==="pattern"&&a){let u=r(a)??`pattern-fill-${i.id}`;n.has(u)||(e+=Il(u,a),n.add(u))}if(l==="linear-gradient"&&c){let u=r(c)??`gradient-stroke-${i.id}`;n.has(u)||(e+=ls(u,c),n.add(u))}if(l==="radial-gradient"&&c){let u=r(c)??`gradient-stroke-${i.id}`;n.has(u)||(e+=cs(u,c),n.add(u))}if(l==="pattern"&&c){let u=r(c)??`pattern-stroke-${i.id}`;n.has(u)||(e+=Il(u,c),n.add(u))}}return e}function ls(t,e,n){return Sv(Cu(t,e),n)}function cs(t,e,n){return Sv($u(t,e),n)}function Sv(t,e){let n=t.attributes.map(([o,s])=>N(o,s)).join(""),r=String(t.attributes.find(([o])=>o==="id")?.[1]??""),i=t.stops.map((o,s)=>{let a=o.attributes.map(([c,u])=>N(c,u)).join(""),l=e?.gradientStopAnimationElements?.(r,s)??[];return l.length>0?`<stop${a}>${l.join("")}</stop>`:`<stop${a}/>`}).join("");return`<${t.element}${n}>${i}</${t.element}>`}function Il(t,e){let n=Pu(t,e);return`<pattern${n.attributes.map(([i,o])=>N(i,o)).join("")}>${n.content}</pattern>`}function Yp(t,e=[]){let n=Array.isArray(t)?Ri(t,e):t;if(n.ids.size===0&&n.legacyEndpoints.size===0)return"";let r="",i=Wi();for(let o of i){let s=o.id,a=s.replace("line-marker-",""),l=`mkr-builtin-${a}`,c=n.legacyEndpoints.has(a)||n.ids.has(s),u=n.ids.has(l);if(!c&&!u)continue;let d=o.element,p=Object.entries(d.attrs).map(([m,h])=>N(m,h)).join(""),f=`<${d.tag}${p}/>`,g=m=>{r+=`<marker${N("id",m)}${N("viewBox",bl)}${N("refX",o.refX)}${N("refY",o.refY)}${N("markerWidth",6)}${N("markerHeight",6)}${N("orient","auto-start-reverse")}>${f}</marker>`};c&&g(s),u&&g(l)}return r}var xt=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function qp(t){let e=new Set,n=r=>{for(let i of Dn(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);return e}var xv=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Wr(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 Iv(t,e){switch(t.kind){case"symbol":return wv(t,e);case"marker":return kv(t,e);case"linear-gradient":return Rv(t,e);case"radial-gradient":return Tv(t,e);case"pattern":return Pv(t);case"filter":return Cv(t)}}function wv(t,e){return ds(t,t.id,t.shapes,e)}var bv=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function vv(t,e){let n=t.rootAttributes??{},r="";if(e)for(let i of bv){let o=t[i];o!==void 0&&(r+=` ${i}="${xt(o)}"`)}for(let[i,o]of Object.entries(n))i==="id"||bv.includes(i)||/^[A-Za-z_][\w:.-]*$/.test(i)&&(r+=` ${i}="${xt(o)}"`);return r}function ds(t,e,n,r){let i=Fi(t.metadata)+n.map(o=>pn(o,r)).join("");return(t.defKind??"symbol")==="group"?`<g id="${xt(e)}"${vv(t,!1)}>${i}</g>`:`<symbol id="${xt(e)}"${vv(t,!0)}>${i}</symbol>`}function kv(t,e){let n;if(t.builtIn){let a=Wi().find(l=>t.id.includes(l.id)||t.id===l.id);if(a){let l=Object.entries(a.element.attrs).map(([c,u])=>` ${c}="${xt(String(u))}"`).join("");n=`<${a.element.tag}${l}/>`}else n=""}else n=t.shapes.map(a=>pn(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="${xt(t.viewBox)}"`),t.preserveAspectRatio!==void 0&&(o+=` preserveAspectRatio="${xt(t.preserveAspectRatio)}"`);let s=new Set(["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"]);for(let[a,l]of Object.entries(t.rootAttributes??{}))s.has(a)||!/^[A-Za-z_][\w:.-]*$/.test(a)||(o+=` ${a}="${xt(l)}"`);return t.overflow!==void 0&&t.rootAttributes?.overflow===void 0&&(o+=` overflow="${xt(t.overflow)}"`),n=Fi(t.metadata)+n,`<marker id="${xt(t.id)}"${o} refX="${xt(i.refX)}" refY="${xt(i.refY)}" markerWidth="${xt(i.markerWidth)}" markerHeight="${xt(i.markerHeight)}" markerUnits="${xt(i.markerUnits)}" orient="${xt(i.orient)}">${n}</marker>`}function Rv(t,e){let n={...t.gradient,type:"linear-gradient",id:t.id};return Rl(ls(t.id,n,e),t.metadata)}function Tv(t,e){let n={...t.gradient,type:"radial-gradient",id:t.id};return Rl(cs(t.id,n,e),t.metadata)}function Pv(t){let e={...t.pattern,type:"pattern",id:t.id};return Rl(Il(t.id,e),t.metadata)}function Cv(t){return Rl(La(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 Rl(t,e){let n=Fi(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 Tl(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??Wr(t),i="";for(let o of xv){let s=n.get(o);if(s)for(let a of s)i+=Iv(a,r)}return i}function MM(t,e){let n=Pl(t,e);return n.length===0?"":Tl(n,Wr(e))}function Pl(t,e,n=[]){let r=new Map;for(let u of e)r.set(u.id,u);let i=new Map,o=u=>{if(!u)return;let d=r.get(u);d&&i.set(u,d)},s=(u,d)=>{if(!u||typeof u!="object")return;let p=u;if(!p.id||i.has(p.id))return;let f=d==="linear-gradient"?"linear-gradient":d==="radial-gradient"?"radial-gradient":d==="pattern"?"pattern":null;if(!f)return;let{id:g,sourceId:m,...h}=u,b;if(f==="linear-gradient")b={kind:"linear-gradient",id:p.id,name:m??p.id,sourceId:m,gradient:h};else if(f==="radial-gradient")b={kind:"radial-gradient",id:p.id,name:m??p.id,sourceId:m,gradient:h};else{let{customPatternId:S,...v}=h;b={kind:"pattern",id:p.id,name:m??p.id,sourceId:m,pattern:v}}i.set(p.id,b)},a=(u,d)=>{let p=u.filters;if(!Array.isArray(p)||p.length===0)return;let f=`filter-${d}`;i.has(f)||i.set(f,{kind:"filter",id:f,name:f,filters:p,...u.filterColorInterpolation&&u.filterColorInterpolation!=="auto"?{colorInterpolation:u.filterColorInterpolation}:{},...u.filterUnits?{filterUnits:u.filterUnits}:{},...u.primitiveUnits?{primitiveUnits:u.primitiveUnits}:{},...typeof u.filterX=="string"?{x:u.filterX}:{},...typeof u.filterY=="string"?{y:u.filterY}:{},...typeof u.filterWidth=="string"?{width:u.filterWidth}:{},...typeof u.filterHeight=="string"?{height:u.filterHeight}:{}})},l=u=>{let d=u.state;if(!d)return;if(o(d.fillLibraryId),o(d.strokeLibraryId),o(d.markerStart),o(d.markerMid),o(d.markerEnd),u.type==="symbol-instance"){let f=d.symbolId;f&&To(u)===f&&o(f)}else o(d.symbolId);let p=d.filterLibraryIds;if(Array.isArray(p))for(let f of p)typeof f=="string"&&o(f);d.fillLibraryId||s(d.fillGradient,d.fillType),d.strokeLibraryId||s(d.strokeGradient,d.strokeType),(!Array.isArray(p)||p.length===0)&&a(d,u.id)};for(let u of t)l(u);let c=Array.from(n);for(let u of c)o(u);return fa(t,e,l),Id(c,e,l),Array.from(i.values())}function $v(t){let e=new Map,n=(s,a)=>{let l=s.type??a;return l==="linear-gradient"||l==="radial-gradient"||l==="pattern"?l:null},r=(s,a,l)=>{if(typeof s!="string"||s.length===0||!a||typeof a!="object"||e.has(s))return;let c=a,u=n(c,l);if(!u)return;let{id:d,sourceId:p,type:f,...g}=c,m=typeof p=="string"?p:s;if(u==="linear-gradient")e.set(s,{kind:u,id:s,name:m,...typeof p=="string"?{sourceId:p}:{},gradient:g});else if(u==="radial-gradient")e.set(s,{kind:u,id:s,name:m,...typeof p=="string"?{sourceId:p}:{},gradient:g});else{let{customPatternId:h,...b}=g;e.set(s,{kind:"pattern",id:s,name:m,...typeof p=="string"?{sourceId:p}:{},pattern:b})}},i=s=>{let a=s.filterLibraryIds;if(!Array.isArray(a)||a.length!==1||typeof a[0]!="string")return;let l=a[0],c=s.filters;!Array.isArray(c)||c.length===0||e.has(l)||e.set(l,{kind:"filter",id:l,name:l,filters:c,...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 l=a.children;if(Array.isArray(l))for(let c of l)o(c)};for(let s of t)o(s);return Array.from(e.values())}function Ev(t){return t.easing==="custom-bezier"&&t.customBezier?t.customBezier:ei[t.easing]??null}function Av(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,l=f=>(((1-3*r+3*e)*f+(3*r-6*e))*f+3*e)*f,c=f=>(3*(1-3*n+3*t)*f+2*(3*n-6*t))*f+3*t,u=i;for(let f=0;f<s;f++){let g=a(u)-i;if(Math.abs(g)<o)return l(u);let m=c(u);if(Math.abs(m)<o)break;u-=g/m}let d=0,p=1;for(u=i;d<p;){let f=a(u);if(Math.abs(f-i)<o)return l(u);i>f?d=u:p=u;let g=(p-d)*.5+d;if(g===u)break;u=g}return l(u)}function $l(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 It(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?"0":Math.abs(t-1)<1e-9?"1":parseFloat(t.toFixed(6)).toString()}function Zp([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 Nv(t){return t.length>0&&t.every(e=>e==="0 0 1 1")}function El(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 Jp(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 Kr(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 Xi(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 Al(t){return t.keyframes.length===1&&t.cycleDuration===void 0}function Nl(t){return t.calcMode!=="discrete"?!1:t.sourceSmilElement==="set"?!0:!t.sourceSmilElement&&!t.cycleInfinite&&t.keyframes.every(e=>e.easing!=="steps")}function Qp(t,e){if(e<=0)return Xi(t);if(Xi(t)==="indefinite")return"indefinite";let n=t.keyframes[e]?.time??0;return n!==0?`${n}s`:""}function ef(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 Yi(t){return t.cycleInfinite||t.fill==="remove"?null:"freeze"}function tf(t){return t.additive==="sum"?"sum":null}function nf(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 OM(t){let e=n=>Math.max(0,Math.min(1,n));return[t[0],e(t[1]),t[2],e(t[3])]}function DM(t){let[e,n,r,i]=t,o=new Set,s=8;for(let d=1;d<=s;d++)o.add(d/s);let a=n-2*i+1,l=2*(i-2*n),c=n,u=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&&o.add(Number(p.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(l)>=1e-9&&u(-c/l);else{let d=l*l-4*a*c;if(d>=0){let p=Math.sqrt(d);u((-l+p)/(2*a)),u((-l-p)/(2*a))}}return[...o].sort((d,p)=>d-p)}function zM(t,e,n,r,i,o){let s=typeof t.value=="number"&&typeof e.value=="number",a=mr(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(s){let h=e.linearPoints;for(let b=1;b<h.length;b++){let S=h[b],v=t.time+(e.time-t.time)*S.position,I=t.value+(e.value-t.value)*S.value;r.push(I),i.push(It(n(v))),o.push("0 0 1 1")}return}r.push(a),i.push(It(n(e.time))),o.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(It(n(e.time))),o.push("0 0 1 1");return}let l=Ev(e);if(!l){r.push(a),i.push(It(n(e.time))),o.push("0 0 1 1");return}let[,c,,u]=l;if(!(c<0||c>1||u<0||u>1)){r.push(a),i.push(It(n(e.time))),o.push(Zp(l));return}if(!s){r.push(a),i.push(It(n(e.time))),o.push(Zp(OM(l)));return}let p=DM(l),f=t.value,g=e.value,m=e.time-t.time;for(let h of p){let b=Av(l[0],l[1],l[2],l[3],h),S=t.time+m*h,v=f+(g-f)*b;r.push(v),i.push(It(n(S))),o.push("0 0 1 1")}}function mr(t){return Array.isArray(t)?t.join(" "):t}function _M(t,e,n){let r=[],{count:i,position:o}=n,s=e.time-t.time,a=mr(t.value),l=mr(e.value),c=typeof a=="number"&&typeof l=="number",u=typeof a=="string"&&typeof l=="string",d=g=>u?g<.5?a:l:c?a+(l-a)*g:g>=1?l:a,p=g=>{let m=Math.floor(g*i);(o==="jump-start"||o==="jump-both")&&(m+=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 m>h&&(m=h),m<0&&(m=0),m/h},f=p(0);for(let g=1;g<=i;g++){let m=g/i,h=p(m);if(h===f)continue;let b=t.time+m*s;r.push({value:d(h),time:b}),f=h}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 FM(t,e){let n=[],r=[],i=(o,s)=>{n.push(o),r.push(It(e(s)))};i(mr(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 l=_M(s,a,a.stepsParams);for(let c of l)i(c.value,c.time)}else i(mr(a.value),a.time)}return{values:n,keyTimes:r}}function LM(t,e,n){return{values:t.slice().reverse(),keyTimes:e.slice().reverse().map(r=>It(1-parseFloat(r))),keySplines:n.slice().reverse().map($l)}}function Cl(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{...LM(t,e,n),calcMode:r};if(o==="alternate-reverse"){let c=t.slice().reverse(),u=e.slice().reverse().map(p=>It(.5-parseFloat(p))),d=n.slice().reverse().map($l);return{values:[...c,...t.slice(1)],keyTimes:[...u,...e.slice(1).map(p=>It(.5+parseFloat(p)))],keySplines:[...d,...n],calcMode:r}}let s=t.slice(0,-1).reverse(),a=e.slice(0,-1).reverse().map(c=>It(1-parseFloat(c))),l=n.slice().reverse().map($l);return{values:[...t,...s],keyTimes:[...e,...a],keySplines:[...n,...l],calcMode:r}}function Xr(t){let e=t.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let n=Kr(t),r=e[0]?.time??0,i=c=>n>0?(c-r)/n:0;if(e.some(c=>c.easing==="steps")){let{values:c,keyTimes:u}=FM(e,i);return Cl(c,u,[],"discrete",t)}if(t.calcMode==="discrete"){let c=e.map(d=>mr(d.value)),u=e.map(d=>It(i(d.time)));return Cl(c,u,[],"discrete",t)}if(t.calcMode==="paced"){let c=e.map(d=>mr(d.value)),u=e.map(d=>It(i(d.time)));return Cl(c,u,[],"paced",t)}let s=[mr(e[0].value)],a=[It(i(e[0].time))],l=[];for(let c=1;c<e.length;c++)zM(e[c-1],e[c],i,s,a,l);return Cl(s,a,l,"spline",t)}function Ml(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&&!Nv(t.keySplines);return El(t.keyTimes)||(r.keyTimes=t.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=t.keySplines.join(";")),r}function Mv(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 l=0;l<4;l++)if(s[l]!==a[l])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 rf(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 l=a.property==="translateX"||a.property==="translateY",c=l?"translateX":"scaleX",u=l?"translateY":"scaleY";if(!(a.property!==c&&a.property!==u))for(let d=s+1;d<i.length;d++){let p=i[d];if(o.has(p.id)||!(a.property===c&&p.property===u||a.property===u&&p.property===c)||!Mv(a,p))continue;let f=a.property===c?a:p,g=a.property===u?a:p;e.set(f.id,g),n.add(g.id),o.add(f.id),o.add(g.id);break}}}return{partner:e,skip:n}}function of(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),l=[];for(let c=0;c<a;c++)l.push(`${o[c]} ${s[c]}`);return l}let i=n?"1":"0";return t.values.map(o=>e?`${i} ${o}`:`${o} ${i}`)}var Ov={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"},Dv=new Set(["transformMatrix","rotation","skewX","skewY"]),zv=new Set(["translateX","translateY","scaleX","scaleY"]);function Dl(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ae(t,e){return e==null?"":` ${t}="${Dl(e)}"`}function sf(t,e){let n=Ml(t,e);return Ae("keyTimes",n.keyTimes)+Ae("calcMode",n.calcMode)+Ae("keySplines",n.keySplines)}function zl(t,e){return Ae("dur",`${e}s`)+Ae("begin",Xi(t)||null)+Ae("repeatCount",ef(t))}function _v(t,e){let n=e??Ov[t.property];if(!n)return"";let r=Kr(t);if(r<=0)return"";let i=Xr(t);return i.values.length<2?"":"<animate"+Ae("attributeName",n)+Ae("values",i.values.join(";"))+sf(i)+zl(t,r)+Ae("fill",Yi(t))+"/>"}function BM(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=Kr(t);if(r<=0)return"";let i=Xr(t),o=n==="matrix"?i.values.map(l=>VM(l)):i.values.map(l=>String(l));if(o.length<2||o.some(l=>l.length===0))return"";let s=n==="rotate"&&t.transformOrigin?o.map(l=>`${l} ${t.transformOrigin.x} ${t.transformOrigin.y}`):o,a=t.replacesCarrierBase&&e?"sum":tf(t);return'<animateTransform attributeName="transform"'+Ae("type",n)+Ae("values",s.join(";"))+sf(i)+zl(t,r)+Ae("additive",a)+Ae("fill",Yi(t))+"/>"}function GM(t,e,n){let r=t.property==="scaleX"||t.property==="scaleY",i=t.property==="translateY"||t.property==="scaleY",o=r?"scale":"translate",s=Kr(t);if(s<=0)return"";let a=Xr(t);if(a.values.length<2)return"";let l=e?Xr(e):void 0,c=of(a,i,r,l);if(c.length<2)return"";let u=!t.replacesCarrierBase||n?"sum":null;return'<animateTransform attributeName="transform"'+Ae("type",o)+Ae("values",c.join(";"))+sf(a)+zl(t,s)+Ae("additive",u)+Ae("fill",Yi(t))+"/>"}function VM(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 jM(t){if(!t.motionPath)return"";let e=Kr(t);if(e<=0)return"";let n=Xr(t),r=nf(t),i=!!t.motionPathRef&&(t.motionPathRef.mode??"trackShape")==="curveTemplate",o=Ml(n,{defaultCalcMode:"paced"}),s=Jp(r)&&El(n.keyTimes)&&n.calcMode!=="discrete"&&o.calcMode===void 0,a="<animateMotion";return i||(a+=Ae("path",t.motionPath)),a+=Ae("keyTimes",o.keyTimes),s||(a+=Ae("keyPoints",r.join(";"))),a+=Ae("calcMode",o.calcMode)+Ae("keySplines",o.keySplines),a+=zl(t,e),a+=Ae("fill",Yi(t)),t.motionRotate!==void 0&&(a+=Ae("rotate",typeof t.motionRotate=="number"?String(t.motionRotate):t.motionRotate)),i?a+=`><mpath href="#${Dl(t.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function Ol(t,e,n){if(Dv.has(t.property)||zv.has(t.property)||t.property==="pathMotion")return"";let r=n??Ov[t.property];if(!r)return"";let i=t.keyframes[e];return i?"<set"+Ae("attributeName",r)+Ae("to",Array.isArray(i.value)?i.value.join(" "):String(i.value))+Ae("begin",Qp(t,e)||null)+"/>":""}function Fv(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?"":Al(n)?Ol(n,0,e):Nl(n)?n.keyframes.map((r,i)=>Ol(n,i,e)).join(""):n.keyframes.length<2?"":_v(n,e)}function UM(t){let e=Xi(t);return e?`<discard begin="${Dl(e)}"/>`:"<discard/>"}function af(t){let e=new Map,n=t.tracks.map(c=>({...c,locked:c.locked??!1,keyframes:[...c.keyframes].sort((u,d)=>u.time-d.time).map(u=>({...u,time:u.time,value:u.value,easing:u.easing}))})),r=[...n.flatMap(c=>{let u=Ng(c);return u?[u]:[]}),...n],i=rf(r),o=new Set,s=new Set,a=new Set,l=(c,u,d)=>{if(!u)return;let p=u;d.sourceSmilId&&!o.has(d.sourceSmilId)&&(o.add(d.sourceSmilId),p=u.replace(/^(<[a-zA-Z]+)/,`$1 id="${Dl(d.sourceSmilId)}"`));let f=e.get(c)??[];f.push(p),e.set(c,f)};for(let c of r){if(!c.enabled||i.skip.has(c.id)||c.keyframes.length<1)continue;if(c.property==="discard"){l(c.shapeId,UM(c),c);continue}if(Al(c)){l(c.shapeId,Ol(c,0),c);continue}if(Nl(c)){for(let p=0;p<c.keyframes.length;p++)l(c.shapeId,Ol(c,p),c);continue}if(c.keyframes.length<2)continue;let u=c.id.endsWith(":backwards-fill")?s:a,d="";c.property==="pathMotion"&&c.motionPath?d=jM(c):Dv.has(c.property)?(d=BM(c,u.has(c.shapeId)),d&&u.add(c.shapeId)):zv.has(c.property)?(d=GM(c,i.partner.get(c.id),u.has(c.shapeId)),d&&u.add(c.shapeId)):d=_v(c),l(c.shapeId,d,c)}return e}function Fl(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(Fl).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${Fl(n)}`).join(",")}}`}function _l(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=jr(r,e).viewport.childPercentBasis??e),_l(i,o,n)}}function lf(t,e,n={}){let r=n.reservedIds??new Set,i=Ko(t),o=new Map,s=[],a=new WeakMap,l=new Map,c=[],u=(R,C)=>{a.set(R,C);let A=l.get(R.id);A?A.push(C):l.set(R.id,[C]),c.push(...C.diagnostics)},d=(R,C,A)=>{if(a.has(R))return;let D=String(R.state.symbolId??"").trim(),_=D!==""&&i.duplicateIds.has(D),O=D?i.symbol(D):void 0;if(_||!O){u(R,{targetId:null,definition:null,materializationKey:null,materialization:null,parentViewport:A,viewport:null,diagnostics:[{code:_?"duplicate-library-id":"unresolved-symbol-definition",shapeId:R.id,message:_?`Symbol instance ${R.id} targets duplicate library id ${D}.`:`Symbol instance ${R.id} targets missing symbol definition ${D||"(blank)"}.`}]});return}let L=n.instancePolicy?.(R),re=L?.initialVariantKey===void 0?R:{...R,state:{...R.state,variantKey:L.initialVariantKey}},ee=Ii(O,re),F=L?.dedicated===!0,V=qo(R,O,A,n.viewportHost);if(C.includes(ee.materializationKey)){u(R,{targetId:null,definition:O,materializationKey:ee.materializationKey,materialization:null,parentViewport:A,viewport:V,diagnostics:[...ee.diagnostics,{code:"symbol-cycle",shapeId:R.id,message:`Symbol instance cycle detected through ${O.id}.`}]});return}let H=A?`${A.width},${A.height}`:"none",X=`${ee.materializationKey}\0path=${C.join("")}\0viewport=${H}`+(F?`\0dedicated=${R.id}`:""),z=o.get(X);if(!z){let te=structuredClone(ee.shapes);z={occurrenceKey:X,materializationKey:ee.materializationKey,candidateTargetId:F?`${O.id}--ovr-${R.id}`:ee.candidateTargetId,targetId:F?`${O.id}--ovr-${R.id}`:ee.candidateTargetId,definition:O,shapes:te,materialized:ee.materialized||F,forcedDedicated:F,activeDepth:C.length,parentViewport:A,viewport:V},o.set(X,z),s.push(z)}let G={targetId:z.targetId,definition:O,materializationKey:ee.materializationKey,materialization:null,diagnostics:ee.diagnostics,parentViewport:A,viewport:V,pending:z};u(R,G);let q=[...C,ee.materializationKey];_l(z.shapes,z.viewport.childPercentBasis??A,(te,ie)=>d(te,q,ie))};_l(e,n.parentViewport,(R,C)=>{d(R,[],C)});let p=new Map,f=new Map,g=new Set,m=R=>{let C=p.get(R);if(C)return C;if(g.has(R))throw new Error(`Materialization occurrence graph retained a cycle at ${R.occurrenceKey}.`);g.add(R);let A=[];_l(R.shapes,R.viewport.childPercentBasis??R.parentViewport,O=>{let L=a.get(O);if(L?.pending){A.push(`resolved:${m(L.pending)}`);return}A.push(Fl({materializationKey:L?.materializationKey??null,diagnostics:L?.diagnostics.map(re=>re.code)??["missing-resolution"]}))}),g.delete(R);let D=Fl({materializationKey:R.materializationKey,nested:A,forcedOccurrence:R.forcedDedicated?R.occurrenceKey:null}),_=f.get(D);return _||(_=`materialization-signature:${f.size+1}`,f.set(D,_)),p.set(R,_),_},h=(R,C)=>R.activeDepth-C.activeDepth||R.candidateTargetId.localeCompare(C.candidateTargetId)||R.occurrenceKey.localeCompare(C.occurrenceKey),b=new Map;for(let R of s){let C=m(R),A=b.get(C);(!A||h(R,A)<0)&&b.set(C,R)}let S=new Map;for(let R of s)S.set(R,b.get(m(R)));let v=s.filter(R=>S.get(R)===R),I=new Map;for(let R of v){let C=I.get(R.materializationKey);(!C||C.forcedDedicated&&!R.forcedDedicated||C.forcedDedicated===R.forcedDedicated&&h(R,C)<0)&&I.set(R.materializationKey,R)}let x=R=>R.forcedDedicated||R.materialized||I.get(R.materializationKey)!==R,P=new Set(v.filter(R=>!x(R)).map(R=>R.definition.id)),T=new Set([...r,...P,...v.filter(x).map(R=>R.candidateTargetId)]),k=new Set([...r,...P]);for(let R of v){if(!x(R)){R.targetId=R.definition.id;continue}let C=R.candidateTargetId,A=C;if(k.has(A)){let D=2;do A=`${C}-${D++}`;while(T.has(A)||k.has(A))}R.targetId=A,k.add(A)}let w=new Map,$=v.map(R=>{let C={materializationKey:R.materializationKey,targetId:R.targetId,candidateTargetId:R.candidateTargetId,definition:R.definition,shapes:R.shapes,parentViewport:R.parentViewport,viewport:R.viewport};return w.set(R,C),C});for(let R of s){let C=S.get(R),A=w.get(C);R.targetId=A.targetId,R!==C&&w.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 l.values())for(let C of R)C.pending&&(C.targetId=C.pending.targetId,C.materialization=w.get(C.pending)??null,delete C.pending);return{materializations:$,diagnostics:c,resolve(R){let C=a.get(R);if(C)return C;let A=l.get(R.id);return A?.length===1?A[0]:void 0}}}var HM="text/css";function Ll(t){return t.includes("{")?t.replace(/([^{}]*)\{([^{}]*)\}/g,(e,n,r)=>{let i=Lv(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}}`}):Lv(t)}var WM=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?animation(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,KM=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?transition(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,XM=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?(?:transform-origin|transform-box)\s*:[^;]*(?:;|$)/gi;function Lv(t){let e=!1,n=t.replace(WM,r=>(e=!0,cf(r)));return n=n.replace(KM,r=>cf(r)),e&&(n=n.replace(XM,r=>cf(r))),n}function cf(t){return t.startsWith(";")?";":""}function YM(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function Bv(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;")}function Bl(t){let e=t.map(({name:n,defaultValue:r})=>` --${n}: ${r};`);return e.length?`:root, svg {
39
+ ${e.join(`
40
+ `)}
41
+ }
42
+ `:""}function df(t){if(!t||t.length===0)return"";let e=Bl(t);return e?`<style id="svgsketch-variables">${Bv(e)}</style>`:""}function uf(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!==HM&&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}="${YM(s)}"`;i+=`>${Bv(Ll(n.css))}</style>`,e.push(i)}return e.join("")}function qM(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function ZM(t){return t?t.includes("]]>")?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):/[<&>]/.test(t)?`<![CDATA[${t}]]>`:t:""}function pf(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}="${qM(s)}"`;n.source==="inline"&&n.content?i+=`>${ZM(n.content)}</script>`:i+="/>",e.push(i)}return e.join("")}function Gv(t){return t.replace(new RegExp(`\\s+${So}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function ff(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 mf(t,e,n=[],r=new Set){let i=new Map;for(let c of t.rawPaintServerDefs??[]){if(typeof c!="string")continue;let u=bo(c);if(!u||r.has(u))continue;let d=c.includes(So);i.set(u,{id:u,markup:Gv(c),passthrough:d})}for(let c of t.paintServerDefs??[]){if(!c||typeof c.markup!="string")continue;let u=c.id??bo(c.markup);!u||r.has(u)||i.set(u,{id:u,markup:Gv(c.markup),passthrough:c.passthrough===!0})}if(i.size===0)return"";let o=new Set;ff(e,o);for(let c of n)ff(c,o);let s=new Map;for(let c of i.values())c.passthrough&&s.set(c.id,c);let a=!0;for(;a;){a=!1;for(let c of i.values())s.has(c.id)||!o.has(c.id)||(s.set(c.id,c),a=!0);for(let c of s.values()){let u=o.size;ff(c.markup,o),o.size>u&&(a=!0)}}if(s.size===0)return"";let l=[];for(let c of i.values())s.has(c.id)&&l.push(c.markup);return l.join("")}function gf(t){let e=new Set;for(let n of t??[])e.add(n.definitionId??`${n.type}-${n.id}`);return e}var JM={defsMarkup:"",suppressedShapeIds:new Set,memberToDirective:new Map};function Gt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function Gl(t){return t.definitionId??`${t.type}-${t.id}`}function hf(t,e){let n=0;for(;n<t.length;){let c=/^\s+/.exec(t.slice(n));if(c){n+=c[0].length;continue}if(!t.startsWith("<!--",n))break;let u=t.indexOf("-->",n+4);if(u<0)return t;n=u+3}let r=t.slice(n),i=/^<([A-Za-z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(r);if(!i)return t;let[o,s,a,l]=i;return t.slice(0,n)+`<${s}${e(a)}${l}>`+r.slice(o.length)}function QM(t,e){return hf(t,n=>{let r=n.replace(/\s+id\s*=\s*(?:"[^"]*"|'[^']*')/,"");return` id="${Gt(e)}"${r}`})}function us(t,e){return t.replace(new RegExp(`\\s+${e}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function eO(t,e,n){return hf(t,r=>{let i=us(r,"data-shape-id");if(e==="clip"){let o=/\bfill-rule\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(i);i=us(i,"fill-rule"),i=us(i,"clip-rule"),i=us(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="${Gt(s)}"`)}return i})}function yf(t){let e=t.clipMaskGroups;if(!Array.isArray(e)||e.length===0)return JM;let n=new Map;for(let l of t.shapes??[])tn(l,{onShape:c=>n.set(c.id,c)});let r=Wr(Array.isArray(t.library)?t.library:[]),i=new Set,o=new Map,s=new Set,a=[];for(let l of e){if(!l||l.type!=="clip"&&l.type!=="mask")continue;let c=Gl(l),u=Array.isArray(l.clipShapeIds)?l.clipShapeIds:[];for(let p of u)i.add(p);if(!s.has(c)){if(typeof l.rawDefinition=="string"&&l.rawDefinition.length>0)s.add(c),a.push(QM(l.rawDefinition,c));else if(u.length>0){s.add(c);let p=l.type==="clip"?"clipPath":"mask",f=`<${p} id="${Gt(c)}"`;l.type==="clip"?(l.clipPathUnits&&(f+=` clipPathUnits="${Gt(l.clipPathUnits)}"`),l.clipRule&&(f+=` clip-rule="${Gt(l.clipRule)}"`)):(l.maskUnits&&(f+=` maskUnits="${Gt(l.maskUnits)}"`),l.maskContentUnits&&(f+=` maskContentUnits="${Gt(l.maskContentUnits)}"`),l.maskBounds&&(f+=` x="${Gt(l.maskBounds.x)}" y="${Gt(l.maskBounds.y)}"`,f+=` width="${Gt(l.maskBounds.width)}"`,f+=` height="${Gt(l.maskBounds.height)}"`),l.maskType&&(f+=` mask-type="${Gt(l.maskType)}"`)),f+=">";for(let g of u){let m=n.get(g);m&&(f+=eO(pn(m,r),l.type,l.clipRule))}f+=`</${p}>`,a.push(f)}}let d=Array.isArray(l.contentShapeIds)?l.contentShapeIds:[];if(d.length>0){let p={attr:l.type==="clip"?"clip-path":"mask",defId:c,memberIds:d};for(let f of d)o.has(f)||o.set(f,p)}}return{defsMarkup:a.join(""),suppressedShapeIds:i,memberToDirective:o}}function Sf(t,e){return hf(t,n=>`${us(n,e.attr)} ${e.attr}="url(#${Gt(e.defId)})"`)}function Vl(t,e){let n=t.state?.children;return!Array.isArray(n)||n.length===0?t:{...t,state:{...t.state,children:Vv(n,e)}}}function Vv(t,e){let n=t.filter(i=>!e.suppressedShapeIds.has(i?.id)).map(i=>Vl(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],l=i+1;for(;l<n.length&&e.memberToDirective.get(n[l].id)===s;)a.push(n[l]),l++;a.length===1?r.push(tO(o,s)):r.push(nO(a,s)),i=l}return r}function tO(t,e){let n=t.state,r={...n.authoredAttributes??{},[e.attr]:`url(#${e.defId})`};return{...t,state:{...n,authoredAttributes:r}}}function nO(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 Et(t){return t.library+t.builtinMarkers+t.symbols+t.motionPaths+t.paintServers+t.clipMask+t.inlineHoisted}function rO(t){return Up.some(e=>e===t)}function iO(t,e){let n=Xe(t);return n&&n.width>0&&n.height>0?{width:n.width,height:n.height}:e}function fn(t,e={}){let{backgroundColor:n,includeScripts:r=!0}=e;if(t.sceneTree&&t.sceneTree.length>0){let B={...t,shapes:structuredClone(t.shapes??[])};fi(B),t=B}let i=t.shapes??[],o=i.find(B=>B.type==="svg"&&B.state?.isRootSvg===!0),s=o?.state,a=Number(s?.svgViewBoxWidth??0),l=Number(s?.svgViewBoxHeight??0),c=a>0&&l>0?{x:Number(s?.svgViewBoxX??0),y:Number(s?.svgViewBoxY??0),width:a,height:l,intrinsicWidth:Number(s?.svgWidth??0)>0?Number(s?.svgWidth):a,intrinsicHeight:Number(s?.svgHeight??0)>0?Number(s?.svgHeight):l,preserveAspectRatio:typeof s?.svgPreserveAspectRatio=="string"?s.svgPreserveAspectRatio.trim():""}:null,u=t.viewboxes?.[0],d=e.width??c?.intrinsicWidth??u?.width??800,p=e.height??c?.intrinsicHeight??u?.height??600,f=e.viewBox??(c?`${c.x} ${c.y} ${c.width} ${c.height}`:`0 0 ${d} ${p}`),g=e.preserveAspectRatio??c?.preserveAspectRatio??"",m=iO(f,c?{width:c.width,height:c.height}:{width:d,height:p}),h=new Set,b=B=>{for(let ve of B??[])h.add(ve.id),b(ve.state?.children)};for(let B of i)b(B.state?.children);let S=i.filter(B=>B.state?.displayMode==="motionOnly"),v=i.filter(B=>B.state?.displayMode!=="motionOnly"&&B!==o&&!h.has(B.id)),I=new Set(S.filter(B=>jl(B)!==null).map(B=>B.id)),x=t.animationTimeline?{...t.animationTimeline,tracks:t.animationTimeline.tracks.map(B=>{let ve=B.motionPathRef;if(B.property!=="pathMotion"||!B.motionPath||!ve||(ve.mode??"trackShape")!=="curveTemplate"||I.has(ve.shapeId))return B;let{motionPathRef:Re,...nt}=B;return nt})}:null,P=x?af(x):null,T=yf(t),k=aO(t),w=lO(t),$=[...Array.isArray(t.library)?t.library:[],...k.filter(B=>!(Array.isArray(t.library)&&t.library.some(ve=>ve.id===B.id))),...(w??[]).filter(B=>!B.builtIn&&!(Array.isArray(t.library)&&t.library.some(ve=>ve.id===B.id)))],R=qp({documentStyles:t.documentStyles,animationTimeline:x}),C=Pl(v,$,R).filter(B=>B.kind!=="symbol"),A=Ri(v,$);for(let B of R)A.ids.add(B);let D=Wr($);D.textMeasurementHost=e.textMeasurementHost,D.legacySymbolNumericGeometry=(t.schemaVersion??1)<8;let _;{let B=Wo(i),ve=new Map,Re=new Set,nt=new Set,pt=(Z,Ne)=>{Z&&Ne.add(Z)};for(let Z of B.ordered)Z.type==="text"&&pt(Z.state?.shapeInsideRef,Re),Z.type==="shape-reference"&&pt(Z.state?.targetShapeId,nt);let en=new Map;for(let Z of B.ordered){let Ne=Z.state?.metadata?.name,Je=Ne?Ln(Ne):"",xe=Re.has(Z.id)||nt.has(Z.id);Je?en.set(Z,Je):xe&&!B.duplicateIds.has(Z.id)&&en.set(Z,Z.id)}let kn=new Set([...C.map(Z=>Z.id),...S.filter(Z=>jl(Z)).map(Z=>Z.id),...(t.clipMaskGroups??[]).map(Gl)]);for(let[Z,Ne]of Object.entries(vl)){let Je=Z.replace("line-marker-","");(A.legacyEndpoints.has(Je)||A.ids.has(Z))&&kn.add(Z),A.ids.has(Ne)&&kn.add(Ne)}for(let Z of B.ordered)Z.type==="text"&&Z.state.isTextPath&&Z.state.textPathPoints&&kn.add(`text-path-${Z.id}`);_=lf($,v,{reservedIds:new Set([...kn,...en.values()]),parentViewport:m,viewportHost:{legacyNumericGeometry:(t.schemaVersion??1)<8},instancePolicy:(()=>{let Z=e.symbolInstanceInitialVariants;if(!Z||Z.size===0)return;let Ne=new WeakMap;for(let[Je,xe]of Z){let Pt=B.uniqueById.get(Je);Pt?.type==="symbol-instance"&&Ne.set(Pt,xe)}return Je=>{let xe=Ne.get(Je);return xe===void 0?void 0:{initialVariantKey:xe,dedicated:!0}}})()});for(let Z of _.materializations)kn.add(Z.targetId);for(let Z of _.diagnostics)Tt({severity:"warning",code:Z.code,shapeId:Z.shapeId,message:Z.message});D.symbolInstanceTargetElementId=Z=>_.resolve(Z)?.targetId;let Zr=Vr(t),no=new WeakMap;D.symbolInstanceTransform=Z=>{let Ne=no.get(Z);if(!Ne){let Je=_.resolve(Z);Ne=xp(Zr,Z,{},Je?.parentViewport??m),no.set(Z,Ne);for(let xe of Ne.diagnostics)!["invalid-symbol-viewport","unresolved-symbol-viewport","unresolved-symbol-pivot"].includes(xe.code)||!rO(xe.code)||Tt({severity:"warning",code:xe.code,shapeId:xe.shapeId,message:xe.message})}return Ne};let ro=new Set([...en.values(),...kn]),Jr=new Set(kn),Qr=new Map,gr=new Map,gm=new Map;for(let[Z,Ne]of en){let Je=(Qr.get(Ne)??0)+1;Qr.set(Ne,Je);let xe=Ne;if(Je>1||Jr.has(xe)){let Pt=2;do xe=`${Ne}-${Pt++}`;while(ro.has(xe)||Jr.has(xe))}gr.set(Z,xe),B.duplicateIds.has(Z.id)||gm.set(Z.id,xe),Jr.add(xe)}for(let[Z,Ne]of B.uniqueById){let Je=gr.get(Ne);Je&&ve.set(Z,Je)}if(gr.size>0&&(D.elementIdForShape=Z=>gm.get(Z.id)??gr.get(Z)),Re.size>0&&(D.shapeInsideTargetElementId=Z=>ve.get(Z)),nt.size>0){D.shapeReferenceTargetElementId=xe=>B.duplicateIds.has(xe)?null:ve.get(xe);let Z=Vr(t),Ne=new WeakMap,Je=new WeakMap;D.shapeReferenceBounds=xe=>{let Pt=Ne.get(xe);return Pt||(Pt=es(Z,xe),Ne.set(xe,Pt)),Pt},D.shapeReferenceTransform=xe=>{let Pt=Je.get(xe);return Pt||(Pt=vp(Z,xe),Je.set(xe,Pt)),Pt}}}let O=new Map,L=new Set,re=new Map(Wo(i).ordered.map(B=>[B.id,B]));for(let B of x?.tracks??[]){let ve=/^(fill|stroke)GradientStop(\d+)(Color|Opacity|Offset)$/.exec(B.property);if(!ve)continue;let Re=re.get(B.shapeId);if(!Re)continue;let nt=ve[1],pt=Number(ve[2]),en=ve[3],kn=Re.state?.[nt==="fill"?"fillGradient":"strokeGradient"],Zr=Re.state?.[nt==="fill"?"fillLibraryId":"strokeLibraryId"]??kn?.id;if(!Zr)continue;let no=en==="Color"?"stop-color":en==="Opacity"?"stop-opacity":"offset",ro=Fv(B,no);if(!ro)continue;let Jr=`${Zr}|${pt}|${no}|${ro}`;if(L.has(Jr))continue;L.add(Jr);let Qr=O.get(Zr)??new Map,gr=Qr.get(pt)??[];gr.push(ro),Qr.set(pt,gr),O.set(Zr,Qr)}D.gradientStopAnimationElements=(B,ve)=>O.get(B)?.get(ve);let ee=C.length>0?Tl(C,D):"",F=_.materializations.filter(B=>B.targetId===B.definition.id).map(B=>ds(B.definition,B.targetId,B.shapes,D)).join(""),V=ee+F,H=Yp(A,$),X=_.materializations.filter(B=>B.targetId!==B.definition.id).map(B=>ds(B.definition,B.targetId,B.shapes,D)).join(""),z=cO(S),G=n?`<rect width="${d}" height="${p}" fill="${n}"/>`:"",q={...D,animationElementsForShape:B=>P?.get(B.id)},te=B=>{let ve=pn(B,q),Re=P?.get(B.id),nt=Re&&Re.length>0?Re:[];return{shape:B,markup:ve,smil:nt}},ie=v.filter(B=>!T.suppressedShapeIds.has(B.id)).map(B=>Vl(B,T)),J=[];for(let B=0;B<ie.length;){let ve=ie[B],Re=T.memberToDirective.get(ve.id);if(!Re){J.push({kind:"shape",...te(ve)}),B++;continue}let nt=[ve],pt=B+1;for(;pt<ie.length&&T.memberToDirective.get(ie[pt].id)===Re;)nt.push(ie[pt]),pt++;if(nt.length===1){let en=te(ve);J.push({kind:"shape",...en,markup:Sf(en.markup,Re)})}else J.push({kind:"clip-mask-run",directive:Re,open:`<g ${Re.attr}="url(#${bf(Re.defId)})">`,close:"</g>",members:nt.map(te)});B=pt}let ke=Hv(J),Fe=(t.documentStyles??[]).map(B=>Ll(B.css)),Le=Bl(t.templateVariables??[]),Ze=mf(t,ke,[...Fe,Le,T.defsMarkup,V,X,H,z],gf(t.clipMaskGroups)),wt={rootAttributes:Bu(t.documentMetadata),descriptive:Gu(t.documentMetadata),scripts:r?pf(t.documentScripts):"",styles:df(t.templateVariables)+uf(t.documentStyles),trailingComments:(t.documentMetadata?.trailingComments??[]).map(B=>`<!--${B.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")},to={frame:{width:d,height:p,viewBox:f,preserveAspectRatio:g,...e.omitFrameAttributes?{omit:e.omitFrameAttributes}:{}},defs:{library:V,builtinMarkers:H,symbols:X,motionPaths:z,paintServers:Ze,clipMask:T.defsMarkup,inlineHoisted:""},body:J,motionOnlyShapes:S,backgroundRect:G,envelope:wt,strippedCssTexts:Fe,strippedDocumentCss:Fe.join(`
43
+ `).trim(),symbols:_};return sO(to),to}function Hv(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 jv=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/g,Uv=/<(?:use|mpath|textPath)\b[^>]*?\s(?:xlink:)?href\s*=\s*"#([^"]+)"/g,oO=/\sid\s*=\s*"([^"]+)"/g;function ps(t,e,n){for(let r of e.matchAll(t))n.add(r[1])}function sO(t){let e=new Set,n=[Et(t.defs),Hv(t.body),t.envelope.descriptive,t.envelope.styles];for(let s of n)ps(oO,s,e);let r=(s,a)=>{for(let l of s)e.has(l)||Tt({severity:"warning",code:"unresolved-reference",message:a?`Unresolved reference "#${l}" on shape "${a}"; no definition with that id is emitted`:`Unresolved reference "#${l}"; no definition with that id is emitted`,...a?{shapeId:a}:{}})},i=s=>{let a=new Set;ps(jv,s.markup,a),ps(Uv,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;ps(jv,Et(t.defs),o),ps(Uv,Et(t.defs),o),r(o)}function aO(t){let n=(Array.isArray(t.library)?t.library:[]).filter(r=>r.kind==="symbol");return n.length>0?n:t.symbols??[]}function lO(t){let n=(Array.isArray(t.library)?t.library:[]).filter(r=>r.kind==="marker");return n.length>0?n:t.markers}function cO(t){if(t.length===0)return"";let e=[];for(let n of t){let r=jl(n);r&&e.push(`<path id="${bf(n.id)}" d="${bf(r)}"/>`)}return e.join("")}function bf(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function jl(t){return Ra(t)}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"]),Zv=/([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function Jv(t,e){return t.length===0?t:t.replace(Zv,(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=gl(i,e);return o===i?n:`${r}="${o}"`})}var qi=/<\/?([A-Za-z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g;function Hl(t){let e=[],n=0,r=0,i="";qi.lastIndex=0;let o;for(;(o=qi.exec(t))!==null;){let s=o[0].startsWith("</"),a=o[3]==="/";if(s){if(n=Math.max(0,n-1),n===0){let l=t.slice(r,qi.lastIndex);e.push({markup:l,tag:i,id:Wv(l)}),r=qi.lastIndex,i=""}continue}if(n===0&&(i=o[1].toLowerCase()),!a)n++;else if(n===0){let l=t.slice(r,qi.lastIndex);e.push({markup:l,tag:i,id:Wv(l)}),r=qi.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 uO(t,e){let n=(e.paintServerDefs??[]).filter(d=>Array.isArray(d.definitionChildIds)&&d.definitionChildIds.length>0);if(n.length===0)return t;let r=new Map,i=new Map;for(let d of Bn){let p=Hl(t.defs[d]);r.set(d,p),p.forEach((f,g)=>{!f.id||i.has(f.id)||i.set(f.id,{channel:d,index:g,segment:f,key:`${d}:${g}`})})}let o=new Map(n.map(d=>[d.id,d])),s=new Set,a=new Map,l=new Map,c=(d,p)=>{let f=l.get(d);if(f)return f;if(p.has(d))return null;let g=o.get(d),m=i.get(d);if(!g||!m)return null;let h=m.segment.markup,b=h.indexOf(">"),S=h.lastIndexOf("</");if(b<0||S<=b)return h;let v=h.slice(b+1,S),I=g.sourceDefinitionChildIds??g.definitionChildIds,x=g.definitionChildIds,P=new Map(I.map(($,R)=>[$,R])),T=new Set(p);T.add(d);let k=Hl(v).map($=>{if(!$.id)return $.markup;let R=P.get($.id);if(R===void 0)return $.markup;let C=x[R],A=i.get(C);if(!A||A.key===m.key)return $.markup;let D=o.has(C)?c(C,T):A.segment.markup;return D?(s.add(A.key),$.markup.slice(0,$.markup.indexOf("<"))+D.trimStart()):$.markup}).join(""),w=h.slice(0,b+1)+k+h.slice(S);return l.set(d,w),w};for(let d of n){let p=i.get(d.id);if(!p)continue;let f=c(d.id,new Set);f&&a.set(p.key,f)}let u={...t.defs};for(let d of Bn)u[d]=(r.get(d)??[]).map((p,f)=>{let g=`${d}:${f}`;return s.has(g)?"":a.get(g)??p.markup}).join("");return{...t,defs:u}}function Wv(t){let e=/^[^>]*>/.exec(t.trimStart()),n=e?e[0]:t,r=/\sid\s*=\s*"([^"]*)"/.exec(n);return r?r[1]:null}function vf(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xf(t,e){if(e.size===0||t.length===0)return t;let n=t;for(let[r,i]of e){let o=vf(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,l)=>`${a}${l}#${i}${l}`)}return n}function pO(t,e,n){return t.replace(new RegExp(`(\\sid\\s*=\\s*")${vf(e)}(")`),`$1${n}$2`)}var Bn=["library","builtinMarkers","symbols","motionPaths","paintServers","clipMask","inlineHoisted"];function Ul(t,e){let n={...t.defs};for(let r of Bn)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 Qv(t,e){let n=Ul(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 Bn)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 mO(t,e){let n=e.library??[];if(n.length===0)return t;let r=fO(t),i=new Map,o=new Set;for(let l of n){let c=l.sourceId,u=l.id;!c||!u||c===u||o.has(c)||r.has(c)||r.has(u)&&(i.set(u,c),o.add(c))}if(i.size===0)return t;let s=Qv(t,l=>xf(l,i)),a={...s.defs};for(let l of Bn){let c=a[l];for(let[u,d]of i)c=pO(c,u,d);a[l]=c}return{...s,defs:a}}var gO=new Set(["lineargradient","radialgradient","pattern","marker"]);function hO(t,e){let n=t;return e&&(n=n.replace(new RegExp(`\\sid\\s*=\\s*"${vf(e)}"`),"")),n.replace(/\s+/g," ").trim()}function yO(t){let e=new Map,n=new Map,r={...t.defs};for(let o of Bn){let s=Hl(r[o]),a=!1,l=[];for(let c of s){if(!gO.has(c.tag)||!c.id){l.push(c.markup);continue}let u=`${c.tag}|${hO(c.markup,c.id)}`,d=e.get(u);if(d===void 0){e.set(u,c.id),l.push(c.markup);continue}if(d===c.id){a=!0;continue}n.set(c.id,d),a=!0}a&&(r[o]=l.join(""))}if(n.size===0&&r===t.defs)return t;let i={...t,defs:r};return n.size===0?i:Qv(i,o=>xf(o,n))}var SO=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","inherit","initial","unset","revert"]);function Kv(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 ex(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(Kv(o[1]));let s=/font-family\s*:\s*([^;"}<]+)/g;for(;(o=s.exec(r))!==null;)e.add(Kv(o[1]))};for(let r of Bn)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&&!SO.has(r.toLowerCase()))}function bO(t,e){let n=ex(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">
44
+ ${r.trim()}
45
+ </style>`;return{...t,envelope:{...t.envelope,styles:t.envelope.styles.length>0?`${i}
46
+ ${t.envelope.styles}`:i}}}var vO=new Set(["rect","image","svg","use","text"]),Xv="Inter, sans-serif",xO=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 Zi(t){let e=parseFloat(t);return Number.isFinite(e)&&Math.abs(e-1)<1e-6}function Yv(t){let e=parseFloat(t);return Number.isFinite(e)&&e===0}function qv(t){return t===void 0||t==="normal"||t==="400"}var IO=/\s+([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function wO(t,e,n){let r=t.toLowerCase();if(r==="g")return e;let i=r==="image"||r==="foreignobject";return e.replace(IO,(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||Zi(a)&&(n.strokeWidth===void 0||Zi(n.strokeWidth))?"":o;case"stroke-opacity":return Zi(a)&&(n.strokeOpacity===void 0||Zi(n.strokeOpacity))?"":o;case"fill-opacity":return Zi(a)&&(n.fillOpacity===void 0||Zi(n.fillOpacity))?"":o;case"x":case"y":return vO.has(r)&&Yv(a)?"":o;case"font-weight":return qv(a)&&qv(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===Xv&&(n.fontFamily===void 0||n.fontFamily===Xv)?"":o;case"orient":return r==="marker"&&Yv(a)?"":o;case"markerUnits":return r==="marker"&&a==="strokeWidth"?"":o;default:return o}})}function fs(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,l,c,u]=o;if(r+=t.slice(i,o.index),i=o.index+s.length,a==="/"){e.length>1&&e.pop(),r+=s;continue}let d=e[e.length-1],p=wO(l,c,d);if(r+=`<${l}${p}${u}>`,u!=="/"){let f={...d};c.replace(Zv,(g,m,h)=>{let b=xO.get(m);return b&&(f[b]=h),g}),e.push(f)}}return r+=t.slice(i),r}function kO(t){let e={...t.defs};for(let i of Bn)e[i]=fs(e[i],[{}]);let n=[{}],r=t.body.map(i=>{if(i.kind==="shape")return{...i,markup:fs(i.markup,n)};let o=fs(i.open,n),s=i.members.map(l=>({...l,markup:fs(l.markup,n)})),a=fs(i.close,n);return{...i,open:o,members:s,close:a}});return{...t,defs:e,body:r}}function RO(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 TO=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"]]),PO=new Set(["xml","xmlns"]);function CO(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=(d,p)=>{o.lastIndex=0;let f;for(;(f=o.exec(d))!==null;){let g=f[1],m=f[2]??f[3]??"";p.add(g);let h=n.get(g);h||(h=new Set,n.set(g,h)),h.add(m)}},a=(d,p)=>{i.lastIndex=0;let f;for(;(f=i.exec(d))!==null;)f[1]!=="xmlns"&&!p.has(f[1])&&e.add(f[1])},l=new Set(PO);s(t.envelope.rootAttributes,l),a(t.envelope.rootAttributes,l);let c=d=>{if(d.length===0)return;let p=[new Set(l)];r.lastIndex=0;let f;for(;(f=r.exec(d))!==null;){if(f[1]){p.length>1&&p.pop();continue}let g=new Set(p[p.length-1]);s(f[3],g);let m=f[2].indexOf(":");if(m>0){let h=f[2].slice(0,m);g.has(h)||e.add(h)}a(f[3],g),f[4]||p.push(g)}};for(let d of Bn)c(t.defs[d]);for(let d of t.body)d.kind==="shape"?c(d.markup):c(`${d.open}${d.members.map(p=>p.markup).join("")}</g>`);c(t.backgroundRect),c(t.envelope.descriptive),c(t.envelope.scripts),c(t.envelope.styles);let u=[];for(let d of e){let p=n.get(d),f=p?.size===1?[...p][0]:void 0,g=TO.get(d)??f;if(!g){Tt({severity:"warning",code:"undeclarable-namespace-prefix",message:`namespace prefix "${d}:" 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}u.push(` xmlns:${d}="${g}"`)}return u.length===0?t:(u.sort(),{...t,envelope:{...t.envelope,rootAttributes:t.envelope.rootAttributes+u.join("")}})}function If(t,e,n={}){let r=RO(t);if(r=uO(r,e),(n.restoreSourceIds??!0)&&(r=mO(r,e)),(n.deduplicateDefs??!0)&&(r=yO(r)),n.shapeIdAttributes===!1&&(r=Ul(r,i=>i.replace(/\sdata-shape-id="[^"]*"/g,""))),r=Ul(r,i=>i.replace(/\sdata-source-id="[^"]*"/g,"")),n.resolveFontEmbedCss&&(r=bO(r,n.resolveFontEmbedCss)),n.precision!==null){let i=Vp(n.precision??e.documentMetadata?.coordinatePrecision??ml);r=Ul(r,o=>Jv(o,i))}return(n.elideInitialValues??!0)&&(r=kO(r)),r=CO(r),r}function ms(t,e={}){return Wl(t,e).svg}function Wl(t,e={}){let n=new Hi;return{svg:Sl(n,()=>tx(If(fn(t,e),t,e),e)),diagnostics:n.diagnostics}}function tx(t,e={}){let{xmlDeclaration:n=!0,indent:r=!0,className:i}=e,o=r?`
47
+ `:"",s=r?" ":"",a=[];for(let g of t.body){if(g.kind==="shape"){a.push(`${s}${g.markup}`);continue}a.push(`${s}${g.open}`);for(let m of g.members)a.push(`${s}${s}${m.markup}`);a.push(`${s}${g.close}`)}let l=a.join(o),c=t.defs,u="";Et(c).length>0&&(u=`${o}${s}<defs>${o}`,c.library.length>0&&(u+=`${s}${s}${c.library}${o}`),c.builtinMarkers.length>0&&(u+=`${s}${s}${c.builtinMarkers}${o}`),c.symbols.length>0&&(u+=`${s}${s}${c.symbols}${o}`),c.motionPaths.length>0&&(u+=`${s}${s}${c.motionPaths}${o}`),c.paintServers.length>0&&(u+=`${s}${s}${c.paintServers}${o}`),c.clipMask.length>0&&(u+=`${s}${s}${c.clipMask}${o}`),c.inlineHoisted.length>0&&(u+=`${s}${s}${c.inlineHoisted}${o}`),u+=`${s}</defs>`);let d=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+=u,p+=d,l.length>0&&(p+=`${o}${l}`),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}function nx(t,e){return e?t.variants?.[e]??t.shapes:t.shapes}function rx(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 kf(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,l)=>a.time-l.time);s.length<2||e.push({symbolId:o,def:i,overrides:r.symbolOverrides,keyframes:s})}return e}function Rf(t){let e=new Map;for(let[n,r]of t.existingInnerIds)e.set(n,new Set(r));return e}function $O(t){return t.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Ji(t,e){let n=pn(t),r=0;for(;n.startsWith("<!--",r);){let l=n.indexOf("-->",r);if(l===-1)return null;r=l+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?$O(a[1]):null}var Yr=(t,e=0)=>typeof t=="number"&&Number.isFinite(t)?t:e;function EO(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=Yr(t.translateX),o=Yr(t.translateY),s=t.rawTransform;if(s){let m=at(Dt(s)),h=m[0]*e.x+m[2]*e.y+m[4],b=m[1]*e.x+m[3]*e.y+m[5];return{x:h+i,y:b+o}}let a=Yr(t.rotation),l=Yr(t.skewX),c=Yr(t.skewY),u=Yr(t.scaleX,1),d=Yr(t.scaleY,1),p=u!==1||d!==1;if(a===0&&l===0&&c===0&&!p)return{x:e.x+i,y:e.y+o};let f=e.x-n.x,g=e.y-n.y;if(c!==0&&(g=g+f*Math.tan(c*Math.PI/180)),l!==0&&(f=f+g*Math.tan(l*Math.PI/180)),p&&(f*=u,g*=d),a!==0){let m=a*Math.PI/180,h=Math.cos(m),b=Math.sin(m),S=f*h-g*b,v=f*b+g*h;f=S,g=v}return{x:f+n.x+i,y:g+n.y+o}}function ix(t,e){let n=ud(e);if(!n)return t.resolveShapeCenterFallback?.(e)??null;let r=e.state,i=r.customPivot??n;return EO(r,n,i)}var AO=[{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"}],NO={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"}},ox=new Set(["triangle","polygon","star","diamond","ngon","cross","heart","gear","arrow","cloud","ring","lightning","speech-bubble","spiral"]),MO=[{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"}],OO=[{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 sx(t,e){return t+(((e-t)%360+540)%360-180)}function Vt(t,e,n,r,i){return{element:"animate",attributes:[["attributeName",t],["from",e],["to",n],["begin",r],["dur",i],["fill","freeze"]]}}function wf(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 DO(t){let e=t.state.opacity;return e!==void 0?String(e):"1"}function ax(t){let e=t.state.opacity;return e!==void 0?String(Number(e)):"1"}function*Tf(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],l=String(s.value??""),c=String(a.value??"");if(l===c)continue;let u=rx(nx(r,l),i),d=rx(nx(r,c),i);yield{treeA:u,treeB:d,aById:new Map(u.map(p=>[p.id,p])),bById:new Map(d.map(p=>[p.id,p])),index:o,beginSec:s.time/e,durSec:(a.time-s.time)/e}}}function zO(t){let e=kf(t);if(e.length===0)return[];let n=t.timeline.duration>0?t.timeline.duration:1,r=Rf(t),i=[];for(let o of e){let s=r.get(o.symbolId),a=[];for(let l of Tf(o,n)){let c=`${l.beginSec}s`,u=`${l.durSec}s`;for(let d of l.treeB){let p=l.aById.get(d.id);if(!p||!s.has(d.id))continue;let f=p.state,g=d.state,m=[];for(let{key:b,attr:S}of AO){let v=f[b],I=g[b];v===void 0&&I===void 0||v!==I&&(v==null||I==null||m.push({action:"animate",spec:Vt(S,String(v),String(I),c,u)}))}let h=NO[d.type];if(h)for(let[b,S]of Object.entries(h)){let v=f[b],I=g[b];v===void 0&&I===void 0||v!==I&&(v==null||I==null||m.push({action:"animate",spec:Vt(S,String(v),String(I),c,u)}))}if(ox.has(d.type)){let b=Number(f.cx),S=Number(f.cy),v=Number(g.cx),I=Number(g.cy),x=Number(f.rotation??0),P=Number(g.rotation??0);if(Number.isFinite(b)&&Number.isFinite(S)&&Number.isFinite(v)&&Number.isFinite(I)&&Number.isFinite(x)&&Number.isFinite(P)&&(b!==v||S!==I||x!==P)){l.index===0&&m.push({action:"setBaseTransform",transform:`translate(${b}, ${S}) rotate(${x})`}),m.push({action:"animate",spec:wf("translate",`${b} ${S}`,`${v} ${I}`,c,u,"replace")});let R=sx(x,P);m.push({action:"animate",spec:wf("rotate",String(x),String(R),c,u,"sum")})}let k=f.sides,w=g.sides;if((f.radius!==g.radius||f.shiftAngle!==g.shiftAngle||f.cornerRadius!==g.cornerRadius)&&k===w){let R=Ji(p,"d"),C=Ji(d,"d");R&&C&&R!==C&&m.push({action:"animate",spec:Vt("d",R,C,c,u)})}else if(k!==w){let R=`${d.id}--xf`,C=1;for(;s.has(R);)R=`${d.id}--xf${C++}`;s.add(R),m.push({action:"crossfade",innerId:R,shape:d,fadeOut:Vt("opacity","1","0",c,u),fadeIn:Vt("opacity","0",DO(d),c,u)})}}if(d.type==="polyline"){let b=f.polylinePoints??null,S=g.polylinePoints??null;if(b&&S&&b.length===S.length){let v=Ji(p,"points"),I=Ji(d,"points");v&&I&&v!==I&&m.push({action:"animate",spec:Vt("points",v,I,c,u)})}}if(f.lineStyle!==g.lineStyle||f.dashLength!==g.dashLength||f.gapLength!==g.gapLength){let b=Ji(p,"stroke-dasharray"),S=Ji(d,"stroke-dasharray");b&&S&&b!==S&&m.push({action:"animate",spec:Vt("stroke-dasharray",b,S,c,u)})}if(!ox.has(d.type)){let b=Number(f.rotation??0),S=Number(g.rotation??0);if(Number.isFinite(b)&&Number.isFinite(S)&&b!==S){let v=ix(t,p),I=ix(t,d);if(v&&I){let x=sx(b,S);m.push({action:"animate",spec:wf("rotate",`${b} ${v.x} ${v.y}`,`${x} ${I.x} ${I.y}`,c,u,"sum")})}}}for(let[b,S]of[["fillGradient","fill"],["strokeGradient","stroke"]]){let v=_O(f,g,b,S,c,u);v&&m.push(v)}a.push({op:"withInner",innerId:d.id,actions:m})}for(let d of l.treeA)l.bById.has(d.id)||s.has(d.id)&&a.push({op:"withInner",innerId:d.id,actions:[{action:"animate",spec:Vt("opacity","1","0",c,u)}]});for(let d of l.treeB)l.aById.has(d.id)||(s.add(d.id),a.push({op:"ensureInner",innerId:d.id,shape:d,animations:[Vt("opacity","0",ax(d),c,u)]}))}i.push({symbolId:o.symbolId,ops:a})}return i}function _O(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 l=[];for(let d=0;d<s.stops.length;d++){let p=s.stops[d],f=a.stops[d],g=[];p.offset!==f.offset&&g.push(Vt("offset",String(p.offset),String(f.offset),i,o)),p.color!==f.color&&g.push(Vt("stop-color",p.color,f.color,i,o)),p.opacity!==f.opacity&&g.push(Vt("stop-opacity",String(p.opacity),String(f.opacity),i,o)),g.length>0&&l.push({index:d,animations:g})}let c=s.type==="linear-gradient"?["x1","y1","x2","y2"]:["cx","cy","fx","fy","r"],u=[];for(let d of c){let p=s[d],f=a[d];typeof p!="number"||typeof f!="number"||p===f||u.push(Vt(d,String(p),String(f),i,o))}return{action:"gradient",paintAttr:r,expectedStopCount:s.stops.length,stops:l,gradient:u}}var FO=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_");function LO(t){let e=kf(t);if(e.length===0)return{stylesheet:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=Rf(t),i=[],o=0,s=[],a=new Map;for(let l of e){let c=r.get(l.symbolId),u=s.find(f=>f.symbolId===l.symbolId);u||(u={symbolId:l.symbolId,scopeClass:`svgsketch-variant-${FO(l.symbolId)}`,ensure:[],assignments:[]},s.push(u),a.set(u,new Map));let d=a.get(u),p=(f,g,m,h,b,S)=>{let v=`svgsketch-vt-${++o}`;i.push(`@keyframes ${v} { 0% { ${h}: ${g}; } 100% { ${h}: ${m}; } }`);let I=`${v} ${S}s linear ${b}s forwards`,x=d.get(f);x?x.push(I):d.set(f,[I])};for(let f of Tf(l,n))if(!(f.durSec<=0)){for(let g of f.treeB){let m=f.aById.get(g.id);if(!m||!c.has(g.id))continue;let h=m.state,b=g.state;for(let{key:S,prop:v}of MO){let I=h[S],x=b[S];I===void 0&&x===void 0||I!==x&&(I==null||x==null||p(g.id,String(I),String(x),v,f.beginSec,f.durSec))}}for(let g of f.treeA)f.bById.has(g.id)||c.has(g.id)&&p(g.id,"1","0","opacity",f.beginSec,f.durSec);for(let g of f.treeB)f.aById.has(g.id)||(c.has(g.id)||(u.ensure.push({innerId:g.id,shape:g}),c.add(g.id)),p(g.id,"0",ax(g),"opacity",f.beginSec,f.durSec))}}for(let[l,c]of a)for(let[u,d]of c)l.assignments.push({innerId:u,animation:d.join(", ")});return{stylesheet:i.length>0?i.join(`
48
+ `):null,symbols:s}}function BO(t){let e=kf(t);if(e.length===0)return{scriptBody:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=Rf(t),i=[],o=[];for(let l of e){let c=r.get(l.symbolId),u=o.find(d=>d.symbolId===l.symbolId);u||(u={symbolId:l.symbolId,ensure:[]},o.push(u));for(let d of Tf(l,n)){let p=d.beginSec*1e3,f=d.durSec*1e3;if(f<=0)continue;let g=(m,h)=>{let b={},S={};for(let[v,[I,x]]of Object.entries(h))b[v]=I,S[v]=x;i.push({symbolId:l.symbolId,innerId:m,keyframes:[b,S],durationMs:f,delayMs:p})};for(let m of d.treeB){let h=d.aById.get(m.id);if(!h)continue;let b=h.state,S=m.state,v={};for(let{key:I,prop:x}of OO){let P=b[I],T=S[I];P===void 0&&T===void 0||P!==T&&(P==null||T==null||(v[x]=[P,T]))}Object.keys(v).length>0&&g(m.id,v)}for(let m of d.treeA)d.bById.has(m.id)||g(m.id,{opacity:[1,0]});for(let m of d.treeB){if(d.aById.has(m.id))continue;c.has(m.id)||(u.ensure.push({innerId:m.id,shape:m}),c.add(m.id));let h=m.state.opacity,b=h!==void 0?Number(h):1;g(m.id,{opacity:[0,b]})}}}return i.length===0?{scriptBody:null,symbols:o}:{scriptBody:`
49
+ (function () {
50
+ function start() {
51
+ var specs = ${JSON.stringify(i)};
52
+ for (var i = 0; i < specs.length; i++) {
53
+ var spec = specs[i];
54
+ var symbolEl = document.getElementById(spec.symbolId);
55
+ if (!symbolEl) continue;
56
+ var innerEl = symbolEl.querySelector('[data-svgsketch-inner-id="' + spec.innerId + '"]');
57
+ if (!innerEl || !innerEl.animate) continue;
58
+ try {
59
+ innerEl.animate(spec.keyframes, {
60
+ duration: spec.durationMs,
61
+ delay: spec.delayMs,
62
+ fill: 'forwards',
63
+ easing: 'linear'
64
+ });
65
+ } catch (err) {
66
+ // Element.animate may throw on unsupported property names; skip silently.
67
+ }
68
+ }
69
+ }
70
+ if (document.readyState === 'loading') {
71
+ document.addEventListener('DOMContentLoaded', start);
72
+ } else {
73
+ start();
74
+ }
75
+ })();
76
+ `,symbols:o}}function Pf(t,e){let n=HS(t,e);return ms(t,{width:n.width,height:n.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function GO(t){return t==="class"?"className":t==="for"?"htmlFor":t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function Kl(t){return t.replace(/\s([a-z][a-z-]*?)=/g,(e,n)=>n.startsWith("data-")||n.startsWith("aria-")?e:` ${GO(n)}=`)}function Cf(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=fn(t,{width:e.width,height:e.height}),s=[];for(let d of o.body){if(d.kind==="shape"){s.push(`${r}${r}${r}${Kl(d.markup)}`);continue}s.push(`${r}${r}${r}${Kl(d.open)}`);for(let p of d.members)s.push(`${r}${r}${r}${r}${Kl(p.markup)}`);s.push(`${r}${r}${r}${d.close}`)}let a=Et(o.defs),l=a.length>0,c=o.strippedDocumentCss,u=[];u.push("import React from 'react';"),u.push(""),i?(u.push(`interface ${n}Props {`),u.push(`${r}className?: string;`),u.push(`${r}style?: React.CSSProperties;`),u.push("}"),u.push(""),u.push(`const ${n}: React.FC<${n}Props> = ({ className, style }) => {`)):u.push(`const ${n} = ({ className, style }) => {`),u.push(`${r}return (`),u.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}>`),l&&(u.push(`${r}${r}${r}<defs>`),u.push(`${r}${r}${r}${r}${Kl(a)}`),u.push(`${r}${r}${r}</defs>`));for(let d of s)u.push(d);return c.length>0&&u.push(`${r}${r}${r}<style>{${JSON.stringify(c)}}</style>`),u.push(`${r}${r}</svg>`),u.push(`${r});`),u.push("};"),u.push(""),u.push(`export default ${n};`),u.push(""),u.join(`
77
+ `)}function $f(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=fn(t,{width:e.width,height:e.height}),s=[];for(let d of o.body){if(d.kind==="shape"){s.push(`${r}${r}${d.markup}`);continue}s.push(`${r}${r}${d.open}`);for(let p of d.members)s.push(`${r}${r}${r}${p.markup}`);s.push(`${r}${r}${d.close}`)}let a=Et(o.defs),l=a.length>0,c=o.strippedDocumentCss,u=[];u.push("<template>"),u.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">`),l&&(u.push(`${r}${r}<defs>`),u.push(`${r}${r}${r}${a}`),u.push(`${r}${r}</defs>`));for(let d of s)u.push(d);return c.length>0&&u.push(`${r}${r}<component :is="'style'">${c}</component>`),u.push(`${r}</svg>`),u.push("</template>"),u.push(""),i?u.push('<script setup lang="ts">'):u.push("<script setup>"),u.push(`// ${n}`),i?(u.push("defineProps<{"),u.push(`${r}className?: string;`),u.push(`${r}style?: Record<string, string>;`),u.push("}>();")):(u.push("defineProps({"),u.push(`${r}className: { type: String, default: '' },`),u.push(`${r}style: { type: Object, default: () => ({}) },`),u.push("});")),u.push("</script>"),u.push(""),u.join(`
78
+ `)}var VO=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function lx(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Xl(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function jO(t){let e=t.shape;if(!VO.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 Ef(t,e){let n=e.componentName??"createSvg",r=e.indent??" ",i=e.typescript??!1,o=fn(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=Et(o.defs);a.length>0&&(s.push(`${r}svg.append('defs').html(\`${Xl(a)}\`);`),s.push(""));let l=o.strippedDocumentCss;l.length>0&&(s.push(`${r}svg.append('style').text(\`${Xl(l)}\`);`),s.push(""));let c=0;for(let u of o.body){if(c++,u.kind==="clip-mask-run"){s.push(`${r}// group`);let m=u.open+u.members.map(h=>h.markup).join("")+u.close;s.push(`${r}svg.append('g').html(\`${Xl(m)}\`);`),s.push("");continue}let d=u.shape;if(s.push(`${r}// ${d.type}${d.state.metadata?.name?` \u2014 ${d.state.metadata.name}`:""}`),jO(u)){s.push(`${r}svg.append('g').html(\`${Xl(u.markup)}\`);`),s.push("");continue}let p=US(d),f=Ka(d),g=`shape${c}`;s.push(`${r}const ${g} = svg.append('${p}')`);for(let[m,h]of f)s.push(`${r}${r}.attr('${m}', '${lx(h)}')`);d.type==="text"&&d.state.text&&s.push(`${r}${r}.text('${lx(d.state.text)}')`),s[s.length-1]=s[s.length-1]+";",s.push("")}return s.push(`${r}return svg;`),s.push("}"),s.push(""),s.join(`
79
+ `)}function UO(t,e){let n=t.state.metadata?.name;return n?n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${t.type}-${e+1}`}var HO=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function cx(t,e){let n=t.indexOf(" ");return n===-1?t:t.slice(0,n)+` class="${e}"`+t.slice(n)}function Af(t,e){let n=e.indent??" ",r=fn(t,{width:e.width,height:e.height}),i=0,o=new Map,s=[],a=f=>{o.set(f,UO(f.shape,i)),s.push(f),i++};for(let f of r.body)f.kind==="shape"?a(f):f.members.forEach(a);let l=[];for(let f of s){let g=Ka(f.shape),m=[];for(let[h,b]of g)HO.has(h)&&m.push(`${n}${h}: ${b};`);m.length>0&&l.push(`.${o.get(f)} {
80
+ ${m.join(`
18
81
  `)}
19
- }`)}let o=[];for(let l=0;l<i.length;l++){let c=i[l],f=Yo(c,l),d=fe(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 Gi(n,e){let t=Kf(n,e),r={...e};switch(r.format){case"svg":return Oi(t,r);case"react":return Li(t,r);case"vue":return Ni(t,r);case"d3":return Bi(t,r);case"css":return zi(t,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function Kf(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 Kn=class n{_snapshot;constructor(e={}){let{width:t=800,height:r=600,viewboxId:i}=e,s=vn(0,0,t,r,i);this._snapshot=Gr({viewboxes:[s]})}static fromSnapshot(e){let t=new n;return t._snapshot=JSON.parse(JSON.stringify(e)),t}static fromJSON(e,t){let r=Ur(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=[vn(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(Ke({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=Dt(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 jr(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=Hr(this._snapshot,t);return Xt(i,r)}toJSON(e){return Vr(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return Gi(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var Vi=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}}},Ui=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 ce=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=et(Sn(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}}}},Wi=class extends ce{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}},Hi=class extends ce{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}},ji=class extends ce{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}},Ki=class extends ce{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}},Xi=class extends ce{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}},Yi=class extends ce{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=gt(e);return this._state.richTextRuns=t,this._state.richTextData=je(t),this}richTextRuns(e){let t=ht(e);return this._state.richTextRuns=t,this._state.richTextData=je(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}},ge=class extends ce{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}},qi=class extends ge{constructor(e,t,r){super("triangle",e,t,r)}},Zi=class extends ge{constructor(e,t,r,i=5){super("ngon",e,t,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},Ji=class extends ge{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}},Qi=class extends ge{constructor(e,t,r){super("cross",e,t,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},es=class extends ge{constructor(e,t,r){super("ring",e,t,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},ts=class extends ge{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}},ns=class extends ge{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}},rs=class extends ge{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}},is=class extends ge{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}},ss=class extends ge{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}},as=class extends ge{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}},os=class extends ge{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}},ot=class extends ce{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}},ls=class extends ot{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}},us=class extends ot{constructor(){super("switch")}},cs=class extends ot{constructor(){super("container")}},ds=class extends ce{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}},fs=class extends ot{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}},ps=class extends ce{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}},Xn=class extends ce{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}},ms=class extends Xn{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}},hs=class extends Xn{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},gs=class extends ce{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 rt(e,t,r,i,s)}},ys=class extends ce{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}},bs=class extends ce{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 Yn=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}}},qn=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}}},Zn=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=fi(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 Xf(n=0,e=0,t=1,r=0){return new Yn(n,e,t,r)}function Yf(){return new qn}function qf(n="stripes",e="#000000",t="#ffffff"){return new Zn(n,e,t)}var el={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Zf=.04,Jf=0;function Qf(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 ep(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 qo(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(ep(e,T,r,i,s,o,w,$,k,S,x,h))}return d}function Zo(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 Jo(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 Qo(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 tp(n,e={}){let t={...el,...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=Qf(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"?Zf:Jf,b=[];for(let S=0;S<r-1;S++){let x=n.y+(S+1)*d;if(m)b.push(qo(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(Zo(!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(qo(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(Zo(!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=Jo(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=Jo(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=Qo(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=Qo(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 rl=[1,2,3,4,5,6,7,8,9],np={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 Yt(n){return n.map(e=>[...e])}function rp(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function il(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 sl(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 Pt(n){return 1<<n-1}function al(n){let e=0,t=n;for(;t;)t&=t-1,e++;return e}function ip(n){for(let e=1;e<=9;e++)if(n===Pt(e))return e;return 0}function xs(n,e){return Math.floor(n/3)*3+Math.floor(e/3)}function Ss(n){let e=0;for(let t of n)for(let r of t)r!==0&&e++;return e}function sp(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function ol(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 ll(n,e){let t=!0,r=(i,s)=>{let o=0;for(let a of s){if(a===0)continue;let l=Pt(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 $s(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=Pt(o),l=xs(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 vs(n,e,t,r,i){return 511&~(t[n]|r[e]|i[xs(n,e)])}function ul(n,e,t){let r=$s(n);if(!r)return[];let i=Yt(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 $=vs(g,b,o,a,l),k=al($);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(Yt(i));return}let h=rl.filter(g=>p&Pt(g));t&&(h=sl(h,t));for(let g of h){let b=Pt(g),$=xs(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 ap(n){let e=rp(),t=il(n),[r]=ul(e,1,t);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function op(n){let e=$s(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=vs(t,r,e.rows,e.cols,e.boxes);if(al(i)===1)return{row:t,col:r,value:ip(i)}}return null}function lp(n){let e=$s(n);if(!e)return null;let t=r=>{for(let i of rl){let s=Pt(i),o=null;for(let a of r)if(!(n[a.row][a.col]!==0||!(vs(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 tl(n){let e=Yt(n),t=!1;for(;Ss(e)<81;){let r=op(e);if(r){e[r.row][r.col]=r.value;continue}let i=lp(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function nl(n,e){let t={singles:0,"hidden-singles":1,search:2};return t[n]<=t[e]}function Jn(n,e={}){let t=[];return ol(n,t)?ll(n,t)?ul(n,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function up(n){let e=[];if(!ol(n,e))return{valid:!1,unique:!1,solution:null,errors:e};if(ll(n,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=Jn(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]?Yt(r[0]):null,errors:e}}function cp(n){let e=n.difficulty,t=np[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=sp(n.seed);for(let i=0;i<30;i++){let s=r+i*104729>>>0,o=il(s),a=ap(s),l=Yt(a),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=sl(Array.from({length:81},(h,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let h of f){if(Ss(l)<=c)break;let g=l[h.row][h.col];if(l[h.row][h.col]=0,Jn(l,{maxSolutions:2}).length!==1){l[h.row][h.col]=g;continue}let $=tl(l);nl($,t.maxRating)||(l[h.row][h.col]=g)}let d=Ss(l),p=tl(l);if(Jn(l,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&nl(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 cl="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dp={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 fl(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function pl(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 _t(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 fp(n,e,t,r){return n>=0&&e>=0&&n<r&&e<t}function ks(n,e){return Array.from({length:e},()=>Array.from({length:n},()=>!0))}function ml(n,e,t,r){if(!t)return ks(n,e);if(!Array.isArray(t)||t.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),ks(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.`),ks(n,e);i.push(t[s].map(Boolean))}return i}function pp(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 hp(n){return n.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function hl(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 gp(n,e,t,r,i,s,o,a){let l=_t(n),c=[];for(let f=0;f<l.length;f++){let d=e+r.dr*f,p=t+r.dc*f;if(!fp(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 gl(n,e,t,r,i,s){let o=[];for(let a of e){let l=dp[a];for(let c=0;c<i;c++)for(let f=0;f<r;f++){let d=gp(n,c,f,l,t,r,i,s());d&&o.push(d)}}return o}function yl(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=hl(n.axes,n.allowBackwards);o.length===0&&e.push("At least one word direction must be enabled.");let a=ml(Math.max(1,i),Math.max(1,s),n.mask,e),l=pp(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=pl(fl(n.seed));if(e.length===0)for(let m=f.length-1;m>=0;m--){let h=f[m];gl(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 yp(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 bp(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 Sp(n,e){for(let t of e)n[t.row][t.col]=null}function dl(n,e){let t=0;for(let r of e.cells)n[r.row][r.col]===r.grapheme&&t++;return t}function xp(n){return{word:n.word,row:n.row,col:n.col,direction:n.direction,path:n.cells.map(e=>({...e}))}}function $p(n){let e=n.fillerAlphabet??cl,t=typeof e=="string"?_t(e):e.flatMap(i=>_t(i)),r=t.filter((i,s)=>i.trim()&&t.indexOf(i)===s);return r.length>0?r:_t(cl)}function vp(n){let e=Math.floor(n.width),t=Math.floor(n.height),r=fl(n.seed),i=yl({...n,width:e,height:t,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let s=ml(e,t,n.mask,[]),o=Math.max(1,Math.floor(n.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let l=pl(r+a*104729>>>0),c=i.directions,f=new Map;for(let k of i.acceptedWords)f.set(k,gl(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:_t(S).length-_t(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=>!yp(p,v)).sort((v,w)=>{let T=dl(p,w)-dl(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=bp(p,v);if(m.push(xp(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(),Sp(p,w)}return!1};if(!b(0))continue;let $=$p(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 kp(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 Tp(){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 wp(n,e,t){let r=Math.max(1,Math.floor(n)),i=Math.max(1,Math.floor(e)),s=Tp();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 kp(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}}))}export{rs as Arrow,hs as Audio,ro as BUILTIN_MARKER_ID_MAP,vu as COLLAB_PROTOCOL_VERSION,te as COMMON_PROP_DEFAULTS,Ms as COMMON_TRANSFORM_NODE_DEFAULTS,ve as CURRENT_SCHEMA_VERSION,Wi as Circle,as as Cloud,cs as Container,ot as ContainerShapeBuilder,Qi as Cross,$c as DEFAULT_COORDINATE_PRECISION,on as DEFAULT_RICH_TEXT_STYLE,Kn as Document,Kn as DocumentBuilder,tr as EASING_CURVES,er as EasingType,Hi as Ellipse,ns as Gear,is as Heart,ls as Hyperlink,hn as IDENTITY_AFFINE,bs as ImageShape,Os as KNOWN_STATE_KEYS,vo as LIBRARY_EMIT_ORDER,ss as Lightning,Xi as Line,Yn as LinearGradientBuilder,mi as MARKER_HEIGHT,Fn as MARKER_VIEWBOX,pi as MARKER_WIDTH,vc as MAX_COORDINATE_PRECISION,Wa as MIGRATIONS,Zi as NGon,Dl as NON_WIRE_PROP_KEYS,qt as NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,fs as NestedSvg,tn as NodeSchemaRegistry,el as PUZZLE_DEFAULTS,gs as Path,Rs as PathCurveType,bl as PathPointType,Zn as PatternBuilder,ys as Polyline,Ct as RICH_TEXT_STYLE_KEYS,qn as RadialGradientBuilder,ji as Rectangle,es as Ring,As as SERIALIZED_SHAPE_STATE_KEYS,Is as SHAPE_TRANSFORM_STATE_KEYS,or as SceneGraph,We as SceneNode,ce as ShapeBuilder,ps as ShapeReference,os as SpeechBubble,ts as Spiral,Ki as Square,Ji as Star,us as Switch,Yi as Text,Ui as Timeline,Vi as Track,qi as Triangle,ms as Video,ds as View,Xe as affine,Dr as affineFromArray,et as affineToArray,Nm as almostEqualAffine,zm as applyAffineToPoint,Gm as applyAffineToVector,hu as applyOpToSnapshot,Ra as applyOpsInPlace,gu as applyOpsToSnapshot,Aa as applyOpsToSnapshotWithAccepted,un as applyRichTextFormat,Xl as applyTextSplice,En as applyTextTransform,Uo as arcEndpointToCenter,Fo as areTracksTimingEquivalent,Ea as around,Ri as buildCompoundTransformValues,at as buildSmilKeyframeData,Ba as canonicalPolygonTransformString,Gt as canonicalTransformString,fa as collaborationResourceKey,Cn as collectMarkerReferences,Bn as collectReferencedLibraryDefs,Hd as collectReferencedMarkerIds,en as compareOrderKeys,Sn as composeLegacyTransformMatrix,Qr as computeArrowVertices,ri as computeCloudPath,Jr as computeCrossVertices,Ht as computeDashArray,li as computeFlowchartBoxPath,ai as computeGearPath,Xa as computeGearVertices,ni as computeHeartPath,ti as computeLightningVertices,Pn as computePolygonVertices,oi as computeRectanglePath,ii as computeRingPath,ei as computeSpeechBubbleVertices,si as computeSpiralPath,rt as computeSplinePath,Zr as computeStarVertices,Gr as createDocument,pt as createSceneNode,pc as createShape,vn as createViewbox,wp as createWordSearchPrimitiveMask,Ci as cubicBezierExtent1D,Ke as customPatternDefToLibraryDef,br as declaredRichTextDeltaKeys,Vm as decomposeAffine2D,Ap as defaultVariableMode,tu as deriveRichTextFormatRanges,je as deriveSegments,Kl as deriveTextSplice,Su as downTranslateAnimationKeyframeOps,$u as downTranslateCollectionMoveOps,ku as downTranslateDocumentFieldOps,bu as downTranslateScenePlaceOps,xu as downTranslateTextFormatOps,Wo as ellipticalArcBounds,q as escXml,jr as extractVariables,di as filterAttr,bt as findShapeById,nn as flattenShapeStateTree,Ue as flattenStateExtra,Na as foldLegacyAncestorTransformIntoMatrix,Wd as forEachLibraryRefInState,Ud as forEachMarkerRefInState,Mn as forEachReachableShape,Vd as forEachShapeInLibraryDefs,jl as formatOperationValidationIssues,Si as formatSmilKeySpline,xe as formatSmilKeyTime,pn as freezeSiblingOrderKeys,Gi as generateCode,zi as generateCssCode,Bi as generateD3Code,_ as generateId,fi as generatePatternSvgContent,tp as generatePuzzlePieces,Li as generateReactCode,cp as generateSudokuPuzzle,Oi as generateSvgCode,Ni as generateVueCode,vp as generateWordSearch,Xd as getBuiltInMarkerDefs,Pp as getEasingCubicBezier,kc as getEffectivePrecision,Io as getKeyframeCubicBezier,$t as getMarkerDescriptors,Dn as getPatternElements,wi as getSmilAdditive,kt as getSmilBeginValue,Tt as getSmilFillMode,Pi as getSmilMotionKeyPoints,Ti as getSmilRepeatCount,ki as getSmilSetBeginValue,st as getSmilTrackDuration,hl as getWordSearchDirections,sr as initialOrderKeys,Bm as invertAffine,xi as isDefaultKeyPoints,Gn as isDefaultKeyTimes,Bt as isFiniteAffineArray,Fa as isIdentityAffine,Do as isIdentityLinearSplines,$i as isIndefiniteSetTrack,cn as isReusablePatternTile,vi as isSetSequenceTrack,Qt as isValidOrderKey,It as keyBetween,ir as keysBetween,In as legacyEndpointMarkerId,Xf as linearGradient,yl as lintWordSearchOptions,yu as materializeSceneTreeOrderKeys,Da as matrixTransformPart,au as maxCollaborationTimestamp,hr as mergeRichTextStyle,Lr as migrateSnapshot,Ar as moveResourceById,ie as multiplyAffine,O as nodeSchemas,ht as normalizeRichTextRuns,Le as normalizeRichTextStyle,ln as normalizeRichTextStyleDelta,Ae as orderSiblings,Ur as parseDocument,Fr as parseSvgTransformList,xc as parseVariableArgs,hp as parseWordSearchWords,ft as partitionShapeStateTree,ar as partitionStateExtra,Ho as pathDataBounds,qf as pattern,Dt as patternLibraryDefToCustomPatternDef,sa as patternTileSize,_i as planTransformFusion,Lt as projectSceneTreeOntoClipMaskGroups,Ta as projectSceneTreeOntoShapes,ou as promoteRebasedShapeUpdateClock,Di as quadraticBezierExtent1D,Yf as radialGradient,eu as rebaseRichTextFormatRanges,ru as rebaseRichTextRuns,Co as reflectCubicBezier,be as removeResourceById,fr as removeResourceByKey,mr as removeResourceByName,va as removeTrackKeyframe,Ii as renderAnimationElements,Be as renderBuiltinMarkerDefs,ao as renderCircle,oo as renderEllipse,Ld as renderFilterDefs,Ao as renderFilterLibraryDef,ui as renderFilterPrimitive,to as renderFilterPrimitivesForType,yo as renderFlowchartBox,mo as renderImage,ko as renderLibraryDef,Nn as renderLibraryDefs,uo as renderLine,Po as renderLinearGradientLibraryDef,wo as renderMarkerLibraryDef,Ro as renderPatternLibraryDef,bo as renderPolygonShape,po as renderPolyline,_o as renderRadialGradientLibraryDef,lo as renderRectangle,it as renderReferencedLibraryDefs,fe as renderShape,fo as renderSpline,eo as renderSvgPrimitiveChainFilter,go as renderSymbolInstance,To as renderSymbolLibraryDef,co as renderText,Xt as renderToSvg,Jl as resolveRichTextStyleAt,hi as resolveSymbolInstanceShapes,ec as rewriteDocumentEmbeddedPayloads,zr as rewriteShapeStateEmbeddedPayloads,Kt as richTextFontVariantCss,ia as richTextLineSpans,kr as richTextRunsFromState,gr as richTextStyleDelta,$r as richTextStyleDeltasEqual,xr as richTextStylesEqual,gi as richTextTspanAttributes,zt as rotateAffine,Xr as roundCoord,Ka as roundNumberString,Kr as roundSerializedShape,_c as roundSnapshot,gt as runsFromSegments,Tr as sanitizeRichTextFormatRanges,gn as scaleAffine,pu as senderCorrectionsForOp,yn as skewXAffine,bn as skewYAffine,Vn as smilKeyframeAttributes,Mo as solveCubicBezier,Jn as solveSudoku,Vf as splinePathBounds,Vr as stringifyDocument,Wr as substituteString,Hr as substituteVariables,jt as symbolInstanceTargetId,an as transformSplice,Ie as translateAffine,ju as tryParseSvgTransformList,ye as upsertResourceById,dr as upsertResourceByKey,pr as upsertResourceByName,$a as upsertTrackKeyframe,Wl as validateDocumentOperations,cr as validateOperation,Hl as validatePresenceOperation,$n as validateSnapshot,up as validateSudokuPuzzle,Ce as verticesToPath};
82
+ }`)}let c=[];for(let f of r.body){if(f.kind==="shape"){c.push(`${n}${cx(f.markup,o.get(f))}`);continue}c.push(`${n}${f.open}`);for(let g of f.members)c.push(`${n}${n}${cx(g.markup,o.get(g))}`);c.push(`${n}${f.close}`)}let u=Et(r.defs),d=r.strippedDocumentCss,p=[];p.push("<style>");for(let f of l)p.push(f);d.length>0&&p.push(d),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}">`),u.length>0&&p.push(`${n}<defs>${u}</defs>`);for(let f of c)p.push(f);return p.push("</svg>"),p.push(""),p.join(`
83
+ `)}function Nf(t,e){return dx(t,e).code}function dx(t,e){let n=new Hi;return{code:Sl(n,()=>WO(t,e)),diagnostics:n.diagnostics}}function WO(t,e){let n=KO(t,e),r={...e};switch(r.format){case"svg":return Pf(n,r);case"react":return Cf(n,r);case"vue":return $f(n,r);case"d3":return Ef(n,r);case"css":return Af(n,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function KO(t,e){if(Array.isArray(t)){let n=$v(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 Yl=class t{_snapshot;constructor(e={}){let{width:n=800,height:r=600,viewboxId:i}=e,o=Gi(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=zp(e,n),i=new t;return i._snapshot=r,i}static fromSVG(e,n){return t.fromSnapshot(kp(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=[Gi(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=K(),o=n.map(c=>"build"in c&&typeof c.build=="function"?c.build():c),s={kind:"symbol",id:i,name:e,shapes:pr(o,r?.groups)};r?.thumbnail&&(s.thumbnail=r.thumbnail),r?.defKind&&(s.defKind=r.defKind);let a={...r?.wrapperAttrs??{},...r?.rootAttributes??{}},l=a.viewBox;delete a.viewBox,r?.viewBox!==null&&(s.viewBox=r?.viewBox??l??"0 0 100 100");for(let c of["preserveAspectRatio","x","y","width","height","refX","refY"])r?.[c]!==void 0?s[c]=r[c]:s[c]===void 0&&a[c]!==void 0&&(s[c]=a[c]),delete a[c];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(([c,u])=>[c,pr(u,r.groups)]))),r?.variantThumbnails&&(s.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(s),i}placeSymbolInstance(e,n,r,i,o){let s,a={},l=typeof i=="number"||i===void 0;l?s=i:(a=i,s=a.width,o=a.height??o);let c={symbolId:e,x:n,y:r,width:s??100,height:o??100},u=a.authoredUseGeometry??{x:String(n),y:String(r),...l?{width:String(s??100),height:String(o??100)}:{...s!==void 0?{width:String(s)}:{},...o!==void 0?{height:String(o)}:{}}};Object.keys(u).length>0&&(c.authoredUseGeometry=u),a.variantKey&&(c.variantKey=a.variantKey),a.symbolOverrides&&(c.symbolOverrides=a.symbolOverrides),a.instancePresentation&&(c.instancePresentation=a.instancePresentation);let d={id:K(),type:"symbol-instance",state:c};return this._snapshot.shapes.push(d),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=K(),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?.groups&&(s.groups=r.groups),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=K(),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=K(),o="build"in n?n.build():n,{id:s,sourceId:a,...l}=o,c={kind:"linear-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,n,r){let i=K(),o="build"in n?n.build():n,{id:s,sourceId:a,...l}=o,c={kind:"radial-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,n,r){let i=K(),o="build"in n?n.build():n,{id:s,sourceId:a,customPatternId:l,...c}=o,u={kind:"pattern",id:i,name:e,pattern:c};return r?.thumbnail&&(u.thumbnail=r.thumbnail),this._pushLibraryDef(u),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=K(),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=K(),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=K(),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=K(),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=K();return this._pushLibraryDef(Wn({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=fo(n);r&&e.push(r)}return e}addGroup(e,n){this._snapshot.groups||(this._snapshot.groups=[]);let r=e??K();return this._snapshot.groups.push({id:r,parentId:n??null}),r}removeGroup(e){if(!this._snapshot.groups)return!1;let n=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<n}moveToGroup(e,n){let r=this._snapshot.shapes.find(i=>i.id===e);return r&&(r.state.groupId=n),this}removeFromGroup(e){let n=this._snapshot.shapes.find(r=>r.id===e);return n&&delete n.state.groupId,this}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 Bp(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=fl(this._snapshot,n);return ms(i,r)}toSVGWithDiagnostics(e){let{variables:n,...r}=e??{},i=fl(this._snapshot,n);return Wl(i,r)}toJSON(e){return Dp(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,n){return Nf(this._snapshot,{...n,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var Mf=class{_track;constructor(e,n){this._track={id:K(),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:K(),time:e,value:n,easing:r}),this}keyframeBezier(e,n,r){return this._track.keyframes.push({id:K(),time:e,value:n,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(e,n,r){return this._track.keyframes.push({id:K(),time:e,value:n,easing:"linear-function",linearPoints:r}),this}keyframes(...e){return this._track.keyframes.push(...e.map(n=>n.id?n:{...n,id:K()})),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}}},Of=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=>({...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 ut=class{_id;_type;_state={};constructor(e,n){this._type=e,this._id=n??K()}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=at(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,l=this._state.cy;if(a!==void 0&&l!==void 0)return{x:a,y:l};let c=this._state.x1,u=this._state.y1,d=this._state.x2,p=this._state.y2;if(c!==void 0&&u!==void 0&&d!==void 0&&p!==void 0)return{x:(c+d)/2,y:(u+p)/2};let f=this._state.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let g=this._state.polylinePoints;if(g?.[0])return g[0]}filter(...e){let n=this._state.filters??[];return this._state.filters=[...n,...e],this}dropShadow(e={}){let n={id:`drop-shadow-${K()}`,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-${K()}`,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-${K()}`,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-${K()}`,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-${K()}`,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-${K()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(n)}sepia(e=1){let n={id:`sepia-${K()}`,type:"sepia",enabled:!0,amount:e};return this.filter(n)}outline(e={}){return this.filter({id:`outline-${K()}`,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-${K()}`,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-${K()}`,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-${K()}`,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-${K()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(n)}pixelate(e=8){let n={id:`pixelate-${K()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(n)}warp(e={}){let n={id:`warp-${K()}`,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-${K()}`,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-${K()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${K()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(r)}roundEdges(e=4){let n={id:`round-edges-${K()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(n)}channelPainter(e={}){let n={id:`channel-painter-${K()}`,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-${K()}`,type:"brightness",enabled:!0,amount:e};return this.filter(n)}contrast(e=1){let n={id:`contrast-${K()}`,type:"contrast",enabled:!0,amount:e};return this.filter(n)}filterOpacity(e=1){let n={id:`opacity-${K()}`,type:"opacity",enabled:!0,amount:e};return this.filter(n)}invert(e=1){let n={id:`invert-${K()}`,type:"invert",enabled:!0,amount:e};return this.filter(n)}hueRotate(e=0){let n={id:`hue-rotate-${K()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(n)}saturate(e=1){let n={id:`saturate-${K()}`,type:"saturate",enabled:!0,amount:e};return this.filter(n)}blackAndWhite(e=.5){let n={id:`black-and-white-${K()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(n)}duotone(e={}){let n={id:`duotone-${K()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(n)}xray(e=1){let n={id:`xray-${K()}`,type:"xray",enabled:!0,intensity:e};return this.filter(n)}noise(e={}){let n={id:`noise-${K()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(n)}emboss(e={}){let n={id:`emboss-${K()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(n)}filmGrain(e={}){let n={id:`film-grain-${K()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(n)}watercolor(e={}){let n={id:`watercolor-${K()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(n)}gouache(e={}){let n={id:`gouache-${K()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(n)}inkBlot(e={}){let n={id:`ink-blot-${K()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(n)}crumpledPlastic(e={}){let n={id:`crumpled-plastic-${K()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(n)}riddled(e={}){let n={id:`riddled-${K()}`,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}group(e){return this._state.groupId=e,this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},Df=class extends ut{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}},zf=class extends ut{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}},_f=class extends ut{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}},Ff=class extends ut{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}},Lf=class extends ut{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}},Bf=class extends ut{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}richTextData(e){let n=ci(e);return this._state.richTextRuns=n,this._state.richTextData=Hn(n),this}richTextRuns(e){let n=li(e);return this._state.richTextRuns=n,this._state.richTextData=Hn(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}},At=class extends ut{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}},Gf=class extends At{constructor(e,n,r){super("triangle",e,n,r)}},Vf=class extends At{constructor(e,n,r,i=5){super("ngon",e,n,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},jf=class extends At{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}},Uf=class extends At{constructor(e,n,r){super("cross",e,n,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},Hf=class extends At{constructor(e,n,r){super("ring",e,n,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Wf=class extends At{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}},Kf=class extends At{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}},Xf=class extends At{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}},Yf=class extends At{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}},qf=class extends At{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}},Zf=class extends At{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}},Jf=class extends At{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}},qr=class extends ut{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}},Qf=class extends qr{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}},em=class extends qr{constructor(){super("switch")}},tm=class extends qr{constructor(){super("container")}},nm=class extends ut{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}asHome(e=!0){return this}},rm=class extends qr{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}},im=class extends ut{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}},ql=class extends ut{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}},om=class extends ql{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}},sm=class extends ql{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},am=class extends ut{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 Cr(e,n,r,i,o)}},lm=class extends ut{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}},cm=class extends ut{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 Zl=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=K()}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}}},Jl=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=K()}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}}},Ql=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=K()}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=Ru(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 XO(t=0,e=0,n=1,r=0){return new Zl(t,e,n,r)}function YO(){return new Jl}function qO(t="stripes",e="#000000",n="#ffffff"){return new Ql(t,e,n)}var gx={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},ZO=.04,JO=0;function QO(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 ne(t){return Number(t.toFixed(3)).toString()}function eD(t,e,n,r,i,o,s,a,l,c,u,d){return[[0,0],[.2,a],[.5+l+u,-o+c],[.5-o+l,o+c],[.5-2*o+l-u,3*o+c],[.5+2*o+l-u,3*o+c],[.5+o+l,o+c],[.5+l+u,-o+c],[.8,d],[1,0]].map(([f,g])=>{let m=e+f*r,h=n+g*i*s;return t?{x:m,y:h}:{x:h,y:m}})}function ux(t,e,n,r,i,o,s,a,l,c,u){let d=[],p=(x,P)=>l==="alternating"?0:x+c()*(P-x),f=()=>c()<.5,g=p(-a,a),m=l==="alternating"?u%2===0:f(),h=null,b=g,S=p(-a,a),v=p(-a,a),I=p(-a,a);g=p(-a,a);for(let x=0;x<t;x++){x>0&&(h=m,m=l==="alternating"?(u+x)%2===0:f(),b=m===h?-g:g,S=p(-a,a),v=p(-a,a),I=p(-a,a),g=p(-a,a));let P=m?-1:1,T=n+x*i;d.push(eD(e,T,r,i,o,s,P,b,S,v,I,g))}return d}function px(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(([c,u])=>{let d=e+c*r,p=n+u*i*s;return t?{x:d,y:p}:{x:p,y:d}})}function fx(t,e){return t+` C ${ne(e[1].x)} ${ne(e[1].y)} ${ne(e[2].x)} ${ne(e[2].y)} ${ne(e[3].x)} ${ne(e[3].y)} C ${ne(e[4].x)} ${ne(e[4].y)} ${ne(e[5].x)} ${ne(e[5].y)} ${ne(e[6].x)} ${ne(e[6].y)} C ${ne(e[7].x)} ${ne(e[7].y)} ${ne(e[8].x)} ${ne(e[8].y)} ${ne(e[9].x)} ${ne(e[9].y)}`}function mx(t,e){return t+` C ${ne(e[8].x)} ${ne(e[8].y)} ${ne(e[7].x)} ${ne(e[7].y)} ${ne(e[6].x)} ${ne(e[6].y)} C ${ne(e[5].x)} ${ne(e[5].y)} ${ne(e[4].x)} ${ne(e[4].y)} ${ne(e[3].x)} ${ne(e[3].y)} C ${ne(e[2].x)} ${ne(e[2].y)} ${ne(e[1].x)} ${ne(e[1].y)} ${ne(e[0].x)} ${ne(e[0].y)}`}function tD(t,e={}){let n={...gx,...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:l}=n,c=QO(l),u=t.width/i,d=t.height/r,p=Math.max(0,Math.min(.4,s/200)),f=(o==="classic"||o==="curved")&&p>0,g=o==="square-tabs"&&p>0,m=o==="classic"&&a==="random"?ZO:JO,h=[];for(let v=0;v<r-1;v++){let I=t.y+(v+1)*d;if(f)h.push(ux(i,!0,t.x,I,u,d,p,m,a,c,v));else if(g){let x=[];for(let P=0;P<i;P++){let T=a==="alternating"?(v+P)%2===0?1:-1:c()<.5?1:-1;x.push(px(!0,t.x+P*u,I,u,d,p,T))}h.push(x)}else h.push(new Array(i).fill(null))}let b=[];for(let v=0;v<i-1;v++){let I=t.x+(v+1)*u;if(f)b.push(ux(r,!1,t.y,I,d,u,p,m,a,c,v));else if(g){let x=[];for(let P=0;P<r;P++){let T=a==="alternating"?(P+v)%2===0?1:-1:c()<.5?1:-1;x.push(px(!1,t.y+P*d,I,d,u,p,T))}b.push(x)}else b.push(new Array(r).fill(null))}let S=[];for(let v=0;v<r;v++)for(let I=0;I<i;I++){let x=t.x+I*u,P=t.y+v*d,T=x+u,k=P+d,w=`M ${ne(x)} ${ne(P)}`;if(v===0)w+=` L ${ne(T)} ${ne(P)}`;else{let $=h[v-1][I];$?w=fx(w,$):w+=` L ${ne(T)} ${ne(P)}`}if(I===i-1)w+=` L ${ne(T)} ${ne(k)}`;else{let $=b[I][v];$?w=fx(w,$):w+=` L ${ne(T)} ${ne(k)}`}if(v===r-1)w+=` L ${ne(x)} ${ne(k)}`;else{let $=h[v][I];$?w=mx(w,$):w+=` L ${ne(x)} ${ne(k)}`}if(I===0)w+=` L ${ne(x)} ${ne(P)}`;else{let $=b[I-1][v];$?w=mx(w,$):w+=` L ${ne(x)} ${ne(P)}`}w+=" Z",S.push({id:`puzzle-${l}-r${v}-c${I}`,row:v,col:I,d:w})}return S}var Sx=[1,2,3,4,5,6,7,8,9],nD={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 gs(t){return t.map(e=>[...e])}function rD(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function bx(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 vx(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 Qi(t){return 1<<t-1}function xx(t){let e=0,n=t;for(;n;)n&=n-1,e++;return e}function iD(t){for(let e=1;e<=9;e++)if(t===Qi(e))return e;return 0}function um(t,e){return Math.floor(t/3)*3+Math.floor(e/3)}function dm(t){let e=0;for(let n of t)for(let r of n)r!==0&&e++;return e}function oD(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function Ix(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 wx(t,e){let n=!0,r=(i,o)=>{let s=0;for(let a of o){if(a===0)continue;let l=Qi(a);if(s&l){e.push(`${i} contains duplicate ${a}.`),n=!1;return}s|=l}};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 l=o;l<o+3;l++)s.push(t[a][l]);r(`Box ${Math.floor(i/3)*3+Math.floor(o/3)+1}`,s)}return n}function pm(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=Qi(s),l=um(i,o);if(e[i]&a||n[o]&a||r[l]&a)return null;e[i]|=a,n[o]|=a,r[l]|=a}return{rows:e,cols:n,boxes:r}}function fm(t,e,n,r,i){return 511&~(n[t]|r[e]|i[um(t,e)])}function kx(t,e,n){let r=pm(t);if(!r)return[];let i=gs(t),o=[],{rows:s,cols:a,boxes:l}=r,c=()=>{if(o.length>=e)return;let u=-1,d=-1,p=0,f=10;for(let m=0;m<9;m++){for(let h=0;h<9;h++){if(i[m][h]!==0)continue;let b=fm(m,h,s,a,l),S=xx(b);if(S===0)return;if(S<f&&(u=m,d=h,p=b,f=S,S===1))break}if(f===1)break}if(u===-1){o.push(gs(i));return}let g=Sx.filter(m=>p&Qi(m));n&&(g=vx(g,n));for(let m of g){let h=Qi(m),b=um(u,d);if(i[u][d]=m,s[u]|=h,a[d]|=h,l[b]|=h,c(),l[b]&=~h,a[d]&=~h,s[u]&=~h,i[u][d]=0,o.length>=e)return}};return c(),o}function sD(t){let e=rD(),n=bx(t),[r]=kx(e,1,n);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function aD(t){let e=pm(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=fm(n,r,e.rows,e.cols,e.boxes);if(xx(i)===1)return{row:n,col:r,value:iD(i)}}return null}function lD(t){let e=pm(t);if(!e)return null;let n=r=>{for(let i of Sx){let o=Qi(i),s=null;for(let a of r)if(!(t[a.row][a.col]!==0||!(fm(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 l=i;l<i+3;l++)o.push({row:a,col:l});let s=n(o);if(s)return s}return null}function hx(t){let e=gs(t),n=!1;for(;dm(e)<81;){let r=aD(e);if(r){e[r.row][r.col]=r.value;continue}let i=lD(e);if(i){n=!0,e[i.row][i.col]=i.value;continue}return"search"}return n?"hidden-singles":"singles"}function yx(t,e){let n={singles:0,"hidden-singles":1,search:2};return n[t]<=n[e]}function ec(t,e={}){let n=[];return Ix(t,n)?wx(t,n)?kx(t,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function cD(t){let e=[];if(!Ix(t,e))return{valid:!1,unique:!1,solution:null,errors:e};if(wx(t,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=ec(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]?gs(r[0]):null,errors:e}}function dD(t){let e=t.difficulty,n=nD[e];if(!n)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=oD(t.seed);for(let i=0;i<30;i++){let o=r+i*104729>>>0,s=bx(o),a=sD(o),l=gs(a),c=n.minGivens+Math.floor(s()*(n.maxGivens-n.minGivens+1)),u=vx(Array.from({length:81},(g,m)=>({row:Math.floor(m/9),col:m%9})),s);for(let g of u){if(dm(l)<=c)break;let m=l[g.row][g.col];if(l[g.row][g.col]=0,ec(l,{maxSolutions:2}).length!==1){l[g.row][g.col]=m;continue}let b=hx(l);yx(b,n.maxRating)||(l[g.row][g.col]=m)}let d=dm(l),p=hx(l);if(ec(l,{maxSolutions:2}).length===1&&d>=n.minGivens&&d<=n.maxGivens&&yx(p,n.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 Rx="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var uD={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 Px(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function Cx(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 eo(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 pD(t,e,n,r){return t>=0&&e>=0&&t<r&&e<n}function mm(t,e){return Array.from({length:e},()=>Array.from({length:t},()=>!0))}function $x(t,e,n,r){if(!n)return mm(t,e);if(!Array.isArray(n)||n.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),mm(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.`),mm(t,e);i.push(n[o].map(Boolean))}return i}function fD(t){let e=0;for(let n of t)for(let r of n)r&&e++;return e}function mD(t){return t.trim().normalize("NFC")}function gD(t){return t.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function Ex(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 hD(t,e,n,r,i,o,s,a){let l=eo(t),c=[];for(let u=0;u<l.length;u++){let d=e+r.dr*u,p=n+r.dc*u;if(!pD(d,p,o,s)||!i[d][p])return null;c.push({row:d,col:p,grapheme:l[u]})}return{word:t,graphemes:l,row:e,col:n,direction:r.direction,dr:r.dr,dc:r.dc,cells:c,jitter:a}}function Ax(t,e,n,r,i,o){let s=[];for(let a of e){let l=uD[a];for(let c=0;c<i;c++)for(let u=0;u<r;u++){let d=hD(t,c,u,l,n,r,i,o());d&&s.push(d)}}return s}function Nx(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=Ex(t.axes,t.allowBackwards);s.length===0&&e.push("At least one word direction must be enabled.");let a=$x(Math.max(1,i),Math.max(1,o),t.mask,e),l=fD(a);l===0&&e.push("Mask must contain at least one active cell.");let c=new Set,u=[];for(let f of t.words){let g=mD(f);if(g){if(/\s/u.test(g)){r.push({input:f,reason:"Words cannot contain whitespace."});continue}if(c.has(g)){r.push({input:f,reason:"Duplicate word."});continue}c.add(g),u.push(g)}}u.length===0&&e.push("Enter at least one word.");let d=Cx(Px(t.seed));if(e.length===0)for(let f=u.length-1;f>=0;f--){let g=u[f];Ax(g,s,a,i,o,d).length===0&&(r.push({input:g,reason:"No legal placement exists for the current size, mask, and directions."}),u.splice(f,1))}r.length>0&&e.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let p=Math.max(0,l);return u.length>p&&n.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:u,rejectedWords:r,errors:e,warnings:n,minWords:1,maxWords:p,activeCells:l,directions:s}}function yD(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 SD(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 bD(t,e){for(let n of e)t[n.row][n.col]=null}function Tx(t,e){let n=0;for(let r of e.cells)t[r.row][r.col]===r.grapheme&&n++;return n}function vD(t){return{word:t.word,row:t.row,col:t.col,direction:t.direction,path:t.cells.map(e=>({...e}))}}function xD(t){let e=t.fillerAlphabet??Rx,n=typeof e=="string"?eo(e):e.flatMap(i=>eo(i)),r=n.filter((i,o)=>i.trim()&&n.indexOf(i)===o);return r.length>0?r:eo(Rx)}function ID(t){let e=Math.floor(t.width),n=Math.floor(t.height),r=Px(t.seed),i=Nx({...t,width:e,height:n,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let o=$x(e,n,t.mask,[]),s=Math.max(1,Math.floor(t.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let l=Cx(r+a*104729>>>0),c=i.directions,u=new Map;for(let S of i.acceptedWords)u.set(S,Ax(S,c,o,e,n,l));let d=[...i.acceptedWords].sort((S,v)=>{let I=u.get(S)?.length??0,x=u.get(v)?.length??0;return I!==x?I-x:eo(v).length-eo(S).length}),p=Array.from({length:n},(S,v)=>Array.from({length:e},(I,x)=>o[v][x]?null:"")),f=[],g=new Map,m=0,h=S=>{if(++m>s)return!1;if(S>=d.length)return!0;let v=d[S],I=[...u.get(v)??[]].filter(x=>!yD(p,x)).sort((x,P)=>{let T=Tx(p,P)-Tx(p,x);if(T!==0)return T;let k=(g.get(x.direction)??0)-(g.get(P.direction)??0);return k!==0?k:x.jitter-P.jitter});for(let x of I){let P=SD(p,x);if(f.push(vD(x)),g.set(x.direction,(g.get(x.direction)??0)+1),h(S+1))return!0;g.set(x.direction,(g.get(x.direction)??1)-1),f.pop(),bD(p,P)}return!1};if(!h(0))continue;let b=xD(t);for(let S=0;S<n;S++)for(let v=0;v<e;v++)o[S][v]?p[S][v]===null&&(p[S][v]=b[Math.floor(l()*b.length)]):p[S][v]="";return{width:e,height:n,grid:p,mask:o.map(S=>[...S]),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 wD(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 kD(){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 RD(t,e,n){let r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(e)),o=kD();return Array.from({length:i},(s,a)=>Array.from({length:r},(l,c)=>{let u=(c+.5)/r,d=(a+.5)/i,p=u*2-1,f=d*2-1;switch(n){case"rectangle":return!0;case"circle":return p*p+f*f<=1;case"triangle":return d>=.08&&d<=.95&&Math.abs(p)<=d;case"diamond":return Math.abs(p)+Math.abs(f)<=1;case"star":return wD(u,d,o);case"heart":{let g=p*1.25,m=-f*1.25;return Math.pow(g*g+m*m-1,3)-g*g*m*m*m<=0}case"cross":return Math.abs(p)<=.32||Math.abs(f)<=.32;default:return!0}}))}export{lu as ANIMATION_MANAGER_INTERPOLATION_POLICY,Xf as Arrow,sm as Audio,iR as BROWSER_SVG_EXTENSION_URIS,vl as BUILTIN_MARKER_ID_MAP,AN as CANONICAL_NORMALIZATION_FAULT_POINTS,_r as CC_NS,BI as COLLAB_PROTOCOL_VERSION,Ge as COMMON_PROP_DEFAULTS,bm as COMMON_TRANSFORM_NODE_DEFAULTS,Ct as CURRENT_SCHEMA_VERSION,gi as CanonicalDocument,Df as Circle,Zf as Cloud,tm as Container,qr as ContainerShapeBuilder,Uf as Cross,Lt as DC_NS,ml as DEFAULT_COORDINATE_PRECISION,ai as DEFAULT_RICH_TEXT_STYLE,St as DOCUMENT_FIELDS,Ec as DOCUMENT_FIELD_LIVE_AUTHORITY,dl as DOCUMENT_INGEST_POLICIES,Rp as DOCUMENT_SECTION_ORDER,Yl as Document,Yl as DocumentBuilder,kr as DocumentModel,Oc as DocumentSession,ei as EASING_CURVES,Gn as EasingType,zf as Ellipse,Kf as Gear,yb as HEADLESS_SVG_STYLE_ENVIRONMENT,Yf as Heart,Qf as Hyperlink,Oe as IDENTITY_AFFINE,v0 as INGEST_APPLY_STAGES,a0 as INGEST_DIAGNOSTIC_CODES,ua as INGEST_DOCUMENT_ROOT_IDENTITY,da as INGEST_FEATURES,vd as INGEST_FEATURE_CAPABILITIES,xd as INGEST_PLAN_VERSION,$o as INGRESS_INTENTS,Es as INLINE_CHILD_CONTAINER_TYPES,cm as ImageShape,ma as IngestApplicationError,Xa as KNOWN_METADATA_PREFIXES,km as KNOWN_STATE_KEYS,Ac as LIBRARY_ASSEMBLY_KIND_ORDER,xv as LIBRARY_EMIT_ORDER,qf as Lightning,Lf as Line,Zl as LinearGradientBuilder,Wp as MARKER_HEIGHT,bl as MARKER_VIEWBOX,Hp as MARKER_WIDTH,iy as MATHML_EXTENSION_URI,Gp as MAX_COORDINATE_PRECISION,jb as MIGRATIONS,Vf as NGon,Xx as NON_WIRE_PROP_KEYS,hs as NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,rm as NestedSvg,xs as NodeSchemaRegistry,So as PAINT_SERVER_PASSTHROUGH_ATTR,Wa as PRESENTATION_SEMANTICS,gx as PUZZLE_DEFAULTS,am as Path,hm as PathCurveType,Mx as PathPointType,Ql as PatternBuilder,lm as Polyline,_i as RDF_NS,Up as RENDER_DIAGNOSTIC_CODES,jN as RENDER_FEATURES,UN as RENDER_FEATURE_CAPABILITIES,uN as RENDER_TARGETS,po as RICH_TEXT_STYLE_KEYS,Jl as RadialGradientBuilder,_f as Rectangle,Hf as Ring,Hh as SAXES_SVG_XML_PARSER_HOST,ym as SERIALIZED_SHAPE_STATE_KEYS,pN as SHAPE_ENVELOPE_KEYS,Sm as SHAPE_TRANSFORM_STATE_KEYS,zr as SVGSKETCH_NS,nk as SVGSKETCH_PATH_EXTENSIONS,Md as SVG_CONDITIONAL_PROCESSING_ATTRIBUTES,ly as SVG_IMPORT_CAPABILITY_OWNERS,W as SVG_NAMESPACE,RE as SVG_NS,ba as SVG_PRESENTATION_PROPERTIES,yr as SceneGraph,Ut as SceneNode,ut as ShapeBuilder,im as ShapeReference,Jf as SpeechBubble,Wf as Spiral,Ff as Square,jf as Star,cl as SvgImportError,Ao as SvgXmlParserHostError,em as Switch,Ya as TYPED_FIELD_PREDICATES,Bf as Text,yl as TextLayoutEngine,Of as Timeline,Mf as Track,Gf as Triangle,Ca as VARIANT_INTERPOLATION_POLICY,om as Video,nm as View,ry as XHTML_EXTENSION_URI,aa as addSmilPointsValues,st as affine,Vs as affineFromArray,at as affineToArray,y_ as almostEqualAffine,Ng as animationBackwardsFillTrack,$g as animationCycleDuration,Ag as animationTrackActiveEnd,Eg as animationTrackDocumentBegin,Be as applyAffineToPoint,Lc as applyAffineToVector,br as applyClipMaskGroupDelta,Vv as applyClipMaskPlanToShapes,zg as applyCssAnimationLonghandOverrides,ks as applyGuideDeltaOp,k0 as applyIngestPlan,Rs as applyMeasurementDeltaOp,uI as applyMetadataDeltaOp,$c as applyOpToSnapshot,yg as applyOpsInPlace,OI as applyOpsToSnapshot,Sg as applyOpsToSnapshotWithAccepted,Cs as applyRichTextFormat,fI as applyTextSplice,xl as applyTextTransform,Tg as applyTimingFunctionToKeyframe,yh as arcEndpointToCenter,Mv as areTracksTimingEquivalent,Hg as around,Ig as assembleLibraryDefs,tx as assembleSvgFromPlan,d0 as assertIngestFeatureRegistry,Db as assertIngestPolicyRegistry,yR as assertSvgImportCapabilityOwners,of as buildCompoundTransformValues,_u as buildFreshMetadataBlock,lI as buildGuideDeltaOps,Lu as buildManagedChildren,XS as buildManagedDescription,cI as buildMeasurementDeltaOps,dI as buildMetadataDeltaOps,fn as buildRenderPlan,Xr as buildSmilKeyframeData,hn as buildSmilKeyframes,tL as buildSvgDestinationIdentityIndex,lf as buildSymbolMaterializationPlan,Yg as canonicalPolygonTransformString,rn as canonicalTransformMatrix,gt as canonicalTransformString,Lr as classifySvgExternalAssetUrl,xc as clipMaskDefinitionFromGroup,Nn as clipMaskDefinitionsFromGroups,Gl as clipMaskGroupDefId,kt as clipMaskGroupDefinitionId,vc as clipMaskGroupIsRawBacked,ui as clipMaskGroupWithDefinition,gf as clipMaskOwnedDefIds,ng as collaborationResourceKey,qp as collectDocumentEnvelopeLibraryReferenceIds,ex as collectFontFamiliesFromPlan,Ri as collectMarkerReferences,Pl as collectReferencedLibraryDefs,b0 as collectReferencedMarkerIds,Pp as collectUnknownDocumentFields,vs as compareOrderKeys,Ks as composeLegacyTransformMatrix,Wc as computeArrowVertices,qc as computeCloudPath,Hc as computeCrossVertices,nd as computeDashArray,td as computeFlowchartBoxPath,Qc as computeGearPath,dh as computeGearVertices,Yc as computeHeartPath,Xc as computeLightningVertices,ea as computePolygonVertices,ed as computeRectanglePath,Zc as computeRingPath,Kc as computeSpeechBubbleVertices,Jc as computeSpiralPath,Cr as computeSplinePath,Uc as computeStarVertices,oF as computeSvgViewportMatrix,$t as containerTransformNeedsContentPivot,Ho as createDocument,oi as createSceneNode,fA as createShape,nL as createSvgDestinationIdAllocator,Gi as createViewbox,RD as createWordSearchPrimitiveMask,Fg as cssAnimationFillField,zo as cssNamedColorToRgb,sd as cubicBezierExtent1D,Dc as cubicBezierToEasingFields,Wn as customPatternDefToLibraryDef,gc as declaredRichTextDeltaKeys,xo as decodeCssEscapes,Hs as decomposeAffine2D,$D as defaultVariableMode,vI as deriveRichTextFormatRanges,Hn as deriveSegments,pI as deriveTextSplice,ZA as documentObjectBounds,_I as downTranslateAnimationKeyframeOps,LI as downTranslateCollectionMoveOps,GI as downTranslateDocumentFieldOps,zI as downTranslateScenePlaceOps,FI as downTranslateTextFormatOps,Sh as ellipticalArcBounds,Nc as emptyDocumentMetadata,ue as escXml,Pg as evaluateParsedTimingFunction,cR as evaluateSvgConditionalProcessing,Bp as extractVariables,VS as fillPaintServerReference,xE as filterAttr,$S as filterChainExtendsBounds,Eu as filterDefinitionEnvelope,Ba as filterReferenceValue,If as finalizeRenderPlan,mi as findShapeById,u0 as fingerprintIngestSource,sc as flattenShapeStateTree,hr as flattenStateExtra,ts as flattenUnknownDocumentFields,Xg as foldLegacyAncestorTransformIntoMatrix,S0 as forEachLibraryRefInState,y0 as forEachMarkerRefInState,fa as forEachReachableShape,Id as forEachShapeInLibraryDefs,aI as formatOperationValidationIssues,Zp as formatSmilKeySpline,It as formatSmilKeyTime,p0 as freezeIngestPlan,Ns as freezeSiblingOrderKeys,Nf as generateCode,dx as generateCodeWithDiagnostics,Af as generateCssCode,Ef as generateD3Code,K as generateId,Ru as generatePatternSvgContent,tD as generatePuzzlePieces,Cf as generateReactCode,dD as generateSudokuPuzzle,Pf as generateSvgCode,$f as generateVueCode,ID as generateWordSearch,uM as getBuiltInMarkerDefs,TD as getEasingCubicBezier,Vp as getEffectivePrecision,c0 as getIngestFeatureCapability,ga as getIngestFieldPolicy,Ev as getKeyframeCubicBezier,KS as getLicenseLabel,WS as getLicenseUrl,Wi as getMarkerDescriptors,za as getPatternElements,Po as getShapeGeometryKernel,tf as getSmilAdditive,Xi as getSmilBeginValue,Yi as getSmilFillMode,nf as getSmilMotionKeyPoints,ef as getSmilRepeatCount,Qp as getSmilSetBeginValue,Kr as getSmilTrackDuration,Ar as getSvgPropertySemantics,E as getSvgSourceAttribute,Ee as getSvgSourceHref,Ex as getWordSearchDirections,zu as hasAnyTypedMetadataField,lt as hasSvgSourceAttribute,kp as importSvg,Ob as importSvgWithDiagnostics,Ko as indexLibraryDefinitions,ic as initialOrderKeys,Sf as injectClipMaskReference,lh as inspectCssTransformValue,Jy as interpolateAngle,RP as interpolateCharOffsetArray,eS as interpolateColor,v1 as interpolateDasharrayLists,TP as interpolateGradient,au as interpolateNumericArray,S1 as interpolatePathData,PP as interpolatePlainObject,wP as interpolatePointArray,b1 as interpolatePolylinePoints,DP as interpolateShapeTrees,kP as interpolateSplinePointArray,S_ as invertAffine,h1 as isColorValue,su as isCssNamedColor,Jp as isDefaultKeyPoints,El as isDefaultKeyTimes,Yn as isFiniteAffineArray,Xy as isGradientLike,Kt as isIdentityAffine,Nv as isIdentityLinearSplines,Al as isIndefiniteSetTrack,ar as isNumericArray,$s as isReusablePatternTile,Nl as isSetSequenceTrack,Fd as isSvgPresentationProperty,bs as isValidOrderKey,so as keyBetween,rc as keysBetween,cM as layoutText,pa as legacyEndpointMarkerId,Ie as lerpNumber,XO as linearGradient,Cu as linearGradientEnvelope,Nx as lintWordSearchOptions,d_ as mapAnimationTrackTime,XI as matchCubicBezierToPreset,DI as materializeSceneTreeOrderKeys,Ws as matrixTransformPart,RI as maxCollaborationTimestamp,uo as mergeRichTextStyle,Cp as migrateLegacySplineShape,mN as migrateLegacySplines,pl as migrateLegacyViewboxesToViews,is as migrateSnapshot,Vb as migrateV6toV7,jl as motionPathD,co as moveResourceById,de as multiplyAffine,ZE as mutateSvgClipMaskDefinitionMarkup,se as nodeSchemas,Ht as normalizeClipMaskGroups,rs as normalizeLegacyShapeAliases,Ms as normalizePaintServerDef,li as normalizeRichTextRuns,En as normalizeRichTextStyle,Ps as normalizeRichTextStyleDelta,Ok as normalizeSmilPointsValue,FN as normalizeSnapshotStructure,VN as normalizeSnapshotToCanonicalDocument,Ap as normalizeSnapshotToInlineChildren,it as orderSiblings,Os as paintServerDefsFromRawFragments,$a as parseColor,_c as parseCssAnimationShorthand,hi as parseCssTimingFunction,oh as parseCssTransformOrigin,zp as parseDocument,Yb as parseDocumentWithDiagnostics,y1 as parseInterpolationNumbers,Mo as parsePreserveAspectRatio,pd as parseSmilAdditive,Kn as parseSmilClockValue,fd as parseSmilDuration,Th as parseSmilFillField,tr as parseSmilKeySplines,er as parseSmilKeyTimes,Rh as parseSmilRepeatSettings,$r as parseSmilValues,Ot as parseSvgAbsoluteLength,Se as parseSvgLength,Fc as parseSvgLengthList,ot as parseSvgLengthToken,Qn as parseSvgPathData,Pd as parseSvgRootFrame,Sn as parseSvgSourceDocument,RT as parseSvgStyleAttribute,Dt as parseSvgTransformList,Xe as parseSvgViewBox,QN as parseVariableArgs,gD as parseWordSearchWords,oc as partitionShapeStateTree,Is as partitionStateExtra,ns as partitionUnknownDocumentFields,IP as pathCommandStructuresMatch,sn as pathDataBounds,qO as pattern,Pu as patternDefinitionEnvelope,fo as patternLibraryDefToCustomPatternDef,Ym as patternTileSize,Fs as pickCssAnimationListItem,yf as planClipMaskGroups,cA as planSnapshotExternalEffects,Jd as planSvgAnimations,jd as planSvgAuthoredAttributes,gu as planSvgClipMasks,Od as planSvgConditionalProcessing,Ad as planSvgContainerHierarchy,$d as planSvgEmbeddedFrames,ip as planSvgExternalEffects,wu as planSvgFilters,Su as planSvgGradients,cp as planSvgImport,ou as planSvgLeafGeometry,hu as planSvgMarkers,Xu as planSvgMetadata,xu as planSvgPaintServerDefinitions,bu as planSvgPatterns,Vd as planSvgResourceDependencies,ku as planSvgScripts,Dd as planSvgSourceIdentifiers,qd as planSvgStyleCascade,Ld as planSvgSymbolUses,_d as planSvgUseOccurrences,Cd as planSvgViews,rf as planTransformFusion,LO as planVariantTransitionsCss,zO as planVariantTransitionsSmil,BO as planVariantTransitionsWaapi,qa as prepareSvgAuthorCssForLiveProjection,cb as prepareSvgExternalAssetUrlForLiveProjection,XE as prepareSvgMarkupForLiveProjection,jh as prepareSvgXmlSource,Wh as preserveAspectRatioAlignFactor,ch as projectCssTransformStops,Vo as projectPresentation,Mu as projectPresentationEntry,yo as projectSceneTreeOntoClipMaskGroups,fi as projectSceneTreeOntoShapes,zh as projectSvgAnimationPlan,hd as projectSvgAnimationTimeline,Mb as projectSvgImportToSnapshot,YS as promoteManagedDescription,TI as promoteRebasedShapeUpdateClock,Vl as pruneAndWrapSubtree,ad as quadraticBezierExtent1D,YO as radialGradient,$u as radialGradientEnvelope,bI as rebaseRichTextFormatRanges,II as rebaseRichTextRuns,$l as reflectCubicBezier,Ak as registeredShapeGeometryTypes,mt as removeResourceById,dc as removeResourceByKey,pc as removeResourceByName,pg as removeTrackKeyframe,af as renderAnimationElements,Yp as renderBuiltinMarkerDefs,rv as renderCircle,Gu as renderDescriptiveElements,pf as renderDocumentScripts,uf as renderDocumentStyles,iv as renderEllipse,vE as renderFilterDefs,La as renderFilterElement,Cv as renderFilterLibraryDef,Au as renderFilterPrimitive,DS as renderFilterPrimitivesForType,gv as renderFlowchartBox,uv as renderForeignObject,NM as renderGradientDefs,dv as renderImage,Iv as renderLibraryDef,Tl as renderLibraryDefs,sv as renderLine,ls as renderLinearGradient,Rv as renderLinearGradientLibraryDef,kv as renderMarkerLibraryDef,mf as renderPaintServerDefs,Pv as renderPatternLibraryDef,Et as renderPlanDefsBody,hv as renderPolygonShape,cv as renderPolyline,cs as renderRadialGradient,Tv as renderRadialGradientLibraryDef,ov as renderRectangle,MM as renderReferencedLibraryDefs,ds as renderResolvedSymbolLibraryDef,pn as renderShape,Wr as renderShapeContextForLibrary,lv as renderSpline,OS as renderSvgPrimitiveChainFilter,mv as renderSymbolInstance,wv as renderSymbolLibraryDef,df as renderTemplateVariablesStyle,av as renderText,ms as renderToSvg,Wl as renderToSvgWithDiagnostics,Ic as replaceClipMaskDefinition,vr as replaceClipMaskGroupsInSceneTree,VI as replaySceneTreePlacements,Xo as resolveContainerTransform,il as resolveContainerTransformFromContentBounds,Dg as resolveCssAnimationEasingType,jr as resolveEmbeddedSvgTransform,KA as resolveEmbeddedSvgViewportFrameBounds,Ip as resolveInlineContainerTransform,Fu as resolveMetadataQName,yI as resolveRichTextStyleAt,Zt as resolveShapeGeometry,bp as resolveShapeLocalObjectBounds,es as resolveShapeObjectBounds,vp as resolveShapeReferenceTransform,hS as resolveSvgGradientGeometry,Xn as resolveSvgLengthToken,bS as resolveSvgPatternTile,Ti as resolveSvgViewport,Ii as resolveSymbolInstanceContent,bk as resolveSymbolInstanceShapes,xp as resolveSymbolInstanceTransform,qo as resolveSymbolViewport,HN as rewriteDocumentEmbeddedPayloads,xf as rewriteIdReferencesInMarkup,Op as rewriteShapeStateEmbeddedPayloads,iT as rewriteSvgResourceReferenceValue,ss as richTextFontVariantCss,Xm as richTextLineSpans,di as richTextRunsFromState,fc as richTextStyleDelta,yc as richTextStyleDeltasEqual,Un as richTextStylesEqual,Kp as richTextTspanAttributes,Bu as rootMetadataAttrs,bo as rootPaintServerDefId,wo as rotateAffine,In as roundCoord,Jv as roundMarkupCoordinates,gl as roundNumberString,qb as roundSerializedShape,rM as roundSnapshot,ci as runsFromSegments,bc as sanitizeRichTextFormatRanges,Ln as sanitizeXmlId,bi as scaleAffine,mn as scanCssFunctionTokens,Dn as scanCssLocalUrlTokens,NI as senderCorrectionsForOp,od as serializeSvgPathData,ur as serializedPresentationReader,sa as shapeLocalObjectBounds,ud as shapeLocalObjectCenter,gp as shapeObjectBoundsInSpace,js as skewXAffine,Us as skewYAffine,Ml as smilKeyframeAttributes,Vr as snapshotBoundsView,Av as solveCubicBezier,ec as solveSudoku,hk as splinePathBounds,_s as splitCssAnimationList,yi as splitCssTopLevel,On as splitCssTopLevelRanges,Hl as splitTopLevelElements,Dp as stringifyDocument,Ll as stripAnimationDeclarations,jS as strokePaintServerReference,_p as substituteString,fl as substituteVariables,To as symbolInstanceTargetId,_g as synthesizeCssAnimationShorthand,Bl as templateVariablesCss,Ts as transformSplice,ck as transformSvgPathData,_e as translateAffine,lk as translateSvgPathData,Xt as tryParseSvgTransformList,ft as upsertResourceById,cc as upsertResourceByKey,uc as upsertResourceByName,ug as upsertTrackKeyframe,oI as validateDocumentOperations,lc as validateOperation,sI as validatePresenceOperation,Br as validateSnapshot,cD as validateSudokuPuzzle,gn as verticesToPath,tn as visitShapeTree,Nt as visitSnapshotShapeTrees};