@hanzo/ui 5.3.19 → 5.3.21

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.
Files changed (229) hide show
  1. package/dist/3d/button.js +298 -1
  2. package/dist/3d/button.mjs +273 -1
  3. package/dist/3d/card.js +234 -1
  4. package/dist/3d/card.mjs +207 -1
  5. package/dist/3d/carousel.js +371 -1
  6. package/dist/3d/carousel.mjs +344 -1
  7. package/dist/3d/grid.js +362 -1
  8. package/dist/3d/grid.mjs +337 -1
  9. package/dist/3d/index.js +1518 -1
  10. package/dist/3d/index.mjs +1472 -1
  11. package/dist/3d/marquee.js +352 -1
  12. package/dist/3d/marquee.mjs +327 -1
  13. package/dist/3d/pin.js +46 -1
  14. package/dist/3d/pin.mjs +24 -1
  15. package/dist/accordion.js +80 -1
  16. package/dist/accordion.mjs +55 -1
  17. package/dist/alert-dialog.js +220 -1
  18. package/dist/alert-dialog.mjs +187 -1
  19. package/dist/alert.js +68 -1
  20. package/dist/alert.mjs +64 -1
  21. package/dist/animation/animated-background.js +424 -1
  22. package/dist/animation/animated-background.mjs +418 -1
  23. package/dist/animation/animated-beam.js +119 -1
  24. package/dist/animation/animated-beam.mjs +97 -1
  25. package/dist/animation/animated-cursor.js +275 -1
  26. package/dist/animation/animated-cursor.mjs +270 -1
  27. package/dist/animation/animated-icon.js +357 -2
  28. package/dist/animation/animated-icon.mjs +351 -2
  29. package/dist/animation/animated-list.js +339 -1
  30. package/dist/animation/animated-list.mjs +333 -1
  31. package/dist/animation/animated-number.js +283 -1
  32. package/dist/animation/animated-number.mjs +277 -1
  33. package/dist/animation/animated-testimonials.js +97 -1
  34. package/dist/animation/animated-testimonials.mjs +75 -1
  35. package/dist/animation/animated-tooltip.js +67 -1
  36. package/dist/animation/animated-tooltip.mjs +45 -1
  37. package/dist/animation/apple-cards-carousel.js +308 -1
  38. package/dist/animation/apple-cards-carousel.mjs +285 -1
  39. package/dist/animation/apple-hello-effect.js +60 -1
  40. package/dist/animation/apple-hello-effect.mjs +38 -1
  41. package/dist/animation/index.js +1952 -2
  42. package/dist/animation/index.mjs +1921 -2
  43. package/dist/avatar.js +71 -1
  44. package/dist/avatar.mjs +47 -1
  45. package/dist/badge.js +66 -1
  46. package/dist/badge.mjs +40 -1
  47. package/dist/blocks/index.js +1665 -2
  48. package/dist/blocks/index.mjs +1626 -2
  49. package/dist/breadcrumb.js +107 -1
  50. package/dist/breadcrumb.mjs +99 -1
  51. package/dist/calendar.js +189 -1
  52. package/dist/calendar.mjs +164 -1
  53. package/dist/carousel.js +278 -1
  54. package/dist/carousel.mjs +249 -1
  55. package/dist/checkbox.js +60 -1
  56. package/dist/checkbox.mjs +35 -1
  57. package/dist/code/block.js +226 -2
  58. package/dist/code/block.mjs +203 -2
  59. package/dist/code/compare.js +445 -5
  60. package/dist/code/compare.mjs +422 -5
  61. package/dist/code/diff.js +430 -12
  62. package/dist/code/diff.mjs +406 -11
  63. package/dist/code/editor.js +243 -1
  64. package/dist/code/editor.mjs +218 -1
  65. package/dist/code/explorer.js +291 -1
  66. package/dist/code/explorer.mjs +268 -1
  67. package/dist/code/index.js +2515 -26
  68. package/dist/code/index.mjs +2472 -24
  69. package/dist/code/preview.js +364 -6
  70. package/dist/code/preview.mjs +341 -6
  71. package/dist/code/snippet.js +274 -2
  72. package/dist/code/snippet.mjs +250 -2
  73. package/dist/code/tabs.js +75 -1
  74. package/dist/code/tabs.mjs +53 -1
  75. package/dist/code/terminal.js +437 -3
  76. package/dist/code/terminal.mjs +414 -3
  77. package/dist/collapsible.js +33 -1
  78. package/dist/collapsible.mjs +9 -1
  79. package/dist/command.js +262 -1
  80. package/dist/command.mjs +232 -1
  81. package/dist/context-menu.js +207 -1
  82. package/dist/context-menu.mjs +171 -1
  83. package/dist/device/index.js +3 -1
  84. package/dist/device/index.mjs +2 -0
  85. package/dist/dialog.js +151 -1
  86. package/dist/dialog.mjs +121 -1
  87. package/dist/dock/basic.js +174 -1
  88. package/dist/dock/basic.mjs +151 -1
  89. package/dist/dock/index.js +628 -1
  90. package/dist/dock/index.mjs +601 -1
  91. package/dist/dock/limelight-nav.js +295 -1
  92. package/dist/dock/limelight-nav.mjs +274 -1
  93. package/dist/dock/macos.js +141 -1
  94. package/dist/dock/macos.mjs +118 -1
  95. package/dist/dock/menu.js +70 -1
  96. package/dist/dock/menu.mjs +48 -1
  97. package/dist/dock/message.js +144 -1
  98. package/dist/dock/message.mjs +122 -1
  99. package/dist/drawer.js +115 -1
  100. package/dist/drawer.mjs +103 -1
  101. package/dist/dropdown-menu.js +202 -1
  102. package/dist/dropdown-menu.mjs +166 -1
  103. package/dist/finance/AdvancedChart.js +48 -2
  104. package/dist/finance/AdvancedChart.mjs +46 -2
  105. package/dist/finance/CompanyProfile.js +48 -2
  106. package/dist/finance/CompanyProfile.mjs +46 -2
  107. package/dist/finance/CryptoScreener.js +45 -2
  108. package/dist/finance/CryptoScreener.mjs +43 -2
  109. package/dist/finance/Financials.js +52 -2
  110. package/dist/finance/Financials.mjs +50 -2
  111. package/dist/finance/ForexScreener.js +46 -2
  112. package/dist/finance/ForexScreener.mjs +44 -2
  113. package/dist/finance/MarketOverview.js +104 -2
  114. package/dist/finance/MarketOverview.mjs +102 -2
  115. package/dist/finance/NewsTimeline.js +44 -2
  116. package/dist/finance/NewsTimeline.mjs +42 -2
  117. package/dist/finance/OrderEntry.js +131 -1
  118. package/dist/finance/OrderEntry.mjs +129 -1
  119. package/dist/finance/OrdersHistory.js +64 -1
  120. package/dist/finance/OrdersHistory.mjs +62 -1
  121. package/dist/finance/PositionsList.js +80 -1
  122. package/dist/finance/PositionsList.mjs +78 -1
  123. package/dist/finance/StockScreener.js +46 -2
  124. package/dist/finance/StockScreener.mjs +44 -2
  125. package/dist/finance/SymbolInfo.js +46 -2
  126. package/dist/finance/SymbolInfo.mjs +44 -2
  127. package/dist/finance/TechnicalAnalysis.js +54 -2
  128. package/dist/finance/TechnicalAnalysis.mjs +52 -2
  129. package/dist/finance/TickerTape.js +56 -2
  130. package/dist/finance/TickerTape.mjs +54 -2
  131. package/dist/finance/TradingPanel.js +191 -1
  132. package/dist/finance/TradingPanel.mjs +189 -1
  133. package/dist/finance/index.js +930 -2
  134. package/dist/finance/index.mjs +914 -2
  135. package/dist/form/index.js +155 -1
  136. package/dist/form/index.mjs +125 -1
  137. package/dist/form.js +172 -1
  138. package/dist/form.mjs +142 -1
  139. package/dist/hover-card.js +58 -1
  140. package/dist/hover-card.mjs +34 -1
  141. package/dist/index.js +8467 -192
  142. package/dist/index.mjs +8087 -192
  143. package/dist/input-otp.js +79 -1
  144. package/dist/input-otp.mjs +54 -1
  145. package/dist/lib/utils.js +29 -1
  146. package/dist/lib/utils.mjs +25 -1
  147. package/dist/navigation/index.js +98 -1
  148. package/dist/navigation/index.mjs +79 -1
  149. package/dist/navigation-menu.js +149 -1
  150. package/dist/navigation-menu.mjs +116 -1
  151. package/dist/pattern/grid-pattern.js +326 -3
  152. package/dist/pattern/grid-pattern.mjs +303 -3
  153. package/dist/pattern/index.js +326 -3
  154. package/dist/pattern/index.mjs +303 -3
  155. package/dist/popover.js +63 -1
  156. package/dist/popover.mjs +37 -1
  157. package/dist/primitives/index.js +8467 -192
  158. package/dist/primitives/index.mjs +8087 -192
  159. package/dist/primitives-export.js +8467 -192
  160. package/dist/primitives-export.mjs +8087 -192
  161. package/dist/progress.js +62 -1
  162. package/dist/progress.mjs +37 -1
  163. package/dist/project/gantt.js +65 -1
  164. package/dist/project/gantt.mjs +43 -1
  165. package/dist/project/index.js +636 -1
  166. package/dist/project/index.mjs +611 -1
  167. package/dist/project/kanban.js +597 -1
  168. package/dist/project/kanban.mjs +572 -1
  169. package/dist/project/list.js +35 -1
  170. package/dist/project/list.mjs +12 -1
  171. package/dist/radio-group.js +68 -1
  172. package/dist/radio-group.mjs +45 -1
  173. package/dist/resizable.js +72 -1
  174. package/dist/resizable.mjs +48 -1
  175. package/dist/scroll-area.js +89 -1
  176. package/dist/scroll-area.mjs +66 -1
  177. package/dist/select.js +140 -1
  178. package/dist/select.mjs +111 -1
  179. package/dist/separator.js +59 -1
  180. package/dist/separator.mjs +34 -1
  181. package/dist/sheet.js +148 -1
  182. package/dist/sheet.mjs +117 -1
  183. package/dist/skeleton.js +32 -1
  184. package/dist/skeleton.mjs +27 -1
  185. package/dist/slider.js +99 -1
  186. package/dist/slider.mjs +73 -1
  187. package/dist/sonner.js +34 -1
  188. package/dist/sonner.mjs +29 -1
  189. package/dist/switch.js +62 -1
  190. package/dist/switch.mjs +37 -1
  191. package/dist/table.js +110 -1
  192. package/dist/table.mjs +101 -1
  193. package/dist/tabs.js +82 -1
  194. package/dist/tabs.mjs +57 -1
  195. package/dist/tailwind/index.js +2024 -1
  196. package/dist/tailwind/index.mjs +2012 -1
  197. package/dist/textarea.js +78 -1
  198. package/dist/textarea.mjs +56 -1
  199. package/dist/toggle-group.js +118 -1
  200. package/dist/toggle-group.mjs +93 -1
  201. package/dist/toggle.js +71 -1
  202. package/dist/toggle.mjs +48 -1
  203. package/dist/tooltip.js +67 -1
  204. package/dist/tooltip.mjs +40 -1
  205. package/dist/types/index.js +58 -1
  206. package/dist/types/index.mjs +52 -1
  207. package/dist/ui/announcement.js +129 -1
  208. package/dist/ui/announcement.mjs +107 -1
  209. package/dist/ui/avatar-group.js +88 -1
  210. package/dist/ui/avatar-group.mjs +65 -1
  211. package/dist/ui/banner.js +85 -1
  212. package/dist/ui/banner.mjs +62 -1
  213. package/dist/ui/cursor.js +78 -1
  214. package/dist/ui/cursor.mjs +56 -1
  215. package/dist/ui/index.js +475 -1
  216. package/dist/ui/index.mjs +442 -1
  217. package/dist/ui/marquee.js +74 -1
  218. package/dist/ui/marquee.mjs +52 -1
  219. package/dist/ui/pill.js +85 -1
  220. package/dist/ui/pill.mjs +62 -1
  221. package/dist/ui/spinner.js +28 -1
  222. package/dist/ui/spinner.mjs +26 -1
  223. package/dist/ui/tags.js +101 -1
  224. package/dist/ui/tags.mjs +79 -1
  225. package/dist/ui/ticker.js +73 -1
  226. package/dist/ui/ticker.mjs +51 -1
  227. package/dist/util/index.js +458 -1
  228. package/dist/util/index.mjs +400 -1
  229. package/package.json +1 -1
@@ -1,8 +1,51 @@
1
- import*as s from'react';import {cva}from'class-variance-authority';import {Check,Copy,Eye,EyeOff,Terminal,RefreshCw,Play,Square,Settings,AlertTriangle,X}from'lucide-react';import {cn}from'@hanzo/ui/lib/utils';import {Badge}from'@hanzo/ui/badge';import {Button}from'@hanzo/ui/button';import {CodeSnippet}from'@hanzo/ui/code/snippet';import {Separator}from'@hanzo/ui/separator';import {Tabs,TabsList,TabsTrigger,TabsContent}from'@hanzo/ui/tabs';import {Toggle}from'@hanzo/ui/toggle';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var W=Object.defineProperty;var u=(l,d)=>W(l,"name",{value:d,configurable:true});var pe=cva("relative overflow-hidden rounded-lg border bg-background",{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),ge=u(l=>{let d=l.find(r=>r.type==="html"),n=l.filter(r=>r.type==="css"),f=l.filter(r=>r.type==="js"),c=d?.content||"<div>No HTML file provided</div>";if(n.length>0&&(c=`<style>${n.map(m=>m.content).join(`
2
- `)}</style>
3
- ${c}`),f.length>0){let r=f.map(m=>m.content).join(`
4
- `);c=`${c}
5
- <script>${r}</script>`;}return c},"runHTMLCode"),ue=`
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cva } from 'class-variance-authority';
4
+ import { Check, Copy, Eye, EyeOff, Terminal, RefreshCw, Play, Square, Settings, AlertTriangle, X } from 'lucide-react';
5
+ import { cn } from '@hanzo/ui/lib/utils';
6
+ import { Badge } from '@hanzo/ui/badge';
7
+ import { Button } from '@hanzo/ui/button';
8
+ import { CodeSnippet } from '@hanzo/ui/code/snippet';
9
+ import { Separator } from '@hanzo/ui/separator';
10
+ import { Tabs, TabsList, TabsTrigger, TabsContent } from '@hanzo/ui/tabs';
11
+ import { Toggle } from '@hanzo/ui/toggle';
12
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
+
14
+ var __defProp = Object.defineProperty;
15
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
+ var codePreviewVariants = cva(
17
+ "relative overflow-hidden rounded-lg border bg-background",
18
+ {
19
+ variants: {
20
+ size: {
21
+ sm: "text-xs",
22
+ default: "text-sm",
23
+ lg: "text-base"
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ size: "default"
28
+ }
29
+ }
30
+ );
31
+ var runHTMLCode = /* @__PURE__ */ __name((files) => {
32
+ const htmlFile = files.find((f) => f.type === "html");
33
+ const cssFiles = files.filter((f) => f.type === "css");
34
+ const jsFiles = files.filter((f) => f.type === "js");
35
+ let html = htmlFile?.content || "<div>No HTML file provided</div>";
36
+ if (cssFiles.length > 0) {
37
+ const cssContent = cssFiles.map((f) => f.content).join("\n");
38
+ html = `<style>${cssContent}</style>
39
+ ${html}`;
40
+ }
41
+ if (jsFiles.length > 0) {
42
+ const jsContent = jsFiles.map((f) => f.content).join("\n");
43
+ html = `${html}
44
+ <script>${jsContent}</script>`;
45
+ }
46
+ return html;
47
+ }, "runHTMLCode");
48
+ var consoleScript = `
6
49
  <script>
7
50
  const originalConsole = window.console;
8
51
  const logs = [];
@@ -39,4 +82,296 @@ ${c}`),f.length>0){let r=f.map(m=>m.content).join(`
39
82
  }, '*');
40
83
  });
41
84
  </script>
42
- `,fe=s.forwardRef(({className:l,size:d,files:n,defaultFile:f,showPreview:c=true,showConsole:r=true,autoRun:m=false,maxHeight:M="600px",previewHeight:z="300px",consoleHeight:B="150px",allowFullscreen:D=true,customRunner:x,...I},A)=>{let [b,T]=s.useState(f||n[0]?.filename||""),[$,O]=s.useState(""),[P,R]=s.useState(false),[p,v]=s.useState([]),[w,q]=s.useState(c),[y,J]=s.useState(r),[g,k]=s.useState(false),[X$1,S]=s.useState({}),N=s.useRef(null);n.find(e=>e.filename===b)||n[0];s.useEffect(()=>{let e=u(a=>{(a.data?.type==="console"||a.data?.type==="error")&&v(i=>[...i,a.data.data]);},"handleMessage");return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let C=s.useCallback(async()=>{R(true),v([]);try{let e;if(x?e=await x(n):e=ge(n),e=ue+e,O(e),N.current){let a=N.current.contentDocument;a&&(a.open(),a.write(e),a.close());}}catch(e){v([{type:"error",content:e instanceof Error?e.message:String(e),timestamp:Date.now()}]);}finally{R(false);}},[n,x]);s.useEffect(()=>{if(m){let e=setTimeout(C,1e3);return ()=>clearTimeout(e)}},[n,m,C]);let G=s.useCallback(async e=>{let a=n.find(i=>i.filename===e);if(a)try{await navigator.clipboard.writeText(a.content),S(i=>({...i,[e]:!0})),setTimeout(()=>{S(i=>({...i,[e]:!1}));},2e3);}catch(i){console.error("Failed to copy code:",i);}},[n]),K=u(()=>{v([]);},"clearConsole"),Q=u(()=>jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2 bg-muted/30",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Terminal,{className:"h-4 w-4"}),jsx("span",{className:"text-sm font-medium",children:"Console"}),p.length>0&&jsx(Badge,{variant:"secondary",className:"text-xs",children:p.length})]}),jsx(Button,{variant:"ghost",size:"sm",onClick:K,className:"h-8 w-8 p-0",children:jsx(X,{className:"h-3.5 w-3.5"})})]}),jsx("div",{className:"flex-1 overflow-auto p-2 space-y-1 font-mono text-xs",children:p.length===0?jsx("div",{className:"text-muted-foreground italic",children:"No output"}):p.map((e,a)=>jsxs("div",{className:cn("flex items-start gap-2 p-2 rounded",e.type==="error"&&"bg-red-500/10 text-red-600 dark:text-red-400",e.type==="log"&&"bg-blue-500/10 text-blue-600 dark:text-blue-400",e.type==="output"&&"bg-green-500/10 text-green-600 dark:text-green-400"),children:[jsx("span",{className:"text-xs text-muted-foreground",children:new Date(e.timestamp).toLocaleTimeString()}),jsx("pre",{className:"flex-1 whitespace-pre-wrap break-words",children:e.content})]},a))})]}),"renderConsole"),U=g?"fixed inset-0 z-50 bg-background":"";return jsxs("div",{ref:A,className:cn(pe({size:d}),U,l),style:{maxHeight:g?"100vh":M},...I,children:[jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2",children:[jsx(Tabs,{value:b,onValueChange:T,className:"flex-1",children:jsx(TabsList,{className:"h-auto p-0 bg-transparent",children:n.map(e=>jsxs(TabsTrigger,{value:e.filename,className:"relative flex items-center gap-2 data-[state=active]:bg-muted",children:[jsx("span",{children:e.filename}),jsx(Badge,{variant:"outline",className:"text-xs",children:e.language}),jsx(Button,{variant:"ghost",size:"sm",onClick:a=>{a.stopPropagation(),G(e.filename);},className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:X$1[e.filename]?jsx(Check,{className:"h-3 w-3 text-green-500"}):jsx(Copy,{className:"h-3 w-3"})})]},e.filename))})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Toggle,{pressed:w,onPressedChange:q,"aria-label":"Toggle preview",size:"sm",children:w?jsx(Eye,{className:"h-4 w-4"}):jsx(EyeOff,{className:"h-4 w-4"})}),jsx(Toggle,{pressed:y,onPressedChange:J,"aria-label":"Toggle console",size:"sm",children:jsx(Terminal,{className:"h-4 w-4"})}),jsxs(Button,{variant:"outline",size:"sm",onClick:C,disabled:P,className:"gap-2",children:[P?jsx(RefreshCw,{className:"h-4 w-4 animate-spin"}):jsx(Play,{className:"h-4 w-4"}),"Run"]}),D&&jsx(Button,{variant:"ghost",size:"sm",onClick:()=>k(!g),className:"h-8 w-8 p-0",children:g?jsx(Square,{className:"h-4 w-4"}):jsx(Settings,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"flex flex-col h-full",children:[jsx("div",{className:"flex-1 min-h-0",children:jsx(Tabs,{value:b,onValueChange:T,children:n.map(e=>jsx(TabsContent,{value:e.filename,className:"m-0 h-full",children:jsx(CodeSnippet,{code:e.content,language:e.language,showLineNumbers:true,showCopyButton:false,showHeader:false,maxHeight:"100%",className:"border-0 rounded-none"})},e.filename))})}),(w||y)&&jsxs(Fragment,{children:[jsx(Separator,{}),jsxs("div",{className:"flex flex-col lg:flex-row min-h-0",children:[w&&jsxs("div",{className:"flex-1 min-h-0 border-r last:border-r-0",style:{height:z},children:[jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-2 bg-muted/30",children:[jsx(Eye,{className:"h-4 w-4"}),jsx("span",{className:"text-sm font-medium",children:"Preview"}),p.filter(e=>e.type==="error").length>0&&jsx(AlertTriangle,{className:"h-4 w-4 text-red-500"})]}),jsx("iframe",{ref:N,className:"w-full h-full bg-white",sandbox:"allow-scripts allow-same-origin",srcDoc:$})]}),y&&jsx("div",{className:"flex-1 min-h-0",style:{height:B},children:Q()})]})]})]}),g&&jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>k(false)})]})});fe.displayName="CodePreview";export{fe as CodePreview,pe as codePreviewVariants};
85
+ `;
86
+ var CodePreview = React.forwardRef(
87
+ ({
88
+ className,
89
+ size,
90
+ files,
91
+ defaultFile,
92
+ showPreview = true,
93
+ showConsole = true,
94
+ autoRun = false,
95
+ maxHeight = "600px",
96
+ previewHeight = "300px",
97
+ consoleHeight = "150px",
98
+ allowFullscreen = true,
99
+ customRunner,
100
+ ...props
101
+ }, ref) => {
102
+ const [activeFile, setActiveFile] = React.useState(
103
+ defaultFile || files[0]?.filename || ""
104
+ );
105
+ const [previewContent, setPreviewContent] = React.useState("");
106
+ const [isRunning, setIsRunning] = React.useState(false);
107
+ const [results, setResults] = React.useState([]);
108
+ const [isPreviewVisible, setIsPreviewVisible] = React.useState(showPreview);
109
+ const [isConsoleVisible, setIsConsoleVisible] = React.useState(showConsole);
110
+ const [isFullscreen, setIsFullscreen] = React.useState(false);
111
+ const [copied, setCopied] = React.useState({});
112
+ const iframeRef = React.useRef(null);
113
+ files.find((f) => f.filename === activeFile) || files[0];
114
+ React.useEffect(() => {
115
+ const handleMessage = /* @__PURE__ */ __name((event) => {
116
+ if (event.data?.type === "console" || event.data?.type === "error") {
117
+ setResults((prev) => [...prev, event.data.data]);
118
+ }
119
+ }, "handleMessage");
120
+ window.addEventListener("message", handleMessage);
121
+ return () => window.removeEventListener("message", handleMessage);
122
+ }, []);
123
+ const runCode = React.useCallback(async () => {
124
+ setIsRunning(true);
125
+ setResults([]);
126
+ try {
127
+ let output;
128
+ if (customRunner) {
129
+ output = await customRunner(files);
130
+ } else {
131
+ output = runHTMLCode(files);
132
+ }
133
+ output = consoleScript + output;
134
+ setPreviewContent(output);
135
+ if (iframeRef.current) {
136
+ const doc = iframeRef.current.contentDocument;
137
+ if (doc) {
138
+ doc.open();
139
+ doc.write(output);
140
+ doc.close();
141
+ }
142
+ }
143
+ } catch (error) {
144
+ setResults([
145
+ {
146
+ type: "error",
147
+ content: error instanceof Error ? error.message : String(error),
148
+ timestamp: Date.now()
149
+ }
150
+ ]);
151
+ } finally {
152
+ setIsRunning(false);
153
+ }
154
+ }, [files, customRunner]);
155
+ React.useEffect(() => {
156
+ if (autoRun) {
157
+ const timer = setTimeout(runCode, 1e3);
158
+ return () => clearTimeout(timer);
159
+ }
160
+ }, [files, autoRun, runCode]);
161
+ const copyFileContent = React.useCallback(
162
+ async (filename) => {
163
+ const file = files.find((f) => f.filename === filename);
164
+ if (!file) return;
165
+ try {
166
+ await navigator.clipboard.writeText(file.content);
167
+ setCopied((prev) => ({ ...prev, [filename]: true }));
168
+ setTimeout(() => {
169
+ setCopied((prev) => ({ ...prev, [filename]: false }));
170
+ }, 2e3);
171
+ } catch (error) {
172
+ console.error("Failed to copy code:", error);
173
+ }
174
+ },
175
+ [files]
176
+ );
177
+ const clearConsole = /* @__PURE__ */ __name(() => {
178
+ setResults([]);
179
+ }, "clearConsole");
180
+ const renderConsole = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
181
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2 bg-muted/30", children: [
182
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
183
+ /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" }),
184
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Console" }),
185
+ results.length > 0 && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: results.length })
186
+ ] }),
187
+ /* @__PURE__ */ jsx(
188
+ Button,
189
+ {
190
+ variant: "ghost",
191
+ size: "sm",
192
+ onClick: clearConsole,
193
+ className: "h-8 w-8 p-0",
194
+ children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
195
+ }
196
+ )
197
+ ] }),
198
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-auto p-2 space-y-1 font-mono text-xs", children: results.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground italic", children: "No output" }) : results.map((result, index) => /* @__PURE__ */ jsxs(
199
+ "div",
200
+ {
201
+ className: cn(
202
+ "flex items-start gap-2 p-2 rounded",
203
+ result.type === "error" && "bg-red-500/10 text-red-600 dark:text-red-400",
204
+ result.type === "log" && "bg-blue-500/10 text-blue-600 dark:text-blue-400",
205
+ result.type === "output" && "bg-green-500/10 text-green-600 dark:text-green-400"
206
+ ),
207
+ children: [
208
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: new Date(result.timestamp).toLocaleTimeString() }),
209
+ /* @__PURE__ */ jsx("pre", { className: "flex-1 whitespace-pre-wrap break-words", children: result.content })
210
+ ]
211
+ },
212
+ index
213
+ )) })
214
+ ] }), "renderConsole");
215
+ const layout = isFullscreen ? "fixed inset-0 z-50 bg-background" : "";
216
+ return /* @__PURE__ */ jsxs(
217
+ "div",
218
+ {
219
+ ref,
220
+ className: cn(codePreviewVariants({ size }), layout, className),
221
+ style: { maxHeight: isFullscreen ? "100vh" : maxHeight },
222
+ ...props,
223
+ children: [
224
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
225
+ /* @__PURE__ */ jsx(
226
+ Tabs,
227
+ {
228
+ value: activeFile,
229
+ onValueChange: setActiveFile,
230
+ className: "flex-1",
231
+ children: /* @__PURE__ */ jsx(TabsList, { className: "h-auto p-0 bg-transparent", children: files.map((file) => /* @__PURE__ */ jsxs(
232
+ TabsTrigger,
233
+ {
234
+ value: file.filename,
235
+ className: "relative flex items-center gap-2 data-[state=active]:bg-muted",
236
+ children: [
237
+ /* @__PURE__ */ jsx("span", { children: file.filename }),
238
+ /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-xs", children: file.language }),
239
+ /* @__PURE__ */ jsx(
240
+ Button,
241
+ {
242
+ variant: "ghost",
243
+ size: "sm",
244
+ onClick: (e) => {
245
+ e.stopPropagation();
246
+ copyFileContent(file.filename);
247
+ },
248
+ className: "h-6 w-6 p-0 opacity-0 group-hover:opacity-100",
249
+ children: copied[file.filename] ? /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3" })
250
+ }
251
+ )
252
+ ]
253
+ },
254
+ file.filename
255
+ )) })
256
+ }
257
+ ),
258
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
259
+ /* @__PURE__ */ jsx(
260
+ Toggle,
261
+ {
262
+ pressed: isPreviewVisible,
263
+ onPressedChange: setIsPreviewVisible,
264
+ "aria-label": "Toggle preview",
265
+ size: "sm",
266
+ children: isPreviewVisible ? /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" })
267
+ }
268
+ ),
269
+ /* @__PURE__ */ jsx(
270
+ Toggle,
271
+ {
272
+ pressed: isConsoleVisible,
273
+ onPressedChange: setIsConsoleVisible,
274
+ "aria-label": "Toggle console",
275
+ size: "sm",
276
+ children: /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" })
277
+ }
278
+ ),
279
+ /* @__PURE__ */ jsxs(
280
+ Button,
281
+ {
282
+ variant: "outline",
283
+ size: "sm",
284
+ onClick: runCode,
285
+ disabled: isRunning,
286
+ className: "gap-2",
287
+ children: [
288
+ isRunning ? /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Play, { className: "h-4 w-4" }),
289
+ "Run"
290
+ ]
291
+ }
292
+ ),
293
+ allowFullscreen && /* @__PURE__ */ jsx(
294
+ Button,
295
+ {
296
+ variant: "ghost",
297
+ size: "sm",
298
+ onClick: () => setIsFullscreen(!isFullscreen),
299
+ className: "h-8 w-8 p-0",
300
+ children: isFullscreen ? /* @__PURE__ */ jsx(Square, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4" })
301
+ }
302
+ )
303
+ ] })
304
+ ] }),
305
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
306
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ jsx(Tabs, { value: activeFile, onValueChange: setActiveFile, children: files.map((file) => /* @__PURE__ */ jsx(
307
+ TabsContent,
308
+ {
309
+ value: file.filename,
310
+ className: "m-0 h-full",
311
+ children: /* @__PURE__ */ jsx(
312
+ CodeSnippet,
313
+ {
314
+ code: file.content,
315
+ language: file.language,
316
+ showLineNumbers: true,
317
+ showCopyButton: false,
318
+ showHeader: false,
319
+ maxHeight: "100%",
320
+ className: "border-0 rounded-none"
321
+ }
322
+ )
323
+ },
324
+ file.filename
325
+ )) }) }),
326
+ (isPreviewVisible || isConsoleVisible) && /* @__PURE__ */ jsxs(Fragment, { children: [
327
+ /* @__PURE__ */ jsx(Separator, {}),
328
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row min-h-0", children: [
329
+ isPreviewVisible && /* @__PURE__ */ jsxs(
330
+ "div",
331
+ {
332
+ className: "flex-1 min-h-0 border-r last:border-r-0",
333
+ style: { height: previewHeight },
334
+ children: [
335
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-2 bg-muted/30", children: [
336
+ /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }),
337
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Preview" }),
338
+ results.filter((r) => r.type === "error").length > 0 && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-red-500" })
339
+ ] }),
340
+ /* @__PURE__ */ jsx(
341
+ "iframe",
342
+ {
343
+ ref: iframeRef,
344
+ className: "w-full h-full bg-white",
345
+ sandbox: "allow-scripts allow-same-origin",
346
+ srcDoc: previewContent
347
+ }
348
+ )
349
+ ]
350
+ }
351
+ ),
352
+ isConsoleVisible && /* @__PURE__ */ jsx(
353
+ "div",
354
+ {
355
+ className: "flex-1 min-h-0",
356
+ style: { height: consoleHeight },
357
+ children: renderConsole()
358
+ }
359
+ )
360
+ ] })
361
+ ] })
362
+ ] }),
363
+ isFullscreen && /* @__PURE__ */ jsx(
364
+ "div",
365
+ {
366
+ className: "absolute inset-0 bg-black/50",
367
+ onClick: () => setIsFullscreen(false)
368
+ }
369
+ )
370
+ ]
371
+ }
372
+ );
373
+ }
374
+ );
375
+ CodePreview.displayName = "CodePreview";
376
+
377
+ export { CodePreview, codePreviewVariants };
@@ -1,2 +1,274 @@
1
- 'use strict';var t=require('react'),classVarianceAuthority=require('class-variance-authority'),lucideReact=require('lucide-react'),shiki=require('shiki'),utils=require('@hanzo/ui/lib/utils'),badge=require('@hanzo/ui/badge'),button=require('@hanzo/ui/button'),skeleton=require('@hanzo/ui/skeleton'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var t__namespace=/*#__PURE__*/_interopNamespace(t);var U=Object.defineProperty;var b=(l,o)=>U(l,"name",{value:o,configurable:true});var B=classVarianceAuthority.cva("relative group",{variants:{variant:{default:"rounded-lg border bg-muted/50",inline:"inline-block rounded-md bg-muted px-2 py-1",minimal:"bg-transparent"},theme:{dark:"bg-slate-950 border-slate-800",light:"bg-slate-50 border-slate-200",github:"bg-white border-slate-200","github-dark":"bg-slate-900 border-slate-700",terminal:"bg-black border-green-500/30 text-green-400",retro:"bg-amber-50 border-amber-200 text-amber-900"},size:{xs:"text-xs",sm:"text-sm",default:"text-sm",lg:"text-base"}},defaultVariants:{variant:"default",theme:"dark",size:"default"}}),I=t__namespace.forwardRef(({className:l,variant:o,theme:c,size:p,code:i,language:d="text",filename:f,showLineNumbers:w=false,highlightLines:z=[],showCopyButton:v=true,showLanguageBadge:V=true,showHeader:_=true,maxHeight:P,expandable:h=false,collapsedHeight:A="200px",wrapLines:x=false,startLineNumber:D=1,...F},j)=>{let[k,C]=t__namespace.useState(""),[y,H]=t__namespace.useState(false),[q,L]=t__namespace.useState(true),[m,O]=t__namespace.useState(!h),G={dark:"github-dark",light:"github-light",github:"github-light","github-dark":"github-dark",terminal:"github-dark",retro:"github-light"};t__namespace.useEffect(()=>{b(async()=>{L(true);try{let a=Object.keys(shiki.bundledLanguages).includes(d),s=await shiki.codeToHtml(i,{lang:a?d:"text",theme:G[c||"dark"]}),u=document.createElement("div");u.innerHTML=s;let Q=u.querySelector("code");C(Q?.innerHTML||s);}catch(a){console.error("Failed to highlight code:",a);let s=i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");C(s);}finally{L(false);}},"highlightCode")();},[i,d,c]);let T=t__namespace.useCallback(async()=>{try{await navigator.clipboard.writeText(i),H(!0),setTimeout(()=>H(!1),2e3);}catch(n){console.error("Failed to copy code:",n);}},[i]),M=k.split(`
2
- `).filter((n,a,s)=>n.trim()!==""||a<s.length-1),J=b(()=>jsxRuntime.jsx("code",{className:utils.cn(B({variant:o,theme:c,size:p}),"font-mono",l),dangerouslySetInnerHTML:{__html:k}}),"renderInline"),K=b(()=>jsxRuntime.jsxs("div",{ref:j,className:utils.cn(B({variant:o,theme:c,size:p}),"overflow-hidden",l),...F,children:[_&&(f||d||v||h)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2 bg-muted/30",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[f&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(lucideReact.FileText,{className:"h-3.5 w-3.5 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:f})]}),V&&d&&jsxRuntime.jsx(badge.Badge,{variant:"secondary",className:"text-xs",children:d})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[h&&jsxRuntime.jsxs(button.Button,{variant:"ghost",size:"sm",onClick:()=>O(!m),className:"h-8 w-8 p-0",children:[m?jsxRuntime.jsx(lucideReact.Minimize2,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{className:"sr-only",children:m?"Collapse":"Expand"})]}),v&&jsxRuntime.jsxs(button.Button,{variant:"ghost",size:"sm",onClick:T,className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[y?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-green-500"}):jsxRuntime.jsx(lucideReact.Copy,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{className:"sr-only",children:y?"Copied":"Copy code"})]})]})]}),jsxRuntime.jsx("div",{className:utils.cn("overflow-auto",!x&&"overflow-x-auto"),style:{maxHeight:m?P:A},children:q?jsxRuntime.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:Math.min(M.length||5,10)}).map((n,a)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[w&&jsxRuntime.jsx(skeleton.Skeleton,{className:"h-4 w-8"}),jsxRuntime.jsx(skeleton.Skeleton,{className:"h-4 flex-1"})]},a))}):jsxRuntime.jsx("div",{className:"font-mono",children:M.map((n,a)=>{let s=a+D,u=z.includes(s);return jsxRuntime.jsxs("div",{className:utils.cn("group relative flex min-h-[1.5rem] items-center px-4 py-0.5",u&&"bg-blue-500/10 border-l-2 border-l-blue-500",!x&&"whitespace-nowrap"),children:[w&&jsxRuntime.jsx("span",{className:"mr-4 inline-block w-8 select-none text-right text-xs text-muted-foreground",children:s}),jsxRuntime.jsx("div",{className:utils.cn("flex-1",x?"whitespace-pre-wrap break-words":"overflow-x-auto"),dangerouslySetInnerHTML:{__html:n}})]},a)})})}),h&&!m&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-background to-transparent pointer-events-none"}),o==="minimal"&&v&&jsxRuntime.jsx(button.Button,{variant:"ghost",size:"sm",onClick:T,className:"absolute top-2 right-2 h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:y?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-green-500"}):jsxRuntime.jsx(lucideReact.Copy,{className:"h-3.5 w-3.5"})})]}),"renderBlock");return o==="inline"?J():K()});I.displayName="CodeSnippet";var ae=t__namespace.forwardRef(({children:l,language:o,className:c,...p},i)=>jsxRuntime.jsx(I,{ref:i,code:l,language:o,variant:"inline",showCopyButton:false,showLanguageBadge:false,showHeader:false,className:c,...p}));ae.displayName="InlineCode";exports.CodeSnippet=I;exports.InlineCode=ae;exports.codeSnippetVariants=B;
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var classVarianceAuthority = require('class-variance-authority');
6
+ var lucideReact = require('lucide-react');
7
+ var shiki = require('shiki');
8
+ var utils = require('@hanzo/ui/lib/utils');
9
+ var badge = require('@hanzo/ui/badge');
10
+ var button = require('@hanzo/ui/button');
11
+ var skeleton = require('@hanzo/ui/skeleton');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
+
34
+ var __defProp = Object.defineProperty;
35
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
36
+ var codeSnippetVariants = classVarianceAuthority.cva("relative group", {
37
+ variants: {
38
+ variant: {
39
+ default: "rounded-lg border bg-muted/50",
40
+ inline: "inline-block rounded-md bg-muted px-2 py-1",
41
+ minimal: "bg-transparent"
42
+ },
43
+ theme: {
44
+ dark: "bg-slate-950 border-slate-800",
45
+ light: "bg-slate-50 border-slate-200",
46
+ github: "bg-white border-slate-200",
47
+ "github-dark": "bg-slate-900 border-slate-700",
48
+ terminal: "bg-black border-green-500/30 text-green-400",
49
+ retro: "bg-amber-50 border-amber-200 text-amber-900"
50
+ },
51
+ size: {
52
+ xs: "text-xs",
53
+ sm: "text-sm",
54
+ default: "text-sm",
55
+ lg: "text-base"
56
+ }
57
+ },
58
+ defaultVariants: {
59
+ variant: "default",
60
+ theme: "dark",
61
+ size: "default"
62
+ }
63
+ });
64
+ var CodeSnippet = React__namespace.forwardRef(
65
+ ({
66
+ className,
67
+ variant,
68
+ theme,
69
+ size,
70
+ code,
71
+ language = "text",
72
+ filename,
73
+ showLineNumbers = false,
74
+ highlightLines = [],
75
+ showCopyButton = true,
76
+ showLanguageBadge = true,
77
+ showHeader = true,
78
+ maxHeight,
79
+ expandable = false,
80
+ collapsedHeight = "200px",
81
+ wrapLines = false,
82
+ startLineNumber = 1,
83
+ ...props
84
+ }, ref) => {
85
+ const [highlightedCode, setHighlightedCode] = React__namespace.useState("");
86
+ const [copied, setCopied] = React__namespace.useState(false);
87
+ const [isLoading, setIsLoading] = React__namespace.useState(true);
88
+ const [isExpanded, setIsExpanded] = React__namespace.useState(!expandable);
89
+ const themeMap = {
90
+ dark: "github-dark",
91
+ light: "github-light",
92
+ github: "github-light",
93
+ "github-dark": "github-dark",
94
+ terminal: "github-dark",
95
+ retro: "github-light"
96
+ };
97
+ React__namespace.useEffect(() => {
98
+ const highlightCode = /* @__PURE__ */ __name(async () => {
99
+ setIsLoading(true);
100
+ try {
101
+ const supportedLang = Object.keys(shiki.bundledLanguages).includes(language);
102
+ const highlighted = await shiki.codeToHtml(code, {
103
+ lang: supportedLang ? language : "text",
104
+ theme: themeMap[theme || "dark"]
105
+ });
106
+ const tempDiv = document.createElement("div");
107
+ tempDiv.innerHTML = highlighted;
108
+ const codeElement = tempDiv.querySelector("code");
109
+ setHighlightedCode(codeElement?.innerHTML || highlighted);
110
+ } catch (error) {
111
+ console.error("Failed to highlight code:", error);
112
+ const escaped = code.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
113
+ setHighlightedCode(escaped);
114
+ } finally {
115
+ setIsLoading(false);
116
+ }
117
+ }, "highlightCode");
118
+ highlightCode();
119
+ }, [code, language, theme]);
120
+ const copyToClipboard = React__namespace.useCallback(async () => {
121
+ try {
122
+ await navigator.clipboard.writeText(code);
123
+ setCopied(true);
124
+ setTimeout(() => setCopied(false), 2e3);
125
+ } catch (error) {
126
+ console.error("Failed to copy code:", error);
127
+ }
128
+ }, [code]);
129
+ const lines = highlightedCode.split("\n").filter((line, index, array) => {
130
+ return line.trim() !== "" || index < array.length - 1;
131
+ });
132
+ const renderInline = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntime.jsx(
133
+ "code",
134
+ {
135
+ className: utils.cn(
136
+ codeSnippetVariants({ variant, theme, size }),
137
+ "font-mono",
138
+ className
139
+ ),
140
+ dangerouslySetInnerHTML: { __html: highlightedCode }
141
+ }
142
+ ), "renderInline");
143
+ const renderBlock = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntime.jsxs(
144
+ "div",
145
+ {
146
+ ref,
147
+ className: utils.cn(
148
+ codeSnippetVariants({ variant, theme, size }),
149
+ "overflow-hidden",
150
+ className
151
+ ),
152
+ ...props,
153
+ children: [
154
+ showHeader && (filename || language || showCopyButton || expandable) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2 bg-muted/30", children: [
155
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
156
+ filename && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
157
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "h-3.5 w-3.5 text-muted-foreground" }),
158
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: filename })
159
+ ] }),
160
+ showLanguageBadge && language && /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "secondary", className: "text-xs", children: language })
161
+ ] }),
162
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
163
+ expandable && /* @__PURE__ */ jsxRuntime.jsxs(
164
+ button.Button,
165
+ {
166
+ variant: "ghost",
167
+ size: "sm",
168
+ onClick: () => setIsExpanded(!isExpanded),
169
+ className: "h-8 w-8 p-0",
170
+ children: [
171
+ isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize2, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "h-3.5 w-3.5" }),
172
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: isExpanded ? "Collapse" : "Expand" })
173
+ ]
174
+ }
175
+ ),
176
+ showCopyButton && /* @__PURE__ */ jsxRuntime.jsxs(
177
+ button.Button,
178
+ {
179
+ variant: "ghost",
180
+ size: "sm",
181
+ onClick: copyToClipboard,
182
+ className: "h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
183
+ children: [
184
+ copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" }),
185
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: copied ? "Copied" : "Copy code" })
186
+ ]
187
+ }
188
+ )
189
+ ] })
190
+ ] }),
191
+ /* @__PURE__ */ jsxRuntime.jsx(
192
+ "div",
193
+ {
194
+ className: utils.cn("overflow-auto", !wrapLines && "overflow-x-auto"),
195
+ style: {
196
+ maxHeight: isExpanded ? maxHeight : collapsedHeight
197
+ },
198
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: Array.from({ length: Math.min(lines.length || 5, 10) }).map(
199
+ (_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
200
+ showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-8" }),
201
+ /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 flex-1" })
202
+ ] }, i)
203
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-mono", children: lines.map((line, index) => {
204
+ const lineNumber = index + startLineNumber;
205
+ const isHighlighted = highlightLines.includes(lineNumber);
206
+ return /* @__PURE__ */ jsxRuntime.jsxs(
207
+ "div",
208
+ {
209
+ className: utils.cn(
210
+ "group relative flex min-h-[1.5rem] items-center px-4 py-0.5",
211
+ isHighlighted && "bg-blue-500/10 border-l-2 border-l-blue-500",
212
+ !wrapLines && "whitespace-nowrap"
213
+ ),
214
+ children: [
215
+ showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-4 inline-block w-8 select-none text-right text-xs text-muted-foreground", children: lineNumber }),
216
+ /* @__PURE__ */ jsxRuntime.jsx(
217
+ "div",
218
+ {
219
+ className: utils.cn(
220
+ "flex-1",
221
+ wrapLines ? "whitespace-pre-wrap break-words" : "overflow-x-auto"
222
+ ),
223
+ dangerouslySetInnerHTML: { __html: line }
224
+ }
225
+ )
226
+ ]
227
+ },
228
+ index
229
+ );
230
+ }) })
231
+ }
232
+ ),
233
+ expandable && !isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-background to-transparent pointer-events-none" }),
234
+ variant === "minimal" && showCopyButton && /* @__PURE__ */ jsxRuntime.jsx(
235
+ button.Button,
236
+ {
237
+ variant: "ghost",
238
+ size: "sm",
239
+ onClick: copyToClipboard,
240
+ className: "absolute top-2 right-2 h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
241
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" })
242
+ }
243
+ )
244
+ ]
245
+ }
246
+ ), "renderBlock");
247
+ if (variant === "inline") {
248
+ return renderInline();
249
+ }
250
+ return renderBlock();
251
+ }
252
+ );
253
+ CodeSnippet.displayName = "CodeSnippet";
254
+ var InlineCode = React__namespace.forwardRef(({ children, language, className, ...props }, ref) => {
255
+ return /* @__PURE__ */ jsxRuntime.jsx(
256
+ CodeSnippet,
257
+ {
258
+ ref,
259
+ code: children,
260
+ language,
261
+ variant: "inline",
262
+ showCopyButton: false,
263
+ showLanguageBadge: false,
264
+ showHeader: false,
265
+ className,
266
+ ...props
267
+ }
268
+ );
269
+ });
270
+ InlineCode.displayName = "InlineCode";
271
+
272
+ exports.CodeSnippet = CodeSnippet;
273
+ exports.InlineCode = InlineCode;
274
+ exports.codeSnippetVariants = codeSnippetVariants;