svgfusion-cmd 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -571,7 +571,7 @@ ${r.map((a,o)=>a.split("").map((u,c)=>{let l=(i-1-o)/(i-1),h=(c/(a.length-1||1)+
571
571
  ${e.blue}React${e.reset} ${e.gray}\u2022${e.reset} ${e.green}Vue 3${e.reset} ${e.gray}\u2022${e.reset} ${e.blue}TypeScript${e.reset}
572
572
 
573
573
  ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${e.reset}
574
- `}var F1e=(e=>typeof cC<"u"?cC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof cC<"u"?cC:t)[r]}):e)(function(e){if(typeof cC<"u")return cC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Jyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof F1e<"u"?F1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},Wyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},zyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Hyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Gyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
574
+ `}var F1e=(e=>typeof cC<"u"?cC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof cC<"u"?cC:t)[r]}):e)(function(e){if(typeof cC<"u")return cC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Jyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof F1e<"u"?F1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use",feblend:"feBlend",feflood:"feFlood",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedropshadow:"feDropShadow",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fespecularlighting:"feSpecularLighting",fetile:"feTile",feturbulence:"feTurbulence",filter:"filter",g:"g",image:"image",line:"line",marker:"marker",mask:"mask",metadata:"metadata",path:"path",pattern:"pattern",polygon:"polygon",polyline:"polyline",rect:"rect",stop:"stop",svg:"svg",text:"text",tspan:"tspan",view:"view",circle:"circle",ellipse:"ellipse"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},Wyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},zyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Hyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Gyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
575
575
  `)}},Kyt=class{constructor(e){this.options=e;}apply(e){return this.options.enabled?this.normalizeElements(e):e}normalizeElements(e){return e.map(t=>this.transformElement(t,r=>{let i={...r.attributes};if(this.isDrawableElement(r.tag)){let a=r.attributes.fill!==void 0&&r.attributes.fill!=="",o=r.attributes.stroke!==void 0&&r.attributes.stroke!=="";a&&!o&&(i.stroke="none"),o&&!a&&(i.fill="none");}return {...r,attributes:i}}))}transformElement(e,t){let r=t(e);return r.children&&(r.children=r.children.map(i=>this.transformElement(i,t))),r}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}},Xyt=class{transform(e,t={}){let{optimize:r=true,splitColors:i=false,splitStrokeWidths:a=false,fixedStrokeWidth:o=false,normalizeFillStroke:u=false,accessibility:c=true,removeComments:l=true,removeDuplicates:h=true,minifyPaths:p=false}=t,f=this.deepCloneAst(e),v=[],x=[],A=[];return r&&(this.applyOptimizations(f,{removeComments:l,removeDuplicates:h,minifyPaths:p&&!i}),v.push("optimization")),i&&(x=this.applySplitColors(f),v.push("split-colors")),a&&(A=this.applySplitStrokeWidths(f),v.push("split-stroke-widths")),o&&(this.applyFixedStrokeWidth(f),v.push("fixed-stroke-width")),u&&(this.applyFillStrokeNormalization(f),v.push("normalize-fill-stroke")),c&&(this.applyAccessibility(f),v.push("accessibility")),{ast:f,colorMappings:x,strokeWidthMappings:A,metadata:{originalColors:x.map(P=>P.originalColor),originalStrokeWidths:A.map(P=>P.originalStrokeWidth),optimizationApplied:r,features:v,hasClassAttributes:this.hasClassAttributes(f)}}}applySplitColors(e){let t=new Wyt({generateClasses:true,colorPrefix:"color"}).apply(e.root);return e.root=t.processedElement,t.mappings}applyFixedStrokeWidth(e){let t=new zyt({onlyIfStrokePresent:false,preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyAccessibility(e){let t=new Gyt({addRole:true,addTitle:true,addDesc:true,defaultRole:"img",preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyFillStrokeNormalization(e){let t=new Kyt({enabled:true});e.root.children=t.apply(e.root.children);}applyOptimizations(e,t){t.removeDuplicates&&this.removeDuplicateElements(e),t.minifyPaths&&this.minifyPaths(e),this.removeEmptyGroups(e);}removeDuplicateElements(e){}minifyPaths(e){this.traverseElements(e.root,t=>{t.tag==="path"&&t.attributes.d&&(t.attributes.d=t.attributes.d.replace(/\s+/g," ").replace(/([MLHVCSQTAZ])\s+/gi,"$1").trim());});}removeEmptyGroups(e){let t=r=>(r.children=r.children.filter(t),!(r.tag==="g"&&r.children.length===0&&!r.content));e.root.children=e.root.children.filter(t);}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(.+\)$/.test(e)||/^hsla?\(.+\)$/.test(e)}deepCloneAst(e){return {...e,root:this.deepCloneElement(e.root)}}deepCloneElement(e){return {...e,attributes:{...e.attributes},children:e.children.map(t=>this.deepCloneElement(t))}}hasClassAttributes(e){let t=r=>r.attributes.class||r.attributes.className?true:r.children.some(i=>t(i));return t(e.root)}applySplitStrokeWidths(e){let t=new Hyt({generateClasses:true,strokeWidthPrefix:"strokeWidth"}).apply(e.root);return e.root=t.processedElement,t.mappings}},kM=class{options;constructor(e={}){this.options={typescript:true,memo:true,forwardRef:true,exportDefault:true,componentName:"Icon",prefix:"",suffix:"",includeTypes:true,...e};}astToJsx(e){return this.elementToJsx(e.root,0)}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsx(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
576
576
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
577
577
  `),h+=`
@@ -590,16 +590,16 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
590
590
  }`}generatePropTypes(e,t,r){let i=this.getComponentName(),a=["title: PropTypes.string,","titleId: PropTypes.string,","desc: PropTypes.string,","descId: PropTypes.string,","size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","className: PropTypes.string,","style: PropTypes.object,","width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),"],o=this.generateColorProps(e);o&&a.push(o);let u=this.generateStrokeWidthProps(t);return u&&a.push(u),r.includes("fixed-stroke-width")&&a.push("isFixedStrokeWidth: PropTypes.bool,"),`${i}.propTypes = {
591
591
  ${a.join(`
592
592
  `)}
593
- };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = "24"',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
593
+ };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = ""',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
594
594
  ${p.filter(T=>!U.includes(T)).join(`,
595
595
  `)},
596
596
  ${P},
597
597
  ...svgProps
598
- }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(q=>this.elementToJsx(q,1)).join(`
599
- `);return `const ${t} = (${$}: ${T}${B}) => {
598
+ }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(H=>this.elementToJsx(H,1)).join(`
599
+ `),q=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}: ${T}${B}) => {
600
600
  const computedSize = {
601
- width: svgProps.width || size,
602
- height: svgProps.height || size
601
+ width: svgProps.width || size || '${q.width}',
602
+ height: svgProps.height || size || '${q.height}'
603
603
  };
604
604
 
605
605
  return (
@@ -614,12 +614,15 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
614
614
  ${L}
615
615
  </svg>
616
616
  );
617
- };`}else {let T=e.ast.root.children.map(B=>this.elementToJsx(B,1)).join(`
618
- `);return `const ${t} = (${$}) => {
619
- const computedSize = size ? { width: size, height: size } : {};
617
+ };`}else {let T=e.ast.root.children.map(L=>this.elementToJsx(L,1)).join(`
618
+ `),B=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}) => {
619
+ const computedSize = {
620
+ width: svgProps.width || size || '${B.width}',
621
+ height: svgProps.height || size || '${B.height}'
622
+ };
620
623
 
621
624
  return (
622
- <svg ${F}{...computedSize} {...svgProps}>
625
+ <svg ${F}{...svgProps} {...computedSize}>
623
626
  ${S}
624
627
  ${O}
625
628
  ${T}
@@ -631,7 +634,7 @@ ${T}
631
634
  `:""}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsxWithClasses(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
632
635
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
633
636
  `),h+=`
634
- `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=k1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=lZ(a);t[u]=o;}}}),t}};ms();var uur=Object.defineProperty,lur=(e,t,r)=>t in e?uur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,cur=(e,t,r)=>lur(e,t+"",r),G9e=class extends kM{constructor(e={}){super(e),cur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(hue(),fue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
637
+ `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=k1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=lZ(a);t[u]=o;}}}),t}};ms();var uur=Object.defineProperty,lur=(e,t,r)=>t in e?uur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,cur=(e,t,r)=>lur(e,t+"",r),G9e=class extends kM{constructor(e={}){super(e),cur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(hue(),fue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
635
638
  ${t}
636
639
  </template>
637
640
 
@@ -644,17 +647,17 @@ ${this.vueOptions.scriptSetup&&this.vueOptions.useDefineOptions?`defineOptions({
644
647
  ${i?`<style scoped>
645
648
  ${i}
646
649
  </style>`:""}`}generateJSComponent(e){return this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateTemplate(e){let{ast:t}=e,r=this.generateSvgAttributes(t),i=t.root.children.map(a=>this.elementToVueTemplate(a,2)).join(`
647
- `);return ` <svg${r} v-bind="$attrs" :width="computedWidth" :height="computedHeight">
650
+ `);return ` <svg${r} v-bind="$attrs" :width="computedSize.width" :height="computedSize.height">
648
651
  <title v-if="props.title" :id="props.titleId">{{ props.title }}</title>
649
652
  <desc v-if="props.desc" :id="props.descId">{{ props.desc }}</desc>
650
653
  ${i}
651
654
  </svg>`}elementToVueTemplate(e,t=0){let r=" ".repeat(t),{tag:i,attributes:a,children:o,content:u}=e,c=[],l=[],h="class"in a;if(Object.entries(a).forEach(([v,x])=>{if(v==="vector-effect"&&x==="non-scaling-stroke")c.push(`:vector-effect="props.isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'"`);else if(v==="style"){let A=this.parseStyleStringForVue(x);c.push(`:style="${A}"`);let P=this.extractClassVarsFromStyle(x);l.push(...P);}else if(x.startsWith("{")&&x.endsWith("}")){let A=x.slice(1,-1);if(c.push(`:${v}="props.${A}"`),v==="fill"||v==="stroke"||v==="stroke-width"){let P=`${A}Class`;l.push(`props.${P}`);}}else c.push(`${v}="${x}"`);}),l.length>0){let v=a.class;v?c.push(`:class="[${l.join(", ")}, '${v}']"`):c.push(`:class="[${l.join(", ")}]"`);}else if(h){let v=a.class;v&&c.push(`class="${v}"`);}let p=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${p} />`;let f=`${r}<${i}${p}>`;return u&&(f+=u),o.length>0&&(f+=`
652
655
  `,f+=o.map(v=>this.elementToVueTemplate(v,t+1)).join(`
653
656
  `),f+=`
654
- `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let o=this.generateColorPropsInterface(t);o&&a.push(o);let u=this.generateStrokeWidthPropsInterface(r);u&&a.push(u),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "24" },');return this.vueOptions.typescript&&a.push(' size: "24",'),t.forEach(o=>{let u=o.variableName,c=o.originalColor,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: String, default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),r.forEach(o=>{let u=o.variableName,c=o.originalStrokeWidth,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: [String, Number], default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push(""),a.push("const computedWidth = computed(() => props.width || props.size);"),a.push("const computedHeight = computed(() => props.height || props.size);"),a.join(`
655
- `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {"),o.push(" const computedWidth = computed(() => props.width || props.size);"),o.push(" const computedHeight = computed(() => props.height || props.size);"),o.push(" return { computedWidth, computedHeight };"),o.push(" },"),o.push("});"),o.join(`
656
- `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {"),o.push(" computedWidth() {"),o.push(" return this.width || this.size;"),o.push(" },"),o.push(" computedHeight() {"),o.push(" return this.height || this.size;"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
657
- `)}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
657
+ `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let u=this.generateColorPropsInterface(t);u&&a.push(u);let c=this.generateStrokeWidthPropsInterface(r);c&&a.push(c),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "" },');this.vueOptions.typescript&&a.push(' size: "",'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: String, default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: [String, Number], default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push("");let o=this.getViewBoxDimensions(e.ast);return a.push("const computedSize = computed(() => ({"),a.push(` width: props.width || props.size || '${o.width}',`),a.push(` height: props.height || props.size || '${o.height}'`),a.push("}));"),a.join(`
658
+ `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {");let u=this.getViewBoxDimensions(e.ast);return o.push(" const computedSize = computed(() => ({"),o.push(` width: props.width || props.size || '${u.width}',`),o.push(` height: props.height || props.size || '${u.height}'`),o.push(" }));"),o.push(" return { computedSize };"),o.push(" },"),o.push("});"),o.join(`
659
+ `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {");let u=this.getViewBoxDimensions(e.ast);return o.push(" computedSize() {"),o.push(" return {"),o.push(` width: this.width || this.size || '${u.width}',`),o.push(` height: this.height || this.size || '${u.height}'`),o.push(" };"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
660
+ `)}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
658
661
  ${i}?: string;`}).join(`
659
662
  `)}generateStrokeWidthPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string | number;
660
663
  ${i}?: string;`}).join(`
package/dist/index.mjs CHANGED
@@ -571,7 +571,7 @@ ${r.map((a,o)=>a.split("").map((u,c)=>{let l=(i-1-o)/(i-1),h=(c/(a.length-1||1)+
571
571
  ${e.blue}React${e.reset} ${e.gray}\u2022${e.reset} ${e.green}Vue 3${e.reset} ${e.gray}\u2022${e.reset} ${e.blue}TypeScript${e.reset}
572
572
 
573
573
  ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${e.reset}
574
- `}var P1e=(e=>typeof pC<"u"?pC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof pC<"u"?pC:t)[r]}):e)(function(e){if(typeof pC<"u")return pC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Jyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof P1e<"u"?P1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},Wyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},zyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Hyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Gyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
574
+ `}var P1e=(e=>typeof pC<"u"?pC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof pC<"u"?pC:t)[r]}):e)(function(e){if(typeof pC<"u")return pC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Jyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof P1e<"u"?P1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use",feblend:"feBlend",feflood:"feFlood",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedropshadow:"feDropShadow",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fespecularlighting:"feSpecularLighting",fetile:"feTile",feturbulence:"feTurbulence",filter:"filter",g:"g",image:"image",line:"line",marker:"marker",mask:"mask",metadata:"metadata",path:"path",pattern:"pattern",polygon:"polygon",polyline:"polyline",rect:"rect",stop:"stop",svg:"svg",text:"text",tspan:"tspan",view:"view",circle:"circle",ellipse:"ellipse"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},Wyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},zyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Hyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Gyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
575
575
  `)}},Kyt=class{constructor(e){this.options=e;}apply(e){return this.options.enabled?this.normalizeElements(e):e}normalizeElements(e){return e.map(t=>this.transformElement(t,r=>{let i={...r.attributes};if(this.isDrawableElement(r.tag)){let a=r.attributes.fill!==void 0&&r.attributes.fill!=="",o=r.attributes.stroke!==void 0&&r.attributes.stroke!=="";a&&!o&&(i.stroke="none"),o&&!a&&(i.fill="none");}return {...r,attributes:i}}))}transformElement(e,t){let r=t(e);return r.children&&(r.children=r.children.map(i=>this.transformElement(i,t))),r}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}},Xyt=class{transform(e,t={}){let{optimize:r=true,splitColors:i=false,splitStrokeWidths:a=false,fixedStrokeWidth:o=false,normalizeFillStroke:u=false,accessibility:c=true,removeComments:l=true,removeDuplicates:h=true,minifyPaths:p=false}=t,f=this.deepCloneAst(e),v=[],x=[],A=[];return r&&(this.applyOptimizations(f,{removeComments:l,removeDuplicates:h,minifyPaths:p&&!i}),v.push("optimization")),i&&(x=this.applySplitColors(f),v.push("split-colors")),a&&(A=this.applySplitStrokeWidths(f),v.push("split-stroke-widths")),o&&(this.applyFixedStrokeWidth(f),v.push("fixed-stroke-width")),u&&(this.applyFillStrokeNormalization(f),v.push("normalize-fill-stroke")),c&&(this.applyAccessibility(f),v.push("accessibility")),{ast:f,colorMappings:x,strokeWidthMappings:A,metadata:{originalColors:x.map(P=>P.originalColor),originalStrokeWidths:A.map(P=>P.originalStrokeWidth),optimizationApplied:r,features:v,hasClassAttributes:this.hasClassAttributes(f)}}}applySplitColors(e){let t=new Wyt({generateClasses:true,colorPrefix:"color"}).apply(e.root);return e.root=t.processedElement,t.mappings}applyFixedStrokeWidth(e){let t=new zyt({onlyIfStrokePresent:false,preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyAccessibility(e){let t=new Gyt({addRole:true,addTitle:true,addDesc:true,defaultRole:"img",preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyFillStrokeNormalization(e){let t=new Kyt({enabled:true});e.root.children=t.apply(e.root.children);}applyOptimizations(e,t){t.removeDuplicates&&this.removeDuplicateElements(e),t.minifyPaths&&this.minifyPaths(e),this.removeEmptyGroups(e);}removeDuplicateElements(e){}minifyPaths(e){this.traverseElements(e.root,t=>{t.tag==="path"&&t.attributes.d&&(t.attributes.d=t.attributes.d.replace(/\s+/g," ").replace(/([MLHVCSQTAZ])\s+/gi,"$1").trim());});}removeEmptyGroups(e){let t=r=>(r.children=r.children.filter(t),!(r.tag==="g"&&r.children.length===0&&!r.content));e.root.children=e.root.children.filter(t);}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(.+\)$/.test(e)||/^hsla?\(.+\)$/.test(e)}deepCloneAst(e){return {...e,root:this.deepCloneElement(e.root)}}deepCloneElement(e){return {...e,attributes:{...e.attributes},children:e.children.map(t=>this.deepCloneElement(t))}}hasClassAttributes(e){let t=r=>r.attributes.class||r.attributes.className?true:r.children.some(i=>t(i));return t(e.root)}applySplitStrokeWidths(e){let t=new Hyt({generateClasses:true,strokeWidthPrefix:"strokeWidth"}).apply(e.root);return e.root=t.processedElement,t.mappings}},TM=class{options;constructor(e={}){this.options={typescript:true,memo:true,forwardRef:true,exportDefault:true,componentName:"Icon",prefix:"",suffix:"",includeTypes:true,...e};}astToJsx(e){return this.elementToJsx(e.root,0)}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsx(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
576
576
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
577
577
  `),h+=`
@@ -590,16 +590,16 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
590
590
  }`}generatePropTypes(e,t,r){let i=this.getComponentName(),a=["title: PropTypes.string,","titleId: PropTypes.string,","desc: PropTypes.string,","descId: PropTypes.string,","size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","className: PropTypes.string,","style: PropTypes.object,","width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),"],o=this.generateColorProps(e);o&&a.push(o);let u=this.generateStrokeWidthProps(t);return u&&a.push(u),r.includes("fixed-stroke-width")&&a.push("isFixedStrokeWidth: PropTypes.bool,"),`${i}.propTypes = {
591
591
  ${a.join(`
592
592
  `)}
593
- };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = "24"',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
593
+ };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = ""',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
594
594
  ${p.filter(T=>!U.includes(T)).join(`,
595
595
  `)},
596
596
  ${P},
597
597
  ...svgProps
598
- }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(q=>this.elementToJsx(q,1)).join(`
599
- `);return `const ${t} = (${$}: ${T}${B}) => {
598
+ }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(H=>this.elementToJsx(H,1)).join(`
599
+ `),q=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}: ${T}${B}) => {
600
600
  const computedSize = {
601
- width: svgProps.width || size,
602
- height: svgProps.height || size
601
+ width: svgProps.width || size || '${q.width}',
602
+ height: svgProps.height || size || '${q.height}'
603
603
  };
604
604
 
605
605
  return (
@@ -614,12 +614,15 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
614
614
  ${L}
615
615
  </svg>
616
616
  );
617
- };`}else {let T=e.ast.root.children.map(B=>this.elementToJsx(B,1)).join(`
618
- `);return `const ${t} = (${$}) => {
619
- const computedSize = size ? { width: size, height: size } : {};
617
+ };`}else {let T=e.ast.root.children.map(L=>this.elementToJsx(L,1)).join(`
618
+ `),B=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}) => {
619
+ const computedSize = {
620
+ width: svgProps.width || size || '${B.width}',
621
+ height: svgProps.height || size || '${B.height}'
622
+ };
620
623
 
621
624
  return (
622
- <svg ${F}{...computedSize} {...svgProps}>
625
+ <svg ${F}{...svgProps} {...computedSize}>
623
626
  ${S}
624
627
  ${O}
625
628
  ${T}
@@ -631,7 +634,7 @@ ${T}
631
634
  `:""}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsxWithClasses(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
632
635
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
633
636
  `),h+=`
634
- `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=T1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=cZ(a);t[u]=o;}}}),t}};ms();var uur=Object.defineProperty,lur=(e,t,r)=>t in e?uur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,cur=(e,t,r)=>lur(e,t+"",r),K9e=class extends TM{constructor(e={}){super(e),cur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(mue(),hue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
637
+ `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=T1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=cZ(a);t[u]=o;}}}),t}};ms();var uur=Object.defineProperty,lur=(e,t,r)=>t in e?uur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,cur=(e,t,r)=>lur(e,t+"",r),K9e=class extends TM{constructor(e={}){super(e),cur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(mue(),hue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
635
638
  ${t}
636
639
  </template>
637
640
 
@@ -644,17 +647,17 @@ ${this.vueOptions.scriptSetup&&this.vueOptions.useDefineOptions?`defineOptions({
644
647
  ${i?`<style scoped>
645
648
  ${i}
646
649
  </style>`:""}`}generateJSComponent(e){return this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateTemplate(e){let{ast:t}=e,r=this.generateSvgAttributes(t),i=t.root.children.map(a=>this.elementToVueTemplate(a,2)).join(`
647
- `);return ` <svg${r} v-bind="$attrs" :width="computedWidth" :height="computedHeight">
650
+ `);return ` <svg${r} v-bind="$attrs" :width="computedSize.width" :height="computedSize.height">
648
651
  <title v-if="props.title" :id="props.titleId">{{ props.title }}</title>
649
652
  <desc v-if="props.desc" :id="props.descId">{{ props.desc }}</desc>
650
653
  ${i}
651
654
  </svg>`}elementToVueTemplate(e,t=0){let r=" ".repeat(t),{tag:i,attributes:a,children:o,content:u}=e,c=[],l=[],h="class"in a;if(Object.entries(a).forEach(([v,x])=>{if(v==="vector-effect"&&x==="non-scaling-stroke")c.push(`:vector-effect="props.isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'"`);else if(v==="style"){let A=this.parseStyleStringForVue(x);c.push(`:style="${A}"`);let P=this.extractClassVarsFromStyle(x);l.push(...P);}else if(x.startsWith("{")&&x.endsWith("}")){let A=x.slice(1,-1);if(c.push(`:${v}="props.${A}"`),v==="fill"||v==="stroke"||v==="stroke-width"){let P=`${A}Class`;l.push(`props.${P}`);}}else c.push(`${v}="${x}"`);}),l.length>0){let v=a.class;v?c.push(`:class="[${l.join(", ")}, '${v}']"`):c.push(`:class="[${l.join(", ")}]"`);}else if(h){let v=a.class;v&&c.push(`class="${v}"`);}let p=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${p} />`;let f=`${r}<${i}${p}>`;return u&&(f+=u),o.length>0&&(f+=`
652
655
  `,f+=o.map(v=>this.elementToVueTemplate(v,t+1)).join(`
653
656
  `),f+=`
654
- `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let o=this.generateColorPropsInterface(t);o&&a.push(o);let u=this.generateStrokeWidthPropsInterface(r);u&&a.push(u),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "24" },');return this.vueOptions.typescript&&a.push(' size: "24",'),t.forEach(o=>{let u=o.variableName,c=o.originalColor,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: String, default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),r.forEach(o=>{let u=o.variableName,c=o.originalStrokeWidth,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: [String, Number], default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push(""),a.push("const computedWidth = computed(() => props.width || props.size);"),a.push("const computedHeight = computed(() => props.height || props.size);"),a.join(`
655
- `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {"),o.push(" const computedWidth = computed(() => props.width || props.size);"),o.push(" const computedHeight = computed(() => props.height || props.size);"),o.push(" return { computedWidth, computedHeight };"),o.push(" },"),o.push("});"),o.join(`
656
- `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {"),o.push(" computedWidth() {"),o.push(" return this.width || this.size;"),o.push(" },"),o.push(" computedHeight() {"),o.push(" return this.height || this.size;"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
657
- `)}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
657
+ `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let u=this.generateColorPropsInterface(t);u&&a.push(u);let c=this.generateStrokeWidthPropsInterface(r);c&&a.push(c),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "" },');this.vueOptions.typescript&&a.push(' size: "",'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: String, default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: [String, Number], default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push("");let o=this.getViewBoxDimensions(e.ast);return a.push("const computedSize = computed(() => ({"),a.push(` width: props.width || props.size || '${o.width}',`),a.push(` height: props.height || props.size || '${o.height}'`),a.push("}));"),a.join(`
658
+ `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {");let u=this.getViewBoxDimensions(e.ast);return o.push(" const computedSize = computed(() => ({"),o.push(` width: props.width || props.size || '${u.width}',`),o.push(` height: props.height || props.size || '${u.height}'`),o.push(" }));"),o.push(" return { computedSize };"),o.push(" },"),o.push("});"),o.join(`
659
+ `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {");let u=this.getViewBoxDimensions(e.ast);return o.push(" computedSize() {"),o.push(" return {"),o.push(` width: this.width || this.size || '${u.width}',`),o.push(` height: this.height || this.size || '${u.height}'`),o.push(" };"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
660
+ `)}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
658
661
  ${i}?: string;`}).join(`
659
662
  `)}generateStrokeWidthPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string | number;
660
663
  ${i}?: string;`}).join(`
package/dist/main.js CHANGED
@@ -571,7 +571,7 @@ ${r.map((a,o)=>a.split("").map((u,c)=>{let l=(i-1-o)/(i-1),h=(c/(a.length-1||1)+
571
571
  ${e.blue}React${e.reset} ${e.gray}\u2022${e.reset} ${e.green}Vue 3${e.reset} ${e.gray}\u2022${e.reset} ${e.blue}TypeScript${e.reset}
572
572
 
573
573
  ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${e.reset}
574
- `}var F1e=(e=>typeof cC<"u"?cC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof cC<"u"?cC:t)[r]}):e)(function(e){if(typeof cC<"u")return cC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Wyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof F1e<"u"?F1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},zyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},Hyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Gyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Kyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
574
+ `}var F1e=(e=>typeof cC<"u"?cC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof cC<"u"?cC:t)[r]}):e)(function(e){if(typeof cC<"u")return cC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Wyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof F1e<"u"?F1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use",feblend:"feBlend",feflood:"feFlood",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedropshadow:"feDropShadow",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fespecularlighting:"feSpecularLighting",fetile:"feTile",feturbulence:"feTurbulence",filter:"filter",g:"g",image:"image",line:"line",marker:"marker",mask:"mask",metadata:"metadata",path:"path",pattern:"pattern",polygon:"polygon",polyline:"polyline",rect:"rect",stop:"stop",svg:"svg",text:"text",tspan:"tspan",view:"view",circle:"circle",ellipse:"ellipse"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},zyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},Hyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Gyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Kyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
575
575
  `)}},Xyt=class{constructor(e){this.options=e;}apply(e){return this.options.enabled?this.normalizeElements(e):e}normalizeElements(e){return e.map(t=>this.transformElement(t,r=>{let i={...r.attributes};if(this.isDrawableElement(r.tag)){let a=r.attributes.fill!==void 0&&r.attributes.fill!=="",o=r.attributes.stroke!==void 0&&r.attributes.stroke!=="";a&&!o&&(i.stroke="none"),o&&!a&&(i.fill="none");}return {...r,attributes:i}}))}transformElement(e,t){let r=t(e);return r.children&&(r.children=r.children.map(i=>this.transformElement(i,t))),r}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}},Yyt=class{transform(e,t={}){let{optimize:r=true,splitColors:i=false,splitStrokeWidths:a=false,fixedStrokeWidth:o=false,normalizeFillStroke:u=false,accessibility:c=true,removeComments:l=true,removeDuplicates:h=true,minifyPaths:p=false}=t,f=this.deepCloneAst(e),v=[],x=[],A=[];return r&&(this.applyOptimizations(f,{removeComments:l,removeDuplicates:h,minifyPaths:p&&!i}),v.push("optimization")),i&&(x=this.applySplitColors(f),v.push("split-colors")),a&&(A=this.applySplitStrokeWidths(f),v.push("split-stroke-widths")),o&&(this.applyFixedStrokeWidth(f),v.push("fixed-stroke-width")),u&&(this.applyFillStrokeNormalization(f),v.push("normalize-fill-stroke")),c&&(this.applyAccessibility(f),v.push("accessibility")),{ast:f,colorMappings:x,strokeWidthMappings:A,metadata:{originalColors:x.map(P=>P.originalColor),originalStrokeWidths:A.map(P=>P.originalStrokeWidth),optimizationApplied:r,features:v,hasClassAttributes:this.hasClassAttributes(f)}}}applySplitColors(e){let t=new zyt({generateClasses:true,colorPrefix:"color"}).apply(e.root);return e.root=t.processedElement,t.mappings}applyFixedStrokeWidth(e){let t=new Hyt({onlyIfStrokePresent:false,preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyAccessibility(e){let t=new Kyt({addRole:true,addTitle:true,addDesc:true,defaultRole:"img",preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyFillStrokeNormalization(e){let t=new Xyt({enabled:true});e.root.children=t.apply(e.root.children);}applyOptimizations(e,t){t.removeDuplicates&&this.removeDuplicateElements(e),t.minifyPaths&&this.minifyPaths(e),this.removeEmptyGroups(e);}removeDuplicateElements(e){}minifyPaths(e){this.traverseElements(e.root,t=>{t.tag==="path"&&t.attributes.d&&(t.attributes.d=t.attributes.d.replace(/\s+/g," ").replace(/([MLHVCSQTAZ])\s+/gi,"$1").trim());});}removeEmptyGroups(e){let t=r=>(r.children=r.children.filter(t),!(r.tag==="g"&&r.children.length===0&&!r.content));e.root.children=e.root.children.filter(t);}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(.+\)$/.test(e)||/^hsla?\(.+\)$/.test(e)}deepCloneAst(e){return {...e,root:this.deepCloneElement(e.root)}}deepCloneElement(e){return {...e,attributes:{...e.attributes},children:e.children.map(t=>this.deepCloneElement(t))}}hasClassAttributes(e){let t=r=>r.attributes.class||r.attributes.className?true:r.children.some(i=>t(i));return t(e.root)}applySplitStrokeWidths(e){let t=new Gyt({generateClasses:true,strokeWidthPrefix:"strokeWidth"}).apply(e.root);return e.root=t.processedElement,t.mappings}},kM=class{options;constructor(e={}){this.options={typescript:true,memo:true,forwardRef:true,exportDefault:true,componentName:"Icon",prefix:"",suffix:"",includeTypes:true,...e};}astToJsx(e){return this.elementToJsx(e.root,0)}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsx(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
576
576
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
577
577
  `),h+=`
@@ -590,16 +590,16 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
590
590
  }`}generatePropTypes(e,t,r){let i=this.getComponentName(),a=["title: PropTypes.string,","titleId: PropTypes.string,","desc: PropTypes.string,","descId: PropTypes.string,","size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","className: PropTypes.string,","style: PropTypes.object,","width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),"],o=this.generateColorProps(e);o&&a.push(o);let u=this.generateStrokeWidthProps(t);return u&&a.push(u),r.includes("fixed-stroke-width")&&a.push("isFixedStrokeWidth: PropTypes.bool,"),`${i}.propTypes = {
591
591
  ${a.join(`
592
592
  `)}
593
- };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = "24"',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
593
+ };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = ""',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
594
594
  ${p.filter(T=>!U.includes(T)).join(`,
595
595
  `)},
596
596
  ${P},
597
597
  ...svgProps
598
- }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(q=>this.elementToJsx(q,1)).join(`
599
- `);return `const ${t} = (${$}: ${T}${B}) => {
598
+ }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(H=>this.elementToJsx(H,1)).join(`
599
+ `),q=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}: ${T}${B}) => {
600
600
  const computedSize = {
601
- width: svgProps.width || size,
602
- height: svgProps.height || size
601
+ width: svgProps.width || size || '${q.width}',
602
+ height: svgProps.height || size || '${q.height}'
603
603
  };
604
604
 
605
605
  return (
@@ -614,12 +614,15 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
614
614
  ${L}
615
615
  </svg>
616
616
  );
617
- };`}else {let T=e.ast.root.children.map(B=>this.elementToJsx(B,1)).join(`
618
- `);return `const ${t} = (${$}) => {
619
- const computedSize = size ? { width: size, height: size } : {};
617
+ };`}else {let T=e.ast.root.children.map(L=>this.elementToJsx(L,1)).join(`
618
+ `),B=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}) => {
619
+ const computedSize = {
620
+ width: svgProps.width || size || '${B.width}',
621
+ height: svgProps.height || size || '${B.height}'
622
+ };
620
623
 
621
624
  return (
622
- <svg ${F}{...computedSize} {...svgProps}>
625
+ <svg ${F}{...svgProps} {...computedSize}>
623
626
  ${S}
624
627
  ${O}
625
628
  ${T}
@@ -631,7 +634,7 @@ ${T}
631
634
  `:""}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsxWithClasses(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
632
635
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
633
636
  `),h+=`
634
- `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=k1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=lZ(a);t[u]=o;}}}),t}};is();var lur=Object.defineProperty,cur=(e,t,r)=>t in e?lur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,pur=(e,t,r)=>cur(e,t+"",r),G9e=class extends kM{constructor(e={}){super(e),pur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(hue(),fue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
637
+ `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=k1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=lZ(a);t[u]=o;}}}),t}};is();var lur=Object.defineProperty,cur=(e,t,r)=>t in e?lur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,pur=(e,t,r)=>cur(e,t+"",r),G9e=class extends kM{constructor(e={}){super(e),pur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(hue(),fue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
635
638
  ${t}
636
639
  </template>
637
640
 
@@ -644,17 +647,17 @@ ${this.vueOptions.scriptSetup&&this.vueOptions.useDefineOptions?`defineOptions({
644
647
  ${i?`<style scoped>
645
648
  ${i}
646
649
  </style>`:""}`}generateJSComponent(e){return this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateTemplate(e){let{ast:t}=e,r=this.generateSvgAttributes(t),i=t.root.children.map(a=>this.elementToVueTemplate(a,2)).join(`
647
- `);return ` <svg${r} v-bind="$attrs" :width="computedWidth" :height="computedHeight">
650
+ `);return ` <svg${r} v-bind="$attrs" :width="computedSize.width" :height="computedSize.height">
648
651
  <title v-if="props.title" :id="props.titleId">{{ props.title }}</title>
649
652
  <desc v-if="props.desc" :id="props.descId">{{ props.desc }}</desc>
650
653
  ${i}
651
654
  </svg>`}elementToVueTemplate(e,t=0){let r=" ".repeat(t),{tag:i,attributes:a,children:o,content:u}=e,c=[],l=[],h="class"in a;if(Object.entries(a).forEach(([v,x])=>{if(v==="vector-effect"&&x==="non-scaling-stroke")c.push(`:vector-effect="props.isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'"`);else if(v==="style"){let A=this.parseStyleStringForVue(x);c.push(`:style="${A}"`);let P=this.extractClassVarsFromStyle(x);l.push(...P);}else if(x.startsWith("{")&&x.endsWith("}")){let A=x.slice(1,-1);if(c.push(`:${v}="props.${A}"`),v==="fill"||v==="stroke"||v==="stroke-width"){let P=`${A}Class`;l.push(`props.${P}`);}}else c.push(`${v}="${x}"`);}),l.length>0){let v=a.class;v?c.push(`:class="[${l.join(", ")}, '${v}']"`):c.push(`:class="[${l.join(", ")}]"`);}else if(h){let v=a.class;v&&c.push(`class="${v}"`);}let p=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${p} />`;let f=`${r}<${i}${p}>`;return u&&(f+=u),o.length>0&&(f+=`
652
655
  `,f+=o.map(v=>this.elementToVueTemplate(v,t+1)).join(`
653
656
  `),f+=`
654
- `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let o=this.generateColorPropsInterface(t);o&&a.push(o);let u=this.generateStrokeWidthPropsInterface(r);u&&a.push(u),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "24" },');return this.vueOptions.typescript&&a.push(' size: "24",'),t.forEach(o=>{let u=o.variableName,c=o.originalColor,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: String, default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),r.forEach(o=>{let u=o.variableName,c=o.originalStrokeWidth,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: [String, Number], default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push(""),a.push("const computedWidth = computed(() => props.width || props.size);"),a.push("const computedHeight = computed(() => props.height || props.size);"),a.join(`
655
- `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {"),o.push(" const computedWidth = computed(() => props.width || props.size);"),o.push(" const computedHeight = computed(() => props.height || props.size);"),o.push(" return { computedWidth, computedHeight };"),o.push(" },"),o.push("});"),o.join(`
656
- `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {"),o.push(" computedWidth() {"),o.push(" return this.width || this.size;"),o.push(" },"),o.push(" computedHeight() {"),o.push(" return this.height || this.size;"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
657
- `)}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
657
+ `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let u=this.generateColorPropsInterface(t);u&&a.push(u);let c=this.generateStrokeWidthPropsInterface(r);c&&a.push(c),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "" },');this.vueOptions.typescript&&a.push(' size: "",'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: String, default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: [String, Number], default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push("");let o=this.getViewBoxDimensions(e.ast);return a.push("const computedSize = computed(() => ({"),a.push(` width: props.width || props.size || '${o.width}',`),a.push(` height: props.height || props.size || '${o.height}'`),a.push("}));"),a.join(`
658
+ `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {");let u=this.getViewBoxDimensions(e.ast);return o.push(" const computedSize = computed(() => ({"),o.push(` width: props.width || props.size || '${u.width}',`),o.push(` height: props.height || props.size || '${u.height}'`),o.push(" }));"),o.push(" return { computedSize };"),o.push(" },"),o.push("});"),o.join(`
659
+ `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {");let u=this.getViewBoxDimensions(e.ast);return o.push(" computedSize() {"),o.push(" return {"),o.push(` width: this.width || this.size || '${u.width}',`),o.push(` height: this.height || this.size || '${u.height}'`),o.push(" };"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
660
+ `)}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
658
661
  ${i}?: string;`}).join(`
659
662
  `)}generateStrokeWidthPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string | number;
660
663
  ${i}?: string;`}).join(`
package/dist/main.mjs CHANGED
@@ -571,7 +571,7 @@ ${r.map((a,o)=>a.split("").map((u,c)=>{let l=(i-1-o)/(i-1),h=(c/(a.length-1||1)+
571
571
  ${e.blue}React${e.reset} ${e.gray}\u2022${e.reset} ${e.green}Vue 3${e.reset} ${e.gray}\u2022${e.reset} ${e.blue}TypeScript${e.reset}
572
572
 
573
573
  ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${e.reset}
574
- `}var P1e=(e=>typeof pC<"u"?pC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof pC<"u"?pC:t)[r]}):e)(function(e){if(typeof pC<"u")return pC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Wyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof P1e<"u"?P1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},zyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},Hyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Gyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Kyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
574
+ `}var P1e=(e=>typeof pC<"u"?pC:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof pC<"u"?pC:t)[r]}):e)(function(e){if(typeof pC<"u")return pC.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Wyt=class{parse(e){let t=this.cleanSvgContent(e),r=this.parseElement(t);return {root:r,viewBox:r.attributes.viewBox,width:r.attributes.width,height:r.attributes.height,namespace:r.attributes.xmlns}}extractColors(e){let t=[];return this.traverseElements(e.root,r=>{r.attributes.fill&&this.isValidColor(r.attributes.fill)&&t.push({value:r.attributes.fill,type:"fill",element:r,attribute:"fill"}),r.attributes.stroke&&this.isValidColor(r.attributes.stroke)&&t.push({value:r.attributes.stroke,type:"stroke",element:r,attribute:"stroke"}),r.attributes["stop-color"]&&this.isValidColor(r.attributes["stop-color"])&&t.push({value:r.attributes["stop-color"],type:"stop-color",element:r,attribute:"stop-color"});}),t}cleanSvgContent(e){return e.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(e){if(typeof DOMParser<"u"){let t=new DOMParser().parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let r=t.documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(r)}try{let t=(typeof P1e<"u"?P1e:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:r}=t,i=new r(e,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(e)}}convertDOMToSVGElement(e){let t={tag:this.preserveSvgTagCase(e.tagName),attributes:{},children:[]};for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r];t.attributes[i.name]=i.value;}for(let r=0;r<e.children.length;r++){let i=e.children[r];t.children.push(this.convertDOMToSVGElement(i));}return e.children.length===0&&e.textContent?.trim()&&(t.content=e.textContent.trim()),t}parseElementWithRegex(e){let t=e.match(/<svg([^>]*)>/i);if(!t)throw new Error("Invalid SVG: No svg element found");let r=this.parseAttributes(t[1]),i=this.parseChildren(e);return {tag:"svg",attributes:r,children:i}}parseAttributes(e){let t={},r=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,i;for(;(i=r.exec(e))!==null;)t[i[1]]=i[2];return t}parseChildren(e){let t=[],r=e.match(/<svg[^>]*>(.*)<\/svg>/is);if(!r||!r[1])return t;let i=r[1],a=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,o;for(;(o=a.exec(i))!==null;){let[,u,c,l]=o,h=this.parseAttributes(c),p={tag:u,attributes:h,children:[]};l!==void 0&&(l.includes("<")?p.children=this.parseNestedElements(l):l.trim()&&(p.content=l.trim())),t.push(p);}return t}parseNestedElements(e){let t=[],r=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=r.exec(e))!==null;){let[,a,o,u]=i,c=this.parseAttributes(o),l={tag:a,attributes:c,children:[]};u!==void 0&&(u.includes("<")?l.children=this.parseNestedElements(u):u.trim()&&(l.content=u.trim())),t.push(l);}return t}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}preserveSvgTagCase(e){let t=e.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use",feblend:"feBlend",feflood:"feFlood",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedropshadow:"feDropShadow",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fespecularlighting:"feSpecularLighting",fetile:"feTile",feturbulence:"feTurbulence",filter:"filter",g:"g",image:"image",line:"line",marker:"marker",mask:"mask",metadata:"metadata",path:"path",pattern:"pattern",polygon:"polygon",polyline:"polyline",rect:"rect",stop:"stop",svg:"svg",text:"text",tspan:"tspan",view:"view",circle:"circle",ellipse:"ellipse"}[t]||t}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(e.toLowerCase())}},zyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,generateClasses:e.generateClasses??true,colorPrefix:e.colorPrefix??"color"};}extractColors(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidColor(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>i.value.localeCompare(a.value))}apply(e){let t=this.extractColors(e),r=this.generateColorMappings(t),i=this.replaceColorsWithVariables(e,r);return {mappings:r,processedElement:i,originalColors:t.map(a=>a.value)}}generateColorMappings(e){return e.map((t,r)=>({originalColor:t.value,variableName:r===0?this.options.colorPrefix:`${this.options.colorPrefix}${r+1}`,type:t.type}))}replaceColorsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalColor,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a.fill&&r.has(a.fill)&&(a.fill=`{${r.get(a.fill)}}`),a.stroke&&r.has(a.stroke)&&(a.stroke=`{${r.get(a.stroke)}}`),a["stop-color"]&&r.has(a["stop-color"])&&(a["stop-color"]=`{${r.get(a["stop-color"])}}`),a.style){let o=a.style,u=o.match(/fill:\s*([^;]+)/);if(u){let h=u[1].trim();r.has(h)&&(o=o.replace(/fill:\s*[^;]+/,`fill: {${r.get(h)}}`));}let c=o.match(/stroke:\s*([^;]+)/);if(c){let h=c[1].trim();r.has(h)&&(o=o.replace(/stroke:\s*[^;]+/,`stroke: {${r.get(h)}}`));}let l=o.match(/stop-color:\s*([^;]+)/);if(l){let h=l[1].trim();r.has(h)&&(o=o.replace(/stop-color:\s*[^;]+/,`stop-color: {${r.get(h)}}`));}a.style=o;}if(this.isDrawableElement(i.tag)){let o=i.attributes.fill!==void 0&&i.attributes.fill!=="",u=i.attributes.stroke!==void 0&&i.attributes.stroke!=="";o&&!u&&!a.stroke&&(a.stroke="none"),u&&!o&&!a.fill&&(a.fill="none");}return {...i,attributes:a}})}traverseElement(e,t){e.attributes.fill&&t.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&t.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&t.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"}),e.attributes.style&&this.extractColorsFromStyle(e.attributes.style).forEach(r=>{t.push({value:r.value,type:r.type,element:e,attribute:"style"});}),e.children.forEach(r=>this.traverseElement(r,t));}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(e)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(e.toLowerCase())}extractColorsFromStyle(e){let t=[],r=e.match(/fill:\s*([^;]+)/);if(r){let o=r[1].trim();this.isValidColor(o)&&t.push({value:o,type:"fill"});}let i=e.match(/stroke:\s*([^;]+)/);if(i){let o=i[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stroke"});}let a=e.match(/stop-color:\s*([^;]+)/);if(a){let o=a[1].trim();this.isValidColor(o)&&t.push({value:o,type:"stop-color"});}return t}},Hyt=class{options;constructor(e={}){this.options={preserveExisting:e.preserveExisting??true,onlyIfStrokePresent:e.onlyIfStrokePresent??true};}apply(e){let t=0;return {processedElement:this.transformElement(e,r=>this.shouldAddVectorEffect(r)?(t++,{...r,attributes:{...r.attributes,"vector-effect":"non-scaling-stroke"}}):r),elementsModified:t}}shouldAddVectorEffect(e){return this.options.preserveExisting&&e.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(e.tag)}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}},Gyt=class{options;constructor(e={}){this.options={preserveOriginalNames:e.preserveOriginalNames??false,strokeWidthPrefix:e.strokeWidthPrefix??"strokeWidth",generateClasses:e.generateClasses??true};}extractStrokeWidths(e){let t=[];this.traverseElement(e,t);let r=new Map;return t.forEach(i=>{this.isValidStrokeWidth(i.value)&&r.set(i.value,i);}),Array.from(r.values()).sort((i,a)=>{let o=parseFloat(i.value),u=parseFloat(a.value);return isNaN(o)&&isNaN(u)?i.value.localeCompare(a.value):isNaN(o)?1:isNaN(u)?-1:o-u})}apply(e){let t=this.extractStrokeWidths(e),r=this.generateStrokeWidthMappings(t),i=this.replaceStrokeWidthsWithVariables(e,r);return {mappings:r,processedElement:i,originalStrokeWidths:t.map(a=>a.value)}}traverseElement(e,t){if(e.attributes["stroke-width"]&&t.push({value:e.attributes["stroke-width"],element:e,attribute:"stroke-width"}),e.attributes.style){let r=this.extractStrokeWidthFromStyle(e.attributes.style);r&&t.push({value:r,element:e,attribute:"style",styleProperty:"stroke-width"});}e.children.forEach(r=>this.traverseElement(r,t));}extractStrokeWidthFromStyle(e){let t=e.match(/stroke-width\s*:\s*([^;]+)/);return t?t[1].trim():null}isValidStrokeWidth(e){return e==="inherit"||e==="none"||e==="initial"||e==="unset"||e.includes("var(")||e.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(e.trim())}generateStrokeWidthMappings(e){return e.map((t,r)=>({originalStrokeWidth:t.value,variableName:r===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${r+1}`}))}replaceStrokeWidthsWithVariables(e,t){let r=new Map(t.map(i=>[i.originalStrokeWidth,i.variableName]));return this.transformElement(e,i=>{let a={...i.attributes};if(a["stroke-width"]&&r.has(a["stroke-width"])&&(a["stroke-width"]=`{${r.get(a["stroke-width"])}}`),a.style){let o=a.style;r.forEach((u,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");o=o.replace(l,`stroke-width: {${u}}`);}),a.style=o;}return {...i,attributes:a}})}transformElement(e,t){let r=t(e);return {...r,children:r.children.map(i=>this.transformElement(i,t))}}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},Kyt=class{options;constructor(e={}){this.options={addRole:e.addRole??true,addAriaHidden:e.addAriaHidden??false,addTitle:e.addTitle??true,addDesc:e.addDesc??true,defaultRole:e.defaultRole??"img",preserveExisting:e.preserveExisting??true};}apply(e){let t=[];if(e.tag!=="svg")return {processedElement:e,attributesAdded:t};let r={...e.attributes};return this.options.addRole&&(!this.options.preserveExisting||!r.role)&&(r.role=this.options.defaultRole,t.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!r["aria-hidden"])&&(r["aria-hidden"]="true",t.push("aria-hidden")),this.options.addTitle&&t.push("title-support"),this.options.addDesc&&t.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!r["aria-labelledby"])?(r["aria-labelledby"]="{titleId} {descId}",t.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!r["aria-labelledby"])&&(r["aria-labelledby"]="{titleId}",t.push("aria-labelledby")),{processedElement:{...e,attributes:r},attributesAdded:t}}generateProps(){let e=[];return this.options.addTitle&&e.push("title?: string","titleId?: string"),this.options.addDesc&&e.push("desc?: string","descId?: string"),e}generateJSXElements(e){let t=[];return e==="react"?(this.options.addDesc&&t.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&t.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&t.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&t.push('<title v-if="title" :id="titleId">{{ title }}</title>')),t.join(`
575
575
  `)}},Xyt=class{constructor(e){this.options=e;}apply(e){return this.options.enabled?this.normalizeElements(e):e}normalizeElements(e){return e.map(t=>this.transformElement(t,r=>{let i={...r.attributes};if(this.isDrawableElement(r.tag)){let a=r.attributes.fill!==void 0&&r.attributes.fill!=="",o=r.attributes.stroke!==void 0&&r.attributes.stroke!=="";a&&!o&&(i.stroke="none"),o&&!a&&(i.fill="none");}return {...r,attributes:i}}))}transformElement(e,t){let r=t(e);return r.children&&(r.children=r.children.map(i=>this.transformElement(i,t))),r}isDrawableElement(e){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(e)}},Yyt=class{transform(e,t={}){let{optimize:r=true,splitColors:i=false,splitStrokeWidths:a=false,fixedStrokeWidth:o=false,normalizeFillStroke:u=false,accessibility:c=true,removeComments:l=true,removeDuplicates:h=true,minifyPaths:p=false}=t,f=this.deepCloneAst(e),v=[],x=[],A=[];return r&&(this.applyOptimizations(f,{removeComments:l,removeDuplicates:h,minifyPaths:p&&!i}),v.push("optimization")),i&&(x=this.applySplitColors(f),v.push("split-colors")),a&&(A=this.applySplitStrokeWidths(f),v.push("split-stroke-widths")),o&&(this.applyFixedStrokeWidth(f),v.push("fixed-stroke-width")),u&&(this.applyFillStrokeNormalization(f),v.push("normalize-fill-stroke")),c&&(this.applyAccessibility(f),v.push("accessibility")),{ast:f,colorMappings:x,strokeWidthMappings:A,metadata:{originalColors:x.map(P=>P.originalColor),originalStrokeWidths:A.map(P=>P.originalStrokeWidth),optimizationApplied:r,features:v,hasClassAttributes:this.hasClassAttributes(f)}}}applySplitColors(e){let t=new zyt({generateClasses:true,colorPrefix:"color"}).apply(e.root);return e.root=t.processedElement,t.mappings}applyFixedStrokeWidth(e){let t=new Hyt({onlyIfStrokePresent:false,preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyAccessibility(e){let t=new Kyt({addRole:true,addTitle:true,addDesc:true,defaultRole:"img",preserveExisting:true}).apply(e.root);e.root=t.processedElement;}applyFillStrokeNormalization(e){let t=new Xyt({enabled:true});e.root.children=t.apply(e.root.children);}applyOptimizations(e,t){t.removeDuplicates&&this.removeDuplicateElements(e),t.minifyPaths&&this.minifyPaths(e),this.removeEmptyGroups(e);}removeDuplicateElements(e){}minifyPaths(e){this.traverseElements(e.root,t=>{t.tag==="path"&&t.attributes.d&&(t.attributes.d=t.attributes.d.replace(/\s+/g," ").replace(/([MLHVCSQTAZ])\s+/gi,"$1").trim());});}removeEmptyGroups(e){let t=r=>(r.children=r.children.filter(t),!(r.tag==="g"&&r.children.length===0&&!r.content));e.root.children=e.root.children.filter(t);}traverseElements(e,t){t(e),e.children.forEach(r=>this.traverseElements(r,t));}isValidColor(e){return !e||e==="none"||e==="transparent"||e==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(e)||/^rgba?\(.+\)$/.test(e)||/^hsla?\(.+\)$/.test(e)}deepCloneAst(e){return {...e,root:this.deepCloneElement(e.root)}}deepCloneElement(e){return {...e,attributes:{...e.attributes},children:e.children.map(t=>this.deepCloneElement(t))}}hasClassAttributes(e){let t=r=>r.attributes.class||r.attributes.className?true:r.children.some(i=>t(i));return t(e.root)}applySplitStrokeWidths(e){let t=new Gyt({generateClasses:true,strokeWidthPrefix:"strokeWidth"}).apply(e.root);return e.root=t.processedElement,t.mappings}},TM=class{options;constructor(e={}){this.options={typescript:true,memo:true,forwardRef:true,exportDefault:true,componentName:"Icon",prefix:"",suffix:"",includeTypes:true,...e};}astToJsx(e){return this.elementToJsx(e.root,0)}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsx(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
576
576
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
577
577
  `),h+=`
@@ -590,16 +590,16 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
590
590
  }`}generatePropTypes(e,t,r){let i=this.getComponentName(),a=["title: PropTypes.string,","titleId: PropTypes.string,","desc: PropTypes.string,","descId: PropTypes.string,","size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","className: PropTypes.string,","style: PropTypes.object,","width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),","height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),"],o=this.generateColorProps(e);o&&a.push(o);let u=this.generateStrokeWidthProps(t);return u&&a.push(u),r.includes("fixed-stroke-width")&&a.push("isFixedStrokeWidth: PropTypes.bool,"),`${i}.propTypes = {
591
591
  ${a.join(`
592
592
  `)}
593
- };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = "24"',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
593
+ };`}generateComponent(e){let t=this.getComponentName(),{colorMappings:r,strokeWidthMappings:i,metadata:a}=e,o=["title","titleId","desc","descId","size"],u=r.map(T=>T.variableName),c=r.map(T=>`${T.variableName}Class`),l=i.map(T=>T.variableName),h=i.map(T=>`${T.variableName}Class`),p=[...o,...u,...c,...l,...h],f=this.generateColorDefaults(r),v=this.generateStrokeWidthDefaults(i),x='size = ""',A=a.features.includes("fixed-stroke-width")?"isFixedStrokeWidth = true":"",P=[x,f,v,A].filter(Boolean).join(", "),U=P.split(", ").map(T=>T.split(" = ")[0]),$=`{
594
594
  ${p.filter(T=>!U.includes(T)).join(`,
595
595
  `)},
596
596
  ${P},
597
597
  ...svgProps
598
- }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(q=>this.elementToJsx(q,1)).join(`
599
- `);return `const ${t} = (${$}: ${T}${B}) => {
598
+ }`,F=this.generateSvgAttributes(e.ast),S="{title ? <title id={titleId}>{title}</title> : null}",O="{desc ? <desc id={descId}>{desc}</desc> : null}";if(this.reactOptions.typescript){let T=`${t}Props`,B=this.reactOptions.forwardRef?", ref: Ref<SVGSVGElement>":"",L=e.ast.root.children.map(H=>this.elementToJsx(H,1)).join(`
599
+ `),q=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}: ${T}${B}) => {
600
600
  const computedSize = {
601
- width: svgProps.width || size,
602
- height: svgProps.height || size
601
+ width: svgProps.width || size || '${q.width}',
602
+ height: svgProps.height || size || '${q.height}'
603
603
  };
604
604
 
605
605
  return (
@@ -614,12 +614,15 @@ ${e.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
614
614
  ${L}
615
615
  </svg>
616
616
  );
617
- };`}else {let T=e.ast.root.children.map(B=>this.elementToJsx(B,1)).join(`
618
- `);return `const ${t} = (${$}) => {
619
- const computedSize = size ? { width: size, height: size } : {};
617
+ };`}else {let T=e.ast.root.children.map(L=>this.elementToJsx(L,1)).join(`
618
+ `),B=this.getViewBoxDimensions(e.ast);return `const ${t} = (${$}) => {
619
+ const computedSize = {
620
+ width: svgProps.width || size || '${B.width}',
621
+ height: svgProps.height || size || '${B.height}'
622
+ };
620
623
 
621
624
  return (
622
- <svg ${F}{...computedSize} {...svgProps}>
625
+ <svg ${F}{...svgProps} {...computedSize}>
623
626
  ${S}
624
627
  ${O}
625
628
  ${T}
@@ -631,7 +634,7 @@ ${T}
631
634
  `:""}elementToJsx(e,t=0){let r=" ".repeat(t+1),{tag:i,attributes:a,children:o,content:u}=e,c=this.attributesToJsxWithClasses(a),l=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${l} />`;let h=`${r}<${i}${l}>`;return u&&(h+=u),o.length>0&&(h+=`
632
635
  `,h+=o.map(p=>this.elementToJsx(p,t+1)).join(`
633
636
  `),h+=`
634
- `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=T1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=cZ(a);t[u]=o;}}}),t}};is();var lur=Object.defineProperty,cur=(e,t,r)=>t in e?lur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,pur=(e,t,r)=>cur(e,t+"",r),K9e=class extends TM{constructor(e={}){super(e),pur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(mue(),hue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
637
+ `+r),h+=`</${i}>`,h}attributesToJsxWithClasses(e){let t=[],r=[],i="class"in e||"className"in e;if(Object.entries(e).forEach(([a,o])=>{let u=T1e(a);if(a==="vector-effect"&&o==="non-scaling-stroke")t.push("vectorEffect={isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'}");else if((a==="fill"||a==="stroke")&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="stroke-width"&&o.startsWith("{")&&o.endsWith("}")){let c=o.slice(1,-1);t.push(`${u}=${o}`);let l=`${c}Class`;r.push(l);}else if(a==="style"){let c=this.parseStyleString(o),l=Object.entries(c).map(([h,p])=>{if(typeof p=="string"&&p.startsWith("{")&&p.endsWith("}")){let f=p.slice(1,-1);if(h==="strokeWidth"){let v=`${f}Class`;r.push(v);}return `${h}: ${f}`}else return `${h}: '${p}'`});t.push(`style={{ ${l.join(", ")} }}`);}else o.startsWith("{")&&o.endsWith("}")?t.push(`${u}=${o}`):t.push(`${u}="${o}"`);}),r.length>0){let a=e.class||e.className;if(r.length===1)a?t.push(`className={\`${a} \${${r[0]}}\`}`):t.push(`className={${r[0]}}`);else {let o=r.map(u=>`\${${u}}`).join(" ");a?t.push(`className={\`${a} ${o}\`}`):t.push(`className={\`${o}\`}`);}}else if(i){let a=e.class||e.className;a&&t.push(`className="${a}"`);}return t}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}parseStyleString(e){let t={};return e.split(";").forEach(r=>{let i=r.indexOf(":");if(i>0){let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(a&&o){let u=cZ(a);t[u]=o;}}}),t}};is();var lur=Object.defineProperty,cur=(e,t,r)=>t in e?lur(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,pur=(e,t,r)=>cur(e,t+"",r),K9e=class extends TM{constructor(e={}){super(e),pur(this,"vueOptions"),this.vueOptions={...this.options,composition:e.composition??true,scriptSetup:e.scriptSetup??true,sfc:e.sfc??true,defineComponent:e.defineComponent??false,useDefineOptions:e.useDefineOptions??false};}async formatCode(e,t){try{let{format:r}=await Promise.resolve().then(()=>(mue(),hue));return await r(e,{parser:t,semi:!0,singleQuote:!0,trailingComma:"es5",tabWidth:2,printWidth:80,bracketSpacing:!0,arrowParens:"avoid",htmlWhitespaceSensitivity:"ignore",vueIndentScriptAndStyle:!0})}catch(r){return console.warn("Prettier formatting failed or not available, using unformatted code:",r),e}}async generate(e){let t=this.getComponentName(),r;this.vueOptions.sfc?r=this.generateSFC(e):r=this.generateJSComponent(e);let i=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"ts":"js",a=this.generateFilename(t,i),o=this.vueOptions.sfc?"vue":this.vueOptions.typescript?"typescript":"babel";return {code:await this.formatCode(r,o),filename:a,componentName:t,dependencies:this.getDependencies()}}generateSFC(e){let t=this.generateTemplate(e),r=this.generateScript(e),i=this.generateStyle();return `<template>
635
638
  ${t}
636
639
  </template>
637
640
 
@@ -644,17 +647,17 @@ ${this.vueOptions.scriptSetup&&this.vueOptions.useDefineOptions?`defineOptions({
644
647
  ${i?`<style scoped>
645
648
  ${i}
646
649
  </style>`:""}`}generateJSComponent(e){return this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateTemplate(e){let{ast:t}=e,r=this.generateSvgAttributes(t),i=t.root.children.map(a=>this.elementToVueTemplate(a,2)).join(`
647
- `);return ` <svg${r} v-bind="$attrs" :width="computedWidth" :height="computedHeight">
650
+ `);return ` <svg${r} v-bind="$attrs" :width="computedSize.width" :height="computedSize.height">
648
651
  <title v-if="props.title" :id="props.titleId">{{ props.title }}</title>
649
652
  <desc v-if="props.desc" :id="props.descId">{{ props.desc }}</desc>
650
653
  ${i}
651
654
  </svg>`}elementToVueTemplate(e,t=0){let r=" ".repeat(t),{tag:i,attributes:a,children:o,content:u}=e,c=[],l=[],h="class"in a;if(Object.entries(a).forEach(([v,x])=>{if(v==="vector-effect"&&x==="non-scaling-stroke")c.push(`:vector-effect="props.isFixedStrokeWidth ? 'non-scaling-stroke' : 'none'"`);else if(v==="style"){let A=this.parseStyleStringForVue(x);c.push(`:style="${A}"`);let P=this.extractClassVarsFromStyle(x);l.push(...P);}else if(x.startsWith("{")&&x.endsWith("}")){let A=x.slice(1,-1);if(c.push(`:${v}="props.${A}"`),v==="fill"||v==="stroke"||v==="stroke-width"){let P=`${A}Class`;l.push(`props.${P}`);}}else c.push(`${v}="${x}"`);}),l.length>0){let v=a.class;v?c.push(`:class="[${l.join(", ")}, '${v}']"`):c.push(`:class="[${l.join(", ")}]"`);}else if(h){let v=a.class;v&&c.push(`class="${v}"`);}let p=c.length>0?" "+c.join(" "):"";if(o.length===0&&!u)return `${r}<${i}${p} />`;let f=`${r}<${i}${p}>`;return u&&(f+=u),o.length>0&&(f+=`
652
655
  `,f+=o.map(v=>this.elementToVueTemplate(v,t+1)).join(`
653
656
  `),f+=`
654
- `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let o=this.generateColorPropsInterface(t);o&&a.push(o);let u=this.generateStrokeWidthPropsInterface(r);u&&a.push(u),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "24" },');return this.vueOptions.typescript&&a.push(' size: "24",'),t.forEach(o=>{let u=o.variableName,c=o.originalColor,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: String, default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),r.forEach(o=>{let u=o.variableName,c=o.originalStrokeWidth,l=`${u}Class`;this.vueOptions.typescript?(a.push(` ${u}: '${c}',`),a.push(` ${l}: "",`)):(a.push(` ${u}: { type: [String, Number], default: '${c}' },`),a.push(` ${l}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push(""),a.push("const computedWidth = computed(() => props.width || props.size);"),a.push("const computedHeight = computed(() => props.height || props.size);"),a.join(`
655
- `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {"),o.push(" const computedWidth = computed(() => props.width || props.size);"),o.push(" const computedHeight = computed(() => props.height || props.size);"),o.push(" return { computedWidth, computedHeight };"),o.push(" },"),o.push("});"),o.join(`
656
- `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];return o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "24" },'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;o.push(` ${c}: { type: String, default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;o.push(` ${c}: { type: [String, Number], default: '${l}' },`),o.push(` ${h}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {"),o.push(" computedWidth() {"),o.push(" return this.width || this.size;"),o.push(" },"),o.push(" computedHeight() {"),o.push(" return this.height || this.size;"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
657
- `)}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
657
+ `+r),f+=`</${i}>`,f}generateScript(e){return this.vueOptions.scriptSetup?this.generateScriptSetup(e):this.vueOptions.composition?this.generateCompositionAPI(e):this.generateOptionsAPI(e)}generateScriptSetup(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=[];if(this.vueOptions.typescript?(a.push('import type { SVGAttributes } from "vue";'),a.push('import { computed } from "vue";'),a.push("")):(a.push('import { computed } from "vue";'),a.push("")),this.vueOptions.typescript){a.push("interface Props extends /* @vue-ignore */ SVGAttributes {"),a.push(" title?: string;"),a.push(" titleId?: string;"),a.push(" desc?: string;"),a.push(" descId?: string;"),a.push(" width?: string | number;"),a.push(" height?: string | number;"),a.push(" size?: string | number;");let u=this.generateColorPropsInterface(t);u&&a.push(u);let c=this.generateStrokeWidthPropsInterface(r);c&&a.push(c),i.features.includes("fixed-stroke-width")&&a.push(" isFixedStrokeWidth?: boolean;"),a.push("}"),a.push(""),a.push("const props = withDefaults(defineProps<Props>(), {");}else a.push("const props = defineProps({"),a.push(" title: { type: String, default: '' },"),a.push(" titleId: { type: String, default: '' },"),a.push(" desc: { type: String, default: '' },"),a.push(" descId: { type: String, default: '' },"),a.push(" class: { type: String, default: '' },"),a.push(" style: { type: Object, default: '' },"),a.push(" width: { type: [String, Number], default: '' },"),a.push(" height: { type: [String, Number], default: '' },"),a.push(' size: { type: [String, Number], default: "" },');this.vueOptions.typescript&&a.push(' size: "",'),t.forEach(u=>{let c=u.variableName,l=u.originalColor,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: String, default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),r.forEach(u=>{let c=u.variableName,l=u.originalStrokeWidth,h=`${c}Class`;this.vueOptions.typescript?(a.push(` ${c}: '${l}',`),a.push(` ${h}: "",`)):(a.push(` ${c}: { type: [String, Number], default: '${l}' },`),a.push(` ${h}: { type: String, default: "" },`));}),i.features.includes("fixed-stroke-width")&&(this.vueOptions.typescript?a.push(" isFixedStrokeWidth: true,"):a.push(" isFixedStrokeWidth: { type: Boolean, default: true },")),a.push("});"),a.push("");let o=this.getViewBoxDimensions(e.ast);return a.push("const computedSize = computed(() => ({"),a.push(` width: props.width || props.size || '${o.width}',`),a.push(` height: props.height || props.size || '${o.height}'`),a.push("}));"),a.join(`
658
+ `)}generateCompositionAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("import { defineComponent, computed } from 'vue';"),o.push(""),o.push("export default defineComponent({"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" setup(props) {");let u=this.getViewBoxDimensions(e.ast);return o.push(" const computedSize = computed(() => ({"),o.push(` width: props.width || props.size || '${u.width}',`),o.push(` height: props.height || props.size || '${u.height}'`),o.push(" }));"),o.push(" return { computedSize };"),o.push(" },"),o.push("});"),o.join(`
659
+ `)}generateOptionsAPI(e){let{colorMappings:t,strokeWidthMappings:r,metadata:i}=e,a=this.getComponentName(),o=[];o.push("export default {"),o.push(` name: '${a}',`),o.push(" props: {"),o.push(" title: { type: String, default: '' },"),o.push(" titleId: { type: String, default: '' },"),o.push(" desc: { type: String, default: '' },"),o.push(" descId: { type: String, default: '' },"),o.push(" class: { type: String, default: '' },"),o.push(" style: { type: Object, default: '' },"),o.push(" width: { type: [String, Number], default: '' },"),o.push(" height: { type: [String, Number], default: '' },"),o.push(' size: { type: [String, Number], default: "" },'),t.forEach(c=>{let l=c.variableName,h=c.originalColor,p=`${l}Class`;o.push(` ${l}: { type: String, default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),r.forEach(c=>{let l=c.variableName,h=c.originalStrokeWidth,p=`${l}Class`;o.push(` ${l}: { type: [String, Number], default: '${h}' },`),o.push(` ${p}: { type: String, default: "" },`);}),i.features.includes("fixed-stroke-width")&&o.push(" isFixedStrokeWidth: { type: Boolean, default: true },"),o.push(" },"),o.push(" computed: {");let u=this.getViewBoxDimensions(e.ast);return o.push(" computedSize() {"),o.push(" return {"),o.push(` width: this.width || this.size || '${u.width}',`),o.push(` height: this.height || this.size || '${u.height}'`),o.push(" };"),o.push(" },"),o.push(" },"),o.push("};"),o.join(`
660
+ `)}getViewBoxDimensions(e){let{width:t,height:r,viewBox:i}=e;if(t&&r)return {width:t,height:r};if(i){let a=i.split(" ");if(a.length===4)return {width:a[2],height:a[3]}}return {width:"24",height:"24"}}generateStyle(){return ""}generateColorPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string;
658
661
  ${i}?: string;`}).join(`
659
662
  `)}generateStrokeWidthPropsInterface(e){return e.length===0?"":e.map(t=>{let r=t.variableName,i=`${r}Class`;return ` ${r}?: string | number;
660
663
  ${i}?: string;`}).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svgfusion-cmd",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Command-line interface for converting SVG files into React and Vue 3 components with TypeScript support and batch processing capabilities.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -59,10 +59,10 @@
59
59
  "dependencies": {
60
60
  "commander": "^11.1.0",
61
61
  "figlet": "^1.7.0",
62
- "svgfusion-core": "1.3.3",
63
- "svgfusion-react": "1.2.3",
64
- "svgfusion-utils": "1.1.3",
65
- "svgfusion-vue": "1.2.3"
62
+ "svgfusion-core": "1.5.0",
63
+ "svgfusion-react": "1.4.0",
64
+ "svgfusion-utils": "1.3.0",
65
+ "svgfusion-vue": "1.4.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@eslint/js": "^9.31.0",