shadcn 4.8.1 → 4.8.3

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/mcp/index.js CHANGED
@@ -1 +1 @@
1
- export{a as server}from'../chunk-I3RKATY2.js';import'../chunk-IQ4BGOAU.js';import'../chunk-3ORLOMOE.js';import'../chunk-WLJDV6SE.js';import'../chunk-CHWMSXYA.js';
1
+ export{a as server}from'../chunk-TLULQEJM.js';import'../chunk-TE73JWUV.js';import'../chunk-3ORLOMOE.js';import'../chunk-7SBJAAAY.js';import'../chunk-CHWMSXYA.js';
@@ -1 +1 @@
1
- export{v as RegistriesIndexParseError,j as RegistryError,i as RegistryErrorCode,n as RegistryFetchError,m as RegistryForbiddenError,u as RegistryInvalidNamespaceError,s as RegistryItemNotFoundError,p as RegistryLocalFileError,t as RegistryMissingEnvironmentVariablesError,o as RegistryNotConfiguredError,k as RegistryNotFoundError,q as RegistryParseError,l as RegistryUnauthorizedError,r as RegistryValidationError,ya as getRegistries,za as getRegistriesIndex,ma as getRegistry,na as getRegistryItems,Ga as loadRegistry,Ha as loadRegistryItem,oa as resolveRegistryItems,La as searchRegistries}from'../chunk-IQ4BGOAU.js';import'../chunk-3ORLOMOE.js';import'../chunk-WLJDV6SE.js';import'../chunk-CHWMSXYA.js';
1
+ export{w as RegistriesIndexParseError,k as RegistryError,j as RegistryErrorCode,o as RegistryFetchError,n as RegistryForbiddenError,v as RegistryInvalidNamespaceError,t as RegistryItemNotFoundError,q as RegistryLocalFileError,u as RegistryMissingEnvironmentVariablesError,p as RegistryNotConfiguredError,l as RegistryNotFoundError,r as RegistryParseError,m as RegistryUnauthorizedError,s as RegistryValidationError,za as getRegistries,Aa as getRegistriesIndex,na as getRegistry,oa as getRegistryItems,Ha as loadRegistry,Ia as loadRegistryItem,pa as resolveRegistryItems,Ma as searchRegistries}from'../chunk-TE73JWUV.js';import'../chunk-3ORLOMOE.js';import'../chunk-7SBJAAAY.js';import'../chunk-CHWMSXYA.js';
@@ -1 +1 @@
1
- export{e as transformDirection,f as transformFont,c as transformIcons,g as transformMenu}from'../chunk-WLJDV6SE.js';import'../chunk-CHWMSXYA.js';import W from'postcss';import D from'postcss-selector-parser';import {z}from'zod';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';import {twMerge}from'tailwind-merge';var b="cn-",k=z.record(z.string().startsWith(b),z.string());function B(t){let e=W.parse(t),n={};return e.walkRules(i=>{let r=i.selectors??[];if(r.length===0)return;let o=_(i);if(o)for(let c of r){let f=X(c);D(s=>{s.each(g=>{let l=q(g);if(!l)return;let p=l.value;p.startsWith(b)&&(n[p]=n[p]?`${o} ${n[p]}`:o);});}).processSync(f);}}),k.parse(n)}function X(t){return t.replace(/\s*&\s*/g,"").trim()}function _(t){let e=[];for(let n of t.nodes||[])if(n.type==="atrule"&&n.name==="apply"){let i=n.params.trim();i&&e.push(i);}return e.length===0?null:e.join(" ")}function q(t){let e=[];return t.walkClasses(n=>{n.value.startsWith(b)&&e.push(n);}),e.length===0?null:e[e.length-1]}var C=new Set(["cn-menu-target","cn-menu-translucent","cn-logical-sides","cn-rtl-flip","cn-font-heading"]);function m(t){return Node.isStringLiteral(t)||Node.isNoSubstitutionTemplateLiteral(t)}var w=async({sourceFile:t,styleMap:e})=>{let n=new Set;return H(t,e,n),Q(t,e,n),Z(t,e,n),t};function O(t,e,n){let i=t.getLiteralText(),r=y(i);if(r.length===0)return;let o=r.filter(s=>!n.has(s));if(o.length===0){let s=x(i);t.setLiteralValue(s);return}let f=o.filter(s=>!C.has(s)).map(s=>e[s]).filter(s=>!!s);if(f.length>0){let s=f.join(" "),g=x(h(s,i));t.setLiteralValue(g),o.forEach(l=>n.add(l));}else {let s=x(i);t.setLiteralValue(s);}}function H(t,e,n){t.forEachDescendant(i=>{if(!Node.isCallExpression(i))return;let r=i.getExpression();if(!Node.isIdentifier(r)||r.getText()!=="cva")return;let o=i.getArguments()[0];Node.isStringLiteral(o)&&O(o,e,n);let c=i.getArguments()[1];if(!c||!Node.isObjectLiteralExpression(c))return;let f=c.getProperties().find(g=>Node.isPropertyAssignment(g)&&Node.isIdentifier(g.getNameNode())&&g.getNameNode().getText()==="variants");if(!f||!Node.isPropertyAssignment(f))return;let s=f.getInitializer();!s||!Node.isObjectLiteralExpression(s)||s.getProperties().forEach(g=>{if(!Node.isPropertyAssignment(g))return;let l=g.getInitializer();!l||!Node.isObjectLiteralExpression(l)||l.getProperties().forEach(p=>{if(!Node.isPropertyAssignment(p))return;let u=p.getInitializer();u&&Node.isStringLiteral(u)&&O(u,e,n);});});});}function Q(t,e,n){t.forEachDescendant(i=>{if(!Node.isJsxAttribute(i)||i.getNameNode().getText()!=="className")return;let r=i.getInitializer();if(!r)return;let o=U(r);if(o.length===0)return;let c=i.getParent()?.getParent();if(!c||!Node.isJsxOpeningElement(c)&&!Node.isJsxSelfClosingElement(c))return;let f=o.filter(l=>!n.has(l));if(f.length===0){$(r);return}let g=f.filter(l=>!C.has(l)).map(l=>e[l]).filter(l=>!!l);if(g.length>0){let l=g.join(" ");Y(c,l);}else $(r);});}function U(t){let e=[];if(m(t))return y(t.getLiteralText());if(!Node.isJsxExpression(t))return e;let n=t.getExpression();if(!n)return e;if(m(n))return y(n.getLiteralText());if(Node.isCallExpression(n)&&E(n))for(let i of n.getArguments())m(i)&&e.push(...y(i.getLiteralText()));return e}function $(t){if(m(t)){let n=x(t.getLiteralText());t.setLiteralValue(n);return}if(!Node.isJsxExpression(t))return;let e=t.getExpression();if(e){if(m(e)){let n=x(e.getLiteralText());e.setLiteralValue(n);return}if(Node.isCallExpression(e)&&E(e)){for(let n of e.getArguments())if(m(n)){let i=x(n.getLiteralText());n.setLiteralValue(i);}L(e);}}}function y(t){let e=t.matchAll(/\bcn-[\w-]+\b/g);return Array.from(e,n=>n[0])}function x(t){return t.replace(/\bcn-[\w-]+\b/g,e=>C.has(e)?e:"").replace(/\s+/g," ").trim()}function L(t){if(!E(t))return;let e=t.getArguments(),n=e.filter(i=>m(i)?i.getLiteralText().trim()!=="":true);if(n.length!==e.length){let i=n.map(o=>o.getText()),r=t.getParent();r&&Node.isJsxExpression(r)?r.replaceWithText(`{cn(${i.join(", ")})}`):t.replaceWithText(`cn(${i.join(", ")})`);}}function Y(t,e){if(!Node.isJsxOpeningElement(t)&&!Node.isJsxSelfClosingElement(t))return;let n=t.getAttributes().find(o=>Node.isJsxAttribute(o)&&o.getNameNode().getText()==="className");if(!n||!Node.isJsxAttribute(n)){t.addAttribute({name:"className",initializer:`{cn(${JSON.stringify(e)})}`});return}let i=n.getInitializer();if(!i){n.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(m(i)){let o=i.getLiteralText(),c=x(h(e,o));i.setLiteralValue(c);return}if(!Node.isJsxExpression(i))return;let r=i.getExpression();if(!r){n.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(m(r)){let o=r.getLiteralText(),c=x(h(e,o));r.setLiteralValue(c);return}if(Node.isCallExpression(r)&&E(r)){let o=r.getArguments()[0];if(m(o)){let s=o.getLiteralText(),g=x(h(e,s));o.setLiteralValue(g);for(let l=1;l<r.getArguments().length;l++){let p=r.getArguments()[l];if(m(p)){let u=p.getLiteralText(),d=x(u);d!==u&&p.setLiteralValue(d);}}L(r);return}let c=r.getArguments().map(s=>{if(m(s)){let g=x(s.getLiteralText());return g?JSON.stringify(g):null}return s.getText()}).filter(s=>s!==null),f=[JSON.stringify(e),...c];n.setInitializer(`{cn(${f.join(", ")})}`);return}n.setInitializer(`{cn(${JSON.stringify(e)}, ${r.getText()})}`);}function h(t,e){return twMerge(t,e)}function E(t){let e=t.getExpression();return Node.isIdentifier(e)&&e.getText()==="cn"}function Z(t,e,n){t.forEachDescendant(i=>{if(!Node.isCallExpression(i))return;let r=i.getExpression();if(!(!Node.isIdentifier(r)||r.getText()!=="mergeProps"))for(let o of i.getArguments()){if(!Node.isObjectLiteralExpression(o))continue;let c=o.getProperties().find(s=>Node.isPropertyAssignment(s)&&Node.isIdentifier(s.getNameNode())&&s.getNameNode().getText()==="className");if(!c||!Node.isPropertyAssignment(c))continue;let f=c.getInitializer();if(f&&Node.isCallExpression(f)&&E(f)){let s=tt(f);if(s.length===0)continue;let g=s.filter(u=>!n.has(u));if(g.length===0){P(f);continue}let p=g.filter(u=>!C.has(u)).map(u=>e[u]).filter(u=>!!u);if(p.length>0){let u=p.join(" ");et(f,u,n,g);}else P(f);}}});}function tt(t){let e=[];for(let n of t.getArguments())m(n)&&e.push(...y(n.getLiteralText()));return e}function P(t){for(let e of t.getArguments())if(m(e)){let n=x(e.getLiteralText());e.setLiteralValue(n);}L(t);}function et(t,e,n,i){let r=t.getArguments()[0];if(m(r)){let s=r.getLiteralText(),g=x(h(e,s));r.setLiteralValue(g),i.forEach(l=>n.add(l));for(let l=1;l<t.getArguments().length;l++){let p=t.getArguments()[l];if(m(p)){let u=p.getLiteralText(),d=x(u);d!==u&&p.setLiteralValue(d);}}L(t);return}let o=t.getArguments().map(s=>{if(m(s)){let g=x(s.getLiteralText());return g?JSON.stringify(g):null}return s.getText()}).filter(s=>s!==null),c=[JSON.stringify(e),...o];i.forEach(s=>n.add(s)),t.getParent()&&t.replaceWithText(`cn(${c.join(", ")})`);}async function st(t,{styleMap:e,transformers:n=[w]}){let r=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",t,{scriptKind:ScriptKind.TSX,overwrite:true});for(let o of n)await o({sourceFile:r,styleMap:e});return r.getText()}var it=async({sourceFile:t,config:e})=>{if(!e.style?.startsWith("base-"))return t;let n=[],i=t.getDescendantsOfKind(SyntaxKind.JsxElement);for(let r of i){let o=r.getOpeningElement(),c=o.getAttribute("render");if(!c)continue;let s=r.getJsxChildren().map(S=>S.getText()).join("").trim();if(!s||c.getKind()!==SyntaxKind.JsxAttribute)continue;let l=c.asKindOrThrow(SyntaxKind.JsxAttribute).getInitializer();if(!l||l.getKind()!==SyntaxKind.JsxExpression)continue;let u=l.asKindOrThrow(SyntaxKind.JsxExpression).getExpression();if(!u||u.getKind()!==SyntaxKind.JsxSelfClosingElement)continue;let d=u.asKindOrThrow(SyntaxKind.JsxSelfClosingElement),A=d.getTagNameNode().getText(),I=d.getAttributes().map(S=>S.getText()).join(" "),J=I?`{<${A} ${I}>${s}</${A}>}`:`{<${A}>${s}</${A}>}`,M=o.getTagNameNode().getText(),j=o.getAttributes().filter(S=>S.getKind()===SyntaxKind.JsxAttribute?S.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()!=="render":true).map(S=>S.getText()).join(" "),V=j?`${j} render=${J}`:`render=${J}`,F=`<${M} ${V} />`;n.push({elementStart:r.getStart(),elementEnd:r.getEnd(),newText:F});}for(let r of n.reverse()){let o=t.getFullText(),c=o.substring(0,r.elementStart)+r.newText+o.substring(r.elementEnd);t.replaceWithText(c);}return t};export{B as createStyleMap,it as transformRender,st as transformStyle};
1
+ export{e as transformDirection,f as transformFont,c as transformIcons,g as transformMenu}from'../chunk-7SBJAAAY.js';import'../chunk-CHWMSXYA.js';import W from'postcss';import D from'postcss-selector-parser';import {z}from'zod';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';import {twMerge}from'tailwind-merge';var b="cn-",k=z.record(z.string().startsWith(b),z.string());function B(t){let e=W.parse(t),n={};return e.walkRules(i=>{let r=i.selectors??[];if(r.length===0)return;let o=_(i);if(o)for(let c of r){let f=X(c);D(s=>{s.each(g=>{let l=q(g);if(!l)return;let p=l.value;p.startsWith(b)&&(n[p]=n[p]?`${o} ${n[p]}`:o);});}).processSync(f);}}),k.parse(n)}function X(t){return t.replace(/\s*&\s*/g,"").trim()}function _(t){let e=[];for(let n of t.nodes||[])if(n.type==="atrule"&&n.name==="apply"){let i=n.params.trim();i&&e.push(i);}return e.length===0?null:e.join(" ")}function q(t){let e=[];return t.walkClasses(n=>{n.value.startsWith(b)&&e.push(n);}),e.length===0?null:e[e.length-1]}var C=new Set(["cn-menu-target","cn-menu-translucent","cn-logical-sides","cn-rtl-flip","cn-font-heading"]);function m(t){return Node.isStringLiteral(t)||Node.isNoSubstitutionTemplateLiteral(t)}var w=async({sourceFile:t,styleMap:e})=>{let n=new Set;return H(t,e,n),Q(t,e,n),Z(t,e,n),t};function O(t,e,n){let i=t.getLiteralText(),r=y(i);if(r.length===0)return;let o=r.filter(s=>!n.has(s));if(o.length===0){let s=x(i);t.setLiteralValue(s);return}let f=o.filter(s=>!C.has(s)).map(s=>e[s]).filter(s=>!!s);if(f.length>0){let s=f.join(" "),g=x(h(s,i));t.setLiteralValue(g),o.forEach(l=>n.add(l));}else {let s=x(i);t.setLiteralValue(s);}}function H(t,e,n){t.forEachDescendant(i=>{if(!Node.isCallExpression(i))return;let r=i.getExpression();if(!Node.isIdentifier(r)||r.getText()!=="cva")return;let o=i.getArguments()[0];Node.isStringLiteral(o)&&O(o,e,n);let c=i.getArguments()[1];if(!c||!Node.isObjectLiteralExpression(c))return;let f=c.getProperties().find(g=>Node.isPropertyAssignment(g)&&Node.isIdentifier(g.getNameNode())&&g.getNameNode().getText()==="variants");if(!f||!Node.isPropertyAssignment(f))return;let s=f.getInitializer();!s||!Node.isObjectLiteralExpression(s)||s.getProperties().forEach(g=>{if(!Node.isPropertyAssignment(g))return;let l=g.getInitializer();!l||!Node.isObjectLiteralExpression(l)||l.getProperties().forEach(p=>{if(!Node.isPropertyAssignment(p))return;let u=p.getInitializer();u&&Node.isStringLiteral(u)&&O(u,e,n);});});});}function Q(t,e,n){t.forEachDescendant(i=>{if(!Node.isJsxAttribute(i)||i.getNameNode().getText()!=="className")return;let r=i.getInitializer();if(!r)return;let o=U(r);if(o.length===0)return;let c=i.getParent()?.getParent();if(!c||!Node.isJsxOpeningElement(c)&&!Node.isJsxSelfClosingElement(c))return;let f=o.filter(l=>!n.has(l));if(f.length===0){$(r);return}let g=f.filter(l=>!C.has(l)).map(l=>e[l]).filter(l=>!!l);if(g.length>0){let l=g.join(" ");Y(c,l);}else $(r);});}function U(t){let e=[];if(m(t))return y(t.getLiteralText());if(!Node.isJsxExpression(t))return e;let n=t.getExpression();if(!n)return e;if(m(n))return y(n.getLiteralText());if(Node.isCallExpression(n)&&E(n))for(let i of n.getArguments())m(i)&&e.push(...y(i.getLiteralText()));return e}function $(t){if(m(t)){let n=x(t.getLiteralText());t.setLiteralValue(n);return}if(!Node.isJsxExpression(t))return;let e=t.getExpression();if(e){if(m(e)){let n=x(e.getLiteralText());e.setLiteralValue(n);return}if(Node.isCallExpression(e)&&E(e)){for(let n of e.getArguments())if(m(n)){let i=x(n.getLiteralText());n.setLiteralValue(i);}L(e);}}}function y(t){let e=t.matchAll(/\bcn-[\w-]+\b/g);return Array.from(e,n=>n[0])}function x(t){return t.replace(/\bcn-[\w-]+\b/g,e=>C.has(e)?e:"").replace(/\s+/g," ").trim()}function L(t){if(!E(t))return;let e=t.getArguments(),n=e.filter(i=>m(i)?i.getLiteralText().trim()!=="":true);if(n.length!==e.length){let i=n.map(o=>o.getText()),r=t.getParent();r&&Node.isJsxExpression(r)?r.replaceWithText(`{cn(${i.join(", ")})}`):t.replaceWithText(`cn(${i.join(", ")})`);}}function Y(t,e){if(!Node.isJsxOpeningElement(t)&&!Node.isJsxSelfClosingElement(t))return;let n=t.getAttributes().find(o=>Node.isJsxAttribute(o)&&o.getNameNode().getText()==="className");if(!n||!Node.isJsxAttribute(n)){t.addAttribute({name:"className",initializer:`{cn(${JSON.stringify(e)})}`});return}let i=n.getInitializer();if(!i){n.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(m(i)){let o=i.getLiteralText(),c=x(h(e,o));i.setLiteralValue(c);return}if(!Node.isJsxExpression(i))return;let r=i.getExpression();if(!r){n.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(m(r)){let o=r.getLiteralText(),c=x(h(e,o));r.setLiteralValue(c);return}if(Node.isCallExpression(r)&&E(r)){let o=r.getArguments()[0];if(m(o)){let s=o.getLiteralText(),g=x(h(e,s));o.setLiteralValue(g);for(let l=1;l<r.getArguments().length;l++){let p=r.getArguments()[l];if(m(p)){let u=p.getLiteralText(),d=x(u);d!==u&&p.setLiteralValue(d);}}L(r);return}let c=r.getArguments().map(s=>{if(m(s)){let g=x(s.getLiteralText());return g?JSON.stringify(g):null}return s.getText()}).filter(s=>s!==null),f=[JSON.stringify(e),...c];n.setInitializer(`{cn(${f.join(", ")})}`);return}n.setInitializer(`{cn(${JSON.stringify(e)}, ${r.getText()})}`);}function h(t,e){return twMerge(t,e)}function E(t){let e=t.getExpression();return Node.isIdentifier(e)&&e.getText()==="cn"}function Z(t,e,n){t.forEachDescendant(i=>{if(!Node.isCallExpression(i))return;let r=i.getExpression();if(!(!Node.isIdentifier(r)||r.getText()!=="mergeProps"))for(let o of i.getArguments()){if(!Node.isObjectLiteralExpression(o))continue;let c=o.getProperties().find(s=>Node.isPropertyAssignment(s)&&Node.isIdentifier(s.getNameNode())&&s.getNameNode().getText()==="className");if(!c||!Node.isPropertyAssignment(c))continue;let f=c.getInitializer();if(f&&Node.isCallExpression(f)&&E(f)){let s=tt(f);if(s.length===0)continue;let g=s.filter(u=>!n.has(u));if(g.length===0){P(f);continue}let p=g.filter(u=>!C.has(u)).map(u=>e[u]).filter(u=>!!u);if(p.length>0){let u=p.join(" ");et(f,u,n,g);}else P(f);}}});}function tt(t){let e=[];for(let n of t.getArguments())m(n)&&e.push(...y(n.getLiteralText()));return e}function P(t){for(let e of t.getArguments())if(m(e)){let n=x(e.getLiteralText());e.setLiteralValue(n);}L(t);}function et(t,e,n,i){let r=t.getArguments()[0];if(m(r)){let s=r.getLiteralText(),g=x(h(e,s));r.setLiteralValue(g),i.forEach(l=>n.add(l));for(let l=1;l<t.getArguments().length;l++){let p=t.getArguments()[l];if(m(p)){let u=p.getLiteralText(),d=x(u);d!==u&&p.setLiteralValue(d);}}L(t);return}let o=t.getArguments().map(s=>{if(m(s)){let g=x(s.getLiteralText());return g?JSON.stringify(g):null}return s.getText()}).filter(s=>s!==null),c=[JSON.stringify(e),...o];i.forEach(s=>n.add(s)),t.getParent()&&t.replaceWithText(`cn(${c.join(", ")})`);}async function st(t,{styleMap:e,transformers:n=[w]}){let r=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",t,{scriptKind:ScriptKind.TSX,overwrite:true});for(let o of n)await o({sourceFile:r,styleMap:e});return r.getText()}var it=async({sourceFile:t,config:e})=>{if(!e.style?.startsWith("base-"))return t;let n=[],i=t.getDescendantsOfKind(SyntaxKind.JsxElement);for(let r of i){let o=r.getOpeningElement(),c=o.getAttribute("render");if(!c)continue;let s=r.getJsxChildren().map(S=>S.getText()).join("").trim();if(!s||c.getKind()!==SyntaxKind.JsxAttribute)continue;let l=c.asKindOrThrow(SyntaxKind.JsxAttribute).getInitializer();if(!l||l.getKind()!==SyntaxKind.JsxExpression)continue;let u=l.asKindOrThrow(SyntaxKind.JsxExpression).getExpression();if(!u||u.getKind()!==SyntaxKind.JsxSelfClosingElement)continue;let d=u.asKindOrThrow(SyntaxKind.JsxSelfClosingElement),A=d.getTagNameNode().getText(),I=d.getAttributes().map(S=>S.getText()).join(" "),J=I?`{<${A} ${I}>${s}</${A}>}`:`{<${A}>${s}</${A}>}`,M=o.getTagNameNode().getText(),j=o.getAttributes().filter(S=>S.getKind()===SyntaxKind.JsxAttribute?S.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()!=="render":true).map(S=>S.getText()).join(" "),V=j?`${j} render=${J}`:`render=${J}`,F=`<${M} ${V} />`;n.push({elementStart:r.getStart(),elementEnd:r.getEnd(),newText:F});}for(let r of n.reverse()){let o=t.getFullText(),c=o.substring(0,r.elementStart)+r.newText+o.substring(r.elementEnd);t.replaceWithText(c);}return t};export{B as createStyleMap,it as transformRender,st as transformStyle};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadcn",
3
- "version": "4.8.1",
3
+ "version": "4.8.3",
4
4
  "description": "Add components to your apps.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,2 +0,0 @@
1
- import {a}from'./chunk-CHWMSXYA.js';import {SyntaxKind,Project,ScriptKind}from'ts-morph';import {promises}from'fs';import {twMerge}from'tailwind-merge';var ot=async({sourceFile:r,config:n})=>{let e=n.iconLibrary;if(!e||!(e in a))return r;let t=e,i=a[t],o=[];for(let a$1 of r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)){if(a$1.getTagNameNode()?.getText()!=="IconPlaceholder")continue;let f=a$1.getAttributes().find(g=>g.getKind()!==SyntaxKind.JsxAttribute?false:g.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()===t);if(!f)continue;let s=f.asKindOrThrow(SyntaxKind.JsxAttribute),l=s.getInitializer()?.getText().replace(/^["']|["']$/g,"");if(!l)continue;o.includes(l)||o.push(l);let u=i.usage.match(/<(\w+)([^>]*)\s*\/>/);s.remove();for(let g of a$1.getAttributes()){if(g.getKind()!==SyntaxKind.JsxAttribute)continue;let x=g.asKindOrThrow(SyntaxKind.JsxAttribute);x.getNameNode().getText()in a&&x.remove();}if(!u){a$1.getTagNameNode()?.replaceWithText(l);continue}let[,b,K]=u;if(b==="ICON"){let g=a$1.getAttributes().filter(x=>x.getKind()!==SyntaxKind.JsxAttribute?true:!(x.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(x=>x.getText()).join(" ");g.trim()?a$1.replaceWithText(`<${l} ${g} />`):a$1.getTagNameNode()?.replaceWithText(l);}else {let g=new Set(a$1.getAttributes().filter(m=>m.getKind()===SyntaxKind.JsxAttribute).map(m=>m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText())),A=K.replace(/\{ICON\}/g,`{${l}}`).trim().split(/\s+(?=\w+=)/).filter(m=>m).map(m=>{let E=m.split("=")[0];return E&&!g.has(E)?m:null}).filter(Boolean),$=a$1.getAttributes().filter(m=>m.getKind()!==SyntaxKind.JsxAttribute?true:!(m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(m=>m.getText()).join(" "),M=[...A,$].filter(Boolean).join(" ");a$1.replaceWithText(`<${b} ${M} />`);}}for(let a of r.getImportDeclarations()??[])if(a.getModuleSpecifier()?.getText()?.includes("icon-placeholder")){let l=(a.getNamedImports()??[]).find(d=>d.getName()==="IconPlaceholder");l&&l.remove(),a.getNamedImports()?.length===0&&a.remove();}if(o.length>0){let a=i.import.split(`
2
- `),f=[];for(let s of a){let l=s.match(/import\s+{([^}]+)}\s+from\s+['"]([^'"]+)['"]/);if(!l)continue;let[,d,u]=l,b=d.split(",").map(g=>g.trim()).map(g=>g==="ICON"?o.map(x=>({name:x})):{name:g}).flat(),K=r.addImportDeclaration({moduleSpecifier:u,namedImports:b});f.push(K);}if(!z(r))for(let s of f)s.replaceWithText(s.getText().replace(";",""));}return r};function z(r){return r.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}var ft=async({sourceFile:r,config:n,baseColor:e})=>(n.tailwind?.cssVariables||!e?.inlineColors||r.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(t=>{let i=t.getLiteralText(),o=J(i,e.inlineColors).trim();o!==i&&t.setLiteralValue(o);}),r);function I(r){if(!r.includes("/")&&!r.includes(":"))return [null,r,null];let n=-1,e=0;for(let s=r.length-1;s>=0;s--){let l=r[s];if(l==="]")e++;else if(l==="[")e--;else if(l===":"&&e===0){n=s;break}}let t=null,i;n===-1?i=r:(t=r.slice(0,n),i=r.slice(n+1));let o=i.lastIndexOf("/");if(o===-1)return [t,i,null];let a=i.slice(0,o),f=i.slice(o+1);return [t,a,f]}var k=["bg-","text-","border-","ring-offset-","ring-"];function J(r,n){r.includes(" border ")&&(r=r.replace(" border "," border border-border "));let e=r.split(" "),t=new Set,i=new Set;for(let o of e){let[a,f,s]=I(o),l=k.find(u=>f?.startsWith(u));if(!l){t.has(o)||t.add(o);continue}let d=f?.replace(l,"");if(d&&d in n.light){t.add([a,`${l}${n.light[d]}`].filter(Boolean).join(":")+(s?`/${s}`:"")),i.add(["dark",a,`${l}${n.dark[d]}`].filter(Boolean).join(":")+(s?`/${s}`:""));continue}t.has(o)||t.add(o);}return [...Array.from(t),...Array.from(i)].join(" ").trim()}var V=[["-ml-","-ms-"],["-mr-","-me-"],["ml-","ms-"],["mr-","me-"],["pl-","ps-"],["pr-","pe-"],["-left-","-start-"],["-right-","-end-"],["left-","start-"],["right-","end-"],["inset-l-","inset-inline-start-"],["inset-r-","inset-inline-end-"],["rounded-tl-","rounded-ss-"],["rounded-tr-","rounded-se-"],["rounded-bl-","rounded-es-"],["rounded-br-","rounded-ee-"],["rounded-l-","rounded-s-"],["rounded-r-","rounded-e-"],["border-l-","border-s-"],["border-r-","border-e-"],["border-l","border-s"],["border-r","border-e"],["text-left","text-start"],["text-right","text-end"],["scroll-ml-","scroll-ms-"],["scroll-mr-","scroll-me-"],["scroll-pl-","scroll-ps-"],["scroll-pr-","scroll-pe-"],["float-left","float-start"],["float-right","float-end"],["clear-left","clear-start"],["clear-right","clear-end"],["origin-top-left","origin-top-start"],["origin-top-right","origin-top-end"],["origin-bottom-left","origin-bottom-start"],["origin-bottom-right","origin-bottom-end"],["origin-left","origin-start"],["origin-right","origin-end"]],B=[["-translate-x-","translate-x-"],["translate-x-","-translate-x-"]],G=[["space-x-","space-x-reverse"],["divide-x-","divide-x-reverse"]],X=[["cursor-w-resize","cursor-e-resize"],["cursor-e-resize","cursor-w-resize"]],F=[["data-[side=inline-start]","slide-in-from-right","slide-in-from-end"],["data-[side=inline-start]","slide-out-to-right","slide-out-to-end"],["data-[side=inline-end]","slide-in-from-left","slide-in-from-start"],["data-[side=inline-end]","slide-out-to-left","slide-out-to-start"]],Q="cn-rtl-flip",P=["ContextMenuContent","ContextMenuSubContent","DropdownMenuSubContent"],C={right:"inline-end",left:"inline-start"},U=["-left-","-right-","left-","right-"],pt=async({sourceFile:r,config:n})=>(n.rtl&&O(r),r);async function xt(r,n){if(!n)return r;let t=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",r,{scriptKind:ScriptKind.TSX,overwrite:true});return O(t),t.getText()}function L(r){return r.replace(/^["']|["']$/g,"")}function h(r){let n=L(r.getText()??"");r.replaceWithText(`"${q(n)}"`);}function q(r){return r.split(" ").flatMap(n=>{if(n.startsWith("rtl:")||n.startsWith("ltr:"))return [n];if(n===Q)return ["rtl:rotate-180"];let[e,t,i]=I(n);if(!t)return [n];for(let[s,l]of B)if(t.startsWith(s)){let d=t.replace(s,l),u=e?`rtl:${e}:${d}${i?`/${i}`:""}`:`rtl:${d}${i?`/${i}`:""}`;return [n,u]}for(let[s,l]of G)if(t.startsWith(s)){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l]of X)if(t===s){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l,d]of F)if(e?.includes(s)&&t.startsWith(l)){let u=t.replace(l,d);return [i?`${e}:${u}/${i}`:`${e}:${u}`]}let o=e?.includes("data-[side=left]")||e?.includes("data-[side=right]"),a=t;for(let[s,l]of V)if(!(o&&U.some(d=>s.startsWith(d)))&&t.startsWith(s)){if(!s.endsWith("-")&&t!==s)continue;a=t.replace(s,l);break}let f;return e?f=i?`${e}:${a}/${i}`:`${e}:${a}`:f=i?`${a}/${i}`:a,[f]}).join(" ")}function O(r){r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="cva").forEach(n=>{let e=n.getArguments()[0];e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&n.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(t=>t.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(t=>{t.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{let o=i.getInitializerIfKind(SyntaxKind.StringLiteral);o&&h(o);});});}),r.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(n=>{if(n.getNameNode().getText()==="className"){let e=n.getInitializer();if(e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let t=n.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(i=>i.getExpression().getText()==="cn");t&&t.getArguments().forEach(i=>{(i.isKind(SyntaxKind.ConditionalExpression)||i.isKind(SyntaxKind.BinaryExpression))&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),i.isKind(SyntaxKind.StringLiteral)&&h(i);});}}n.getNameNode().getText()==="classNames"&&n.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&n.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(e=>{if(e.getInitializer()?.isKind(SyntaxKind.CallExpression)){let i=e.getInitializerIfKind(SyntaxKind.CallExpression);i&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.ConditionalExpression)&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),o.isKind(SyntaxKind.StringLiteral)&&h(o);});}let t=e.getInitializer();t?.isKind(SyntaxKind.StringLiteral)&&e.getNameNode().getText()!=="variant"&&h(t);});}),r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="mergeProps").forEach(n=>{let e=n.getArguments()[0];if(e?.isKind(SyntaxKind.ObjectLiteralExpression)){let t=e.getProperties().find(i=>i.isKind(SyntaxKind.PropertyAssignment)&&i.getName()==="className");if(t?.isKind(SyntaxKind.PropertyAssignment)){let i=t.getInitializer();i?.isKind(SyntaxKind.CallExpression)&&i.getExpression().getText()==="cn"&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.StringLiteral)&&h(o),(o.isKind(SyntaxKind.ConditionalExpression)||o.isKind(SyntaxKind.BinaryExpression))&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h);}),i?.isKind(SyntaxKind.StringLiteral)&&h(i);}}}),[...r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),...r.getDescendantsOfKind(SyntaxKind.JsxOpeningElement)].forEach(n=>{let e=n.getTagNameNode().getText();if(!P.includes(e))return;let t=n.getAttributes().find(f=>f.isKind(SyntaxKind.JsxAttribute)&&f.getNameNode().getText()==="side");if(!t?.isKind(SyntaxKind.JsxAttribute))return;let i=t.getInitializer();if(!i?.isKind(SyntaxKind.StringLiteral))return;let o=L(i.getText()??""),a=C[o];a&&i.replaceWithText(`"${a}"`);}),r.getDescendantsOfKind(SyntaxKind.BindingElement).forEach(n=>{if(n.getNameNode().getText()!=="side")return;let i=n.getFirstAncestorByKind(SyntaxKind.FunctionDeclaration)?.getName();if(!i||!P.includes(i))return;let o=n.getInitializer();if(!o?.isKind(SyntaxKind.StringLiteral))return;let a=L(o.getText()??""),f=C[a];f&&o.replaceWithText(`"${f}"`);});}var D=[{marker:"cn-font-heading",utility:"font-heading",supportToken:"--font-heading:"}],w=/\bcn-font-heading\b/,v=new Map;async function Y(r,n=[]){let e=new Set(n);if(!r)return e;let t=v.get(r);return t||(t=promises.readFile(r,"utf8").then(i=>{let o=new Set;for(let a of D)i.includes(a.supportToken)&&o.add(a.marker);return o}).catch(()=>new Set),v.set(r,t)),(await t).forEach(i=>{e.add(i);}),e}function R(r,n){let e=r;for(let t of D)e.includes(t.marker)&&(e=e.replace(new RegExp(`\\b${t.marker}\\b`,"g"),n.has(t.marker)?t.utility:""));return e.replace(/\s+/g," ").trim()}function N(r,n){let e=r.getLiteralValue();if(!w.test(e))return;let t=R(e,n);t!==e&&r.setLiteralValue(t);}function y(r,n){for(let e of r.getDescendantsOfKind(SyntaxKind.StringLiteral))N(e,n);for(let e of r.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral))N(e,n);}var At=async({sourceFile:r,config:n,supportedFontMarkers:e})=>{let t=await Y(n.resolvedPaths.tailwindCss,e),i=[];for(let o of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){let a=o.getNameNode().getText();if(a!=="className"&&a!=="classNames")continue;let f=o.getInitializer();if(f?.isKind(SyntaxKind.StringLiteral)){let s=f.getLiteralValue();if(w.test(s)){let l=R(s,t);l===""?i.push(o):l!==s&&f.setLiteralValue(l);}}f?.isKind(SyntaxKind.JsxExpression)&&y(f,t);}for(let o of i)o.remove();for(let o of r.getDescendantsOfKind(SyntaxKind.CallExpression)){if(o.getExpression().getText()==="cva"){for(let a of o.getArguments()){if(a.isKind(SyntaxKind.StringLiteral)){N(a,t);continue}if(a.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)){N(a,t);continue}y(a,t);}continue}o.getExpression().getText()==="mergeProps"&&y(o,t);}return r};var et="animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!",yt=async({sourceFile:r,config:n})=>{let e=n.menuColor,t=e==="default-translucent"||e==="inverted-translucent";for(let i of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(i.getNameNode().getText()!=="className")continue;let a=i.getInitializer();if(!a)continue;let f=a.getText();if(!f.includes("cn-menu-target")&&!f.includes("cn-menu-translucent"))continue;let s=f,l=false;e==="inverted"||e==="inverted-translucent"?s=s.replace(/cn-menu-target/g,"dark"):(s=s.replace(/cn-menu-target/g,""),l=true),t?s=s.replace(/"([^"]*cn-menu-translucent[^"]*)"/g,(d,u)=>`"${twMerge(u,et).replace(/\s*\bcn-menu-translucent\b\s*/g," ").trim()}"`):s.includes("cn-menu-translucent")&&(s=s.replace(/cn-menu-translucent/g,""),l=true),l&&(s=s.replace(/\s{2,}/g," "),s=s.replace(/"\s+/g,'"'),s=s.replace(/\s+"/g,'"'),s=s.replace(/,\s*""\s*,/g,","),s=s.replace(/\(\s*""\s*,/g,"("),s=s.replace(/,\s*""\s*\)/g,")")),i.setInitializer(s);}return r};export{ft as a,I as b,ot as c,pt as d,xt as e,At as f,yt as g};