@codespark/react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1753 @@
1
+ import { registerFramework, registry } from "@codespark/framework";
2
+ import { react } from "@codespark/framework/react";
3
+ import { Braces, Check, ChevronRight, Copy, FileIcon, Folder, Maximize, RefreshCw, RemoveFormatting } from "lucide-react";
4
+ import * as React from "react";
5
+ import { Children, createContext, forwardRef, isValidElement, memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
6
+ import { debounce } from "lodash-es";
7
+ import { LoaderType } from "@codespark/framework/loaders";
8
+ import { isElement, isFragment } from "react-is";
9
+ import { clsx } from "clsx";
10
+ import { twMerge } from "tailwind-merge";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { cva } from "class-variance-authority";
13
+ import { Collapsible, Slot, Tabs, Tooltip } from "radix-ui";
14
+ import { javascript } from "@codemirror/lang-javascript";
15
+ import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
16
+ import { languages } from "@codemirror/language-data";
17
+ import ReactCodeMirror, { EditorView, Transaction } from "@uiw/react-codemirror";
18
+ import * as tailwindcss from "tailwindcss";
19
+
20
+ //#region src/lib/utils.ts
21
+ function cn(...inputs) {
22
+ return twMerge(clsx(inputs));
23
+ }
24
+ function constructESMUrl(config) {
25
+ const { pkg, version, deps, external, exports, standalone, bundle } = config;
26
+ const params = new URLSearchParams();
27
+ if (deps?.length) params.set("deps", deps.join(","));
28
+ if (external?.length) params.set("external", external.join(","));
29
+ if (exports?.length) params.set("exports", exports.join(","));
30
+ if (standalone) params.set("standalone", "");
31
+ if (bundle) params.set("bundle", "");
32
+ const isUrl = pkg.startsWith("http://") || pkg.startsWith("https://");
33
+ let base;
34
+ if (isUrl) base = pkg;
35
+ else {
36
+ const slashIndex = pkg.indexOf("/");
37
+ const pkgName = slashIndex > -1 ? pkg.slice(0, slashIndex) : pkg;
38
+ const subpath = slashIndex > -1 ? pkg.slice(slashIndex) : "";
39
+ base = version ? `https://esm.sh/${pkgName}@${version}${subpath}` : `https://esm.sh/${pkg}`;
40
+ }
41
+ const query = params.toString();
42
+ return query ? `${base}?${query}` : base;
43
+ }
44
+ function useCopyToClipboard(timeout = 2e3) {
45
+ const [isCopied, setIsCopied] = useState(false);
46
+ return {
47
+ copyToClipboard: useCallback(async (text) => {
48
+ await navigator.clipboard.writeText(text);
49
+ setIsCopied(true);
50
+ setTimeout(() => setIsCopied(false), timeout);
51
+ }, [timeout]),
52
+ isCopied
53
+ };
54
+ }
55
+ function useLatest(value) {
56
+ const ref = useRef(value);
57
+ ref.current = value;
58
+ return ref;
59
+ }
60
+ function getLanguageFromFile(name) {
61
+ const ext = name.split(".").pop()?.toLowerCase();
62
+ return ext ? {
63
+ ts: "typescript",
64
+ tsx: "typescript",
65
+ js: "javascript",
66
+ jsx: "javascript",
67
+ css: "css",
68
+ json: "json",
69
+ html: "html",
70
+ md: "markdown"
71
+ }[ext] : void 0;
72
+ }
73
+ function serializeAttributes(attrs) {
74
+ if (!attrs || Object.keys(attrs).length === 0) return "";
75
+ return Object.entries(attrs).map(([key, value]) => value === "" ? ` ${key}` : ` ${key}="${value}"`).join("");
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/lib/workspace/internals.ts
80
+ const INTERNAL_SUBSCRIBE = Symbol("subscribe");
81
+ const INTERNAL_REGISTER_EDITOR = Symbol("registerEditor");
82
+ const INTERNAL_UNREGISTER_EDITOR = Symbol("unregisterEditor");
83
+ const INTERNAL_BOUND = Symbol("bound");
84
+ const INTERNAL_SET_ID = Symbol("setId");
85
+ const INTERNAL_EMIT = Symbol("emit");
86
+ const NOOP_SUBSCRIBE = () => () => {};
87
+
88
+ //#endregion
89
+ //#region src/lib/workspace/opfs.ts
90
+ var OPFS = class {
91
+ dir = null;
92
+ async initOPFS(files) {
93
+ this.dir = await (await navigator.storage.getDirectory()).getDirectoryHandle(this.id, { create: true });
94
+ await Promise.all(Object.entries(files).map(([path, content]) => this.writeToOPFS(path, content)));
95
+ }
96
+ async writeToOPFS(path, content) {
97
+ const handle = await this.getFileHandle(path);
98
+ if (!handle) return;
99
+ const writable = await handle.createWritable();
100
+ await writable.write(content);
101
+ await writable.close();
102
+ }
103
+ async getFileHandle(path) {
104
+ if (!this.dir) return null;
105
+ const parts = path.split("/").filter(Boolean);
106
+ const fileName = parts.pop();
107
+ let current = this.dir;
108
+ for (const part of parts) current = await current.getDirectoryHandle(part, { create: true });
109
+ return current.getFileHandle(fileName, { create: true });
110
+ }
111
+ };
112
+
113
+ //#endregion
114
+ //#region src/lib/workspace/index.ts
115
+ /**
116
+ * Workspace - Core class for managing files, compilation, and editor state.
117
+ *
118
+ * Manages a virtual file system for code editing and live preview.
119
+ * Handles file CRUD operations, tracks the currently active file,
120
+ * and emits events for file changes and compilation results.
121
+ * Supports optional Origin Private File System (OPFS) for persistence.
122
+ */
123
+ var Workspace = class extends OPFS {
124
+ id;
125
+ initialFiles;
126
+ listeners = /* @__PURE__ */ new Set();
127
+ events = /* @__PURE__ */ new Map();
128
+ _currentFile = null;
129
+ _editors = /* @__PURE__ */ new Map();
130
+ _bound = false;
131
+ constructor(config) {
132
+ super();
133
+ this.config = config;
134
+ const { id, OPFS: OPFS$1 = false, files } = config;
135
+ this.id = id || "";
136
+ this.initialFiles = { ...files };
137
+ if (OPFS$1) super.initOPFS(this.files);
138
+ }
139
+ notifyListeners() {
140
+ this.listeners.forEach((fn) => fn());
141
+ }
142
+ createEntryFileNode(code) {
143
+ const name = this.entry.split("/").pop() || this.entry;
144
+ return {
145
+ name,
146
+ type: "file",
147
+ path: this.entry,
148
+ code: code ?? this.files[this.entry],
149
+ language: getLanguageFromFile(name)
150
+ };
151
+ }
152
+ normalizePath(path) {
153
+ return path.replace(/^\.\//, "");
154
+ }
155
+ getFile(path) {
156
+ const code = this.files[path];
157
+ if (code === void 0) return;
158
+ const name = path.split("/").pop() || path;
159
+ return {
160
+ name,
161
+ type: "file",
162
+ path,
163
+ code,
164
+ language: getLanguageFromFile(name)
165
+ };
166
+ }
167
+ get entry() {
168
+ return this.config.entry;
169
+ }
170
+ get files() {
171
+ return this.config.files;
172
+ }
173
+ get framework() {
174
+ return this.config.framework ?? "react";
175
+ }
176
+ get currentFile() {
177
+ if (!this._currentFile) this._currentFile = this.createEntryFileNode();
178
+ return this._currentFile;
179
+ }
180
+ get editors() {
181
+ return this._editors;
182
+ }
183
+ setFile(path, content) {
184
+ let newFiles = { ...this.config.files };
185
+ if (!path.endsWith("/")) {
186
+ const parts = path.split("/");
187
+ const parentFolders = /* @__PURE__ */ new Set();
188
+ for (let i = 1; i < parts.length; i++) parentFolders.add(parts.slice(0, i).join("/") + "/");
189
+ newFiles = Object.fromEntries(Object.entries(newFiles).filter(([key]) => !parentFolders.has(key)));
190
+ }
191
+ newFiles[path] = content;
192
+ this.config.files = newFiles;
193
+ if (!path.endsWith("/")) this.writeToOPFS(path, content);
194
+ if (this._currentFile && this._currentFile.path === path) this._currentFile = {
195
+ ...this._currentFile,
196
+ code: content
197
+ };
198
+ this.notifyListeners();
199
+ this.emit("fileChange", path, content);
200
+ }
201
+ setFiles(files) {
202
+ this.config.files = { ...files };
203
+ this.initialFiles = { ...files };
204
+ if (this._currentFile) {
205
+ const newCode = files[this._currentFile.path];
206
+ if (newCode !== void 0) this._currentFile = {
207
+ ...this._currentFile,
208
+ code: newCode
209
+ };
210
+ else this._currentFile = this.createEntryFileNode(files[this.entry]);
211
+ }
212
+ this.notifyListeners();
213
+ this.emit("filesChange", files);
214
+ }
215
+ renameFile(oldPath, newName) {
216
+ const isFolder = !(oldPath in this.files);
217
+ const parentPath = oldPath.split("/").slice(0, -1).join("/");
218
+ const newPath = parentPath ? `${parentPath}/${newName}` : newName;
219
+ if (isFolder) {
220
+ const newFiles = {};
221
+ for (const [path, content] of Object.entries(this.files)) {
222
+ const normalizedPath = this.normalizePath(path);
223
+ if (normalizedPath === oldPath || normalizedPath.startsWith(oldPath + "/")) {
224
+ const newFilePath = path.replace(oldPath, newPath);
225
+ newFiles[newFilePath] = content;
226
+ } else newFiles[path] = content;
227
+ }
228
+ this.config.files = newFiles;
229
+ } else {
230
+ const content = this.files[oldPath];
231
+ const { [oldPath]: _, ...rest } = this.files;
232
+ this.config.files = {
233
+ ...rest,
234
+ [newPath]: content
235
+ };
236
+ this.writeToOPFS(newPath, content);
237
+ }
238
+ if (this._currentFile?.path === oldPath || this._currentFile?.path.startsWith(oldPath + "/")) {
239
+ const newCurrentPath = isFolder ? newPath + this._currentFile.path.slice(oldPath.length) : newPath;
240
+ this._currentFile = {
241
+ ...this._currentFile,
242
+ path: newCurrentPath,
243
+ name: newCurrentPath.split("/").pop()
244
+ };
245
+ }
246
+ this.notifyListeners();
247
+ this.emit("fileRename", oldPath, newPath);
248
+ }
249
+ deleteFile(path) {
250
+ const isEmptyFolder = path.endsWith("/");
251
+ const normalizedPath = isEmptyFolder ? path.slice(0, -1) : path;
252
+ const isFolder = isEmptyFolder || !(path in this.files);
253
+ let newFiles;
254
+ if (isFolder) newFiles = Object.fromEntries(Object.entries(this.files).filter(([filePath]) => {
255
+ const normalized = this.normalizePath(filePath);
256
+ return normalized !== path && normalized !== normalizedPath + "/" && !normalized.startsWith(normalizedPath + "/");
257
+ }));
258
+ else {
259
+ const { [path]: _, ...rest } = this.files;
260
+ newFiles = rest;
261
+ }
262
+ const parentPath = normalizedPath.split("/").slice(0, -1).join("/");
263
+ if (parentPath) {
264
+ if (!Object.keys(newFiles).some((f) => {
265
+ const normalized = this.normalizePath(f).replace(/\/$/, "");
266
+ return normalized.startsWith(parentPath + "/") && normalized !== parentPath;
267
+ })) newFiles[parentPath + "/"] = "";
268
+ }
269
+ this.config.files = newFiles;
270
+ if (this._currentFile?.path === path || this._currentFile?.path.startsWith(normalizedPath + "/")) this._currentFile = this.createEntryFileNode();
271
+ this.notifyListeners();
272
+ this.emit("fileDelete", path);
273
+ }
274
+ setCurrentFile(path) {
275
+ const file = this.getFile(path);
276
+ if (file) {
277
+ this._currentFile = file;
278
+ this.notifyListeners();
279
+ this.emit("currentFileChange", file);
280
+ }
281
+ }
282
+ on(event, callback) {
283
+ if (!this.events.has(event)) this.events.set(event, /* @__PURE__ */ new Set());
284
+ this.events.get(event).add(callback);
285
+ return () => this.off(event, callback);
286
+ }
287
+ off(event, callback) {
288
+ this.events.get(event)?.delete(callback);
289
+ }
290
+ emit(event, ...args) {
291
+ this.events.get(event)?.forEach((cb) => cb(...args));
292
+ }
293
+ [INTERNAL_SUBSCRIBE](listener) {
294
+ this.listeners.add(listener);
295
+ return () => this.listeners.delete(listener);
296
+ }
297
+ [INTERNAL_REGISTER_EDITOR](id, editor) {
298
+ this._editors.set(id, editor);
299
+ }
300
+ [INTERNAL_UNREGISTER_EDITOR](id) {
301
+ this._editors.delete(id);
302
+ }
303
+ [INTERNAL_BOUND]() {
304
+ if (this._bound) return true;
305
+ this._bound = true;
306
+ return false;
307
+ }
308
+ [INTERNAL_SET_ID](id) {
309
+ this.id = id;
310
+ }
311
+ [INTERNAL_EMIT](event, ...args) {
312
+ this.emit(event, ...args);
313
+ }
314
+ };
315
+ /**
316
+ * Hook to manage workspace state and compilation.
317
+ * Provides reactive access to files, compilation results, and workspace methods.
318
+ *
319
+ * @param init - WorkspaceInit config object or existing Workspace instance
320
+ * @returns Workspace state including files, compiled code, and the workspace instance
321
+ */
322
+ function useWorkspace(init) {
323
+ const uid$1 = useId();
324
+ const context = useCodespark();
325
+ const workspace = useMemo(() => {
326
+ let ws;
327
+ if (init instanceof Workspace) ws = init;
328
+ else if (init) ws = new Workspace(init);
329
+ else ws = context?.workspace;
330
+ if (!ws?.id) ws?.[INTERNAL_SET_ID](`workspace${uid$1}`);
331
+ return ws;
332
+ }, []);
333
+ if (!workspace) throw Error("Can not find any workspace instance. Make sure provide a workspace during runtime.");
334
+ const framework = useMemo(() => {
335
+ const fwInput = workspace.framework;
336
+ if (typeof fwInput === "string") return registry.get(fwInput);
337
+ if (typeof fwInput === "function") return new fwInput();
338
+ return fwInput;
339
+ }, []);
340
+ if (!framework) throw new Error(`Framework not found: ${workspace.framework}`);
341
+ const standalone = context ? false : !workspace[INTERNAL_BOUND]();
342
+ const subscribe = useMemo(() => standalone ? (cb) => workspace[INTERNAL_SUBSCRIBE](cb) : NOOP_SUBSCRIBE, []);
343
+ const files = useSyncExternalStore(subscribe, () => workspace.files, () => workspace.files);
344
+ const currentFile = useSyncExternalStore(subscribe, () => workspace.currentFile, () => workspace.currentFile);
345
+ const derivedState = useMemo(() => {
346
+ if (context) {
347
+ const { fileTree: fileTree$1, vendor, compiled, compileError } = context;
348
+ return {
349
+ fileTree: fileTree$1,
350
+ vendor,
351
+ compiled,
352
+ compileError
353
+ };
354
+ }
355
+ const fileTree = (() => {
356
+ const root = [];
357
+ const entries = Object.entries(files);
358
+ const entryItem = entries.find(([path]) => path === workspace.entry);
359
+ const rest = entries.filter(([path]) => path !== workspace.entry);
360
+ const sorted = entryItem ? [entryItem, ...rest] : rest;
361
+ for (const [filePath, code] of sorted) {
362
+ if (filePath.startsWith("../")) continue;
363
+ const isEmptyFolder = filePath.endsWith("/");
364
+ const parts = (isEmptyFolder ? filePath.slice(0, -1) : filePath).split("/").filter((p) => p !== "." && p !== "..");
365
+ let current = root;
366
+ let currentPath = "";
367
+ for (let i = 0; i < parts.length; i++) {
368
+ const name = parts[i];
369
+ const isLast = i === parts.length - 1;
370
+ currentPath = currentPath ? `${currentPath}/${name}` : name;
371
+ if (isLast && !isEmptyFolder) current.push({
372
+ name,
373
+ type: "file",
374
+ path: filePath,
375
+ code,
376
+ language: getLanguageFromFile(name)
377
+ });
378
+ else {
379
+ let folder = current.find((n) => n.type === "folder" && n.name === name);
380
+ if (!folder) {
381
+ folder = {
382
+ name,
383
+ type: "folder",
384
+ path: currentPath,
385
+ children: []
386
+ };
387
+ current.push(folder);
388
+ }
389
+ current = folder.children;
390
+ }
391
+ }
392
+ }
393
+ return root;
394
+ })();
395
+ try {
396
+ framework.analyze(workspace.entry, files);
397
+ const compiled = framework.compile();
398
+ workspace[INTERNAL_EMIT]("compiled", compiled);
399
+ const modules = framework.getOutput(LoaderType.ESModule);
400
+ return {
401
+ fileTree,
402
+ compiled,
403
+ compileError: null,
404
+ vendor: {
405
+ modules,
406
+ styles: framework.getOutput(LoaderType.Style),
407
+ scripts: framework.getOutput(LoaderType.Script),
408
+ imports: {
409
+ ...modules.map(({ externals }) => externals).flat().reduce((pre, { name, imported }) => {
410
+ return {
411
+ ...pre,
412
+ [name]: constructESMUrl({
413
+ pkg: name,
414
+ version: "",
415
+ external: Object.keys(framework.imports),
416
+ exports: imported.length ? imported : void 0
417
+ })
418
+ };
419
+ }, {}),
420
+ ...framework.imports
421
+ }
422
+ }
423
+ };
424
+ } catch (error) {
425
+ workspace[INTERNAL_EMIT]("compileError", error);
426
+ return {
427
+ fileTree,
428
+ compiled: "",
429
+ compileError: error,
430
+ vendor: {
431
+ modules: [],
432
+ styles: [],
433
+ scripts: [],
434
+ imports: {}
435
+ }
436
+ };
437
+ }
438
+ }, [files]);
439
+ return {
440
+ files: context?.files ?? files,
441
+ currentFile: context?.currentFile ?? currentFile,
442
+ ...derivedState,
443
+ workspace
444
+ };
445
+ }
446
+ /**
447
+ * Creates a Workspace instance from a React component or element.
448
+ * Typically used with the rollup plugin to create workspaces from components.
449
+ *
450
+ * @param this - Context containing scanned code information (injected by rollup plugin)
451
+ * @param source - React component or element to create workspace from
452
+ * @param config - Configuration options
453
+ * @returns A new Workspace instance
454
+ *
455
+ * @example
456
+ * ```tsx
457
+ * // Used with rollup plugin
458
+ * const workspace = createWorkspace(MyComponent, {
459
+ * name: './App.tsx',
460
+ * mode: 'packed'
461
+ * });
462
+ * ```
463
+ */
464
+ function createWorkspace(source, config) {
465
+ const { id, framework, name = "./App.tsx", mode = "packed" } = config || {};
466
+ if (!this?.__scanned) return new Workspace({
467
+ id,
468
+ entry: name,
469
+ files: { [name]: source.toString() }
470
+ });
471
+ const { entry, files } = this.__scanned;
472
+ let packedCode;
473
+ if (mode === "raw") packedCode = entry.code;
474
+ else if (mode === "source") {
475
+ packedCode = Object.values(files)[0] || "";
476
+ return new Workspace({
477
+ id,
478
+ framework,
479
+ entry: name,
480
+ files: { [name]: packedCode }
481
+ });
482
+ } else {
483
+ const { code, locals, imports } = entry;
484
+ packedCode = [
485
+ imports.join("\n"),
486
+ locals.join("\n"),
487
+ isElement(source) || isFragment(source) ? `export default function App() {\n return ${code}\n};` : `export default ${code};`
488
+ ].filter(Boolean).join("\n\n");
489
+ }
490
+ return new Workspace({
491
+ id,
492
+ framework,
493
+ entry: name,
494
+ files: {
495
+ [name]: packedCode,
496
+ ...files
497
+ }
498
+ });
499
+ }
500
+
501
+ //#endregion
502
+ //#region src/context/index.tsx
503
+ const ConfigContext = createContext({ theme: "light" });
504
+ const CodesparkContext = createContext(null);
505
+ const useConfig = () => useContext(ConfigContext);
506
+ const useCodespark = () => useContext(CodesparkContext);
507
+ function ConfigProvider(props) {
508
+ const { children, ...config } = props;
509
+ return /* @__PURE__ */ jsx(ConfigContext.Provider, {
510
+ value: config,
511
+ children
512
+ });
513
+ }
514
+ /**
515
+ * CodesparkProvider - A context provider that shares workspace state and configuration.
516
+ *
517
+ * Provides workspace instance, theme, framework type, and import maps to child components.
518
+ * Required when using CodesparkEditor, CodesparkPreview, or CodesparkFileExplorer independently.
519
+ * Automatically manages workspace state synchronization across all child components.
520
+ */
521
+ function CodesparkProvider(props) {
522
+ const { children, theme, framework = "react", imports, editor, workspace = new Workspace({
523
+ entry: "./App.tsx",
524
+ files: { "./App.tsx": "" },
525
+ framework
526
+ }) } = props;
527
+ const store = useWorkspace(workspace);
528
+ return /* @__PURE__ */ jsx(CodesparkContext.Provider, {
529
+ value: {
530
+ framework,
531
+ imports,
532
+ theme,
533
+ editor,
534
+ ...store
535
+ },
536
+ children
537
+ });
538
+ }
539
+
540
+ //#endregion
541
+ //#region src/lib/editor-adapter/index.ts
542
+ let EditorEngine = /* @__PURE__ */ function(EditorEngine$1) {
543
+ EditorEngine$1[EditorEngine$1["Monaco"] = 0] = "Monaco";
544
+ EditorEngine$1[EditorEngine$1["CodeMirror"] = 1] = "CodeMirror";
545
+ return EditorEngine$1;
546
+ }({});
547
+
548
+ //#endregion
549
+ //#region src/ui/button.tsx
550
+ const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
551
+ variants: {
552
+ variant: {
553
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
554
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
555
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
556
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
557
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
558
+ link: "text-primary underline-offset-4 hover:underline"
559
+ },
560
+ size: {
561
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
562
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
563
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
564
+ icon: "size-9",
565
+ "icon-sm": "size-8",
566
+ "icon-lg": "size-10"
567
+ }
568
+ },
569
+ defaultVariants: {
570
+ variant: "default",
571
+ size: "default"
572
+ }
573
+ });
574
+ const Button = React.forwardRef(function Button$1({ className, variant = "default", size = "default", asChild = false, ...props }, ref) {
575
+ return /* @__PURE__ */ jsx(asChild ? Slot.Root : "button", {
576
+ "data-slot": "button",
577
+ "data-variant": variant,
578
+ "data-size": size,
579
+ className: cn(buttonVariants({
580
+ variant,
581
+ size,
582
+ className
583
+ })),
584
+ ref,
585
+ ...props
586
+ });
587
+ });
588
+
589
+ //#endregion
590
+ //#region src/ui/icons.tsx
591
+ const Icons = {
592
+ json: (props) => /* @__PURE__ */ jsx("svg", {
593
+ xmlns: "http://www.w3.org/2000/svg",
594
+ viewBox: "0 0 24 24",
595
+ ...props,
596
+ children: /* @__PURE__ */ jsx("path", {
597
+ fill: "currentColor",
598
+ d: "M12.043 23.968c.479-.004.953-.029 1.426-.094a11.805 11.805 0 0 0 3.146-.863 12.404 12.404 0 0 0 3.793-2.542 11.977 11.977 0 0 0 2.44-3.427 11.794 11.794 0 0 0 1.02-3.476c.149-1.16.135-2.346-.045-3.499a11.96 11.96 0 0 0-.793-2.788 11.197 11.197 0 0 0-.854-1.617c-1.168-1.837-2.861-3.314-4.81-4.3a12.835 12.835 0 0 0-2.172-.87h-.005c.119.063.24.132.345.201.12.074.239.146.351.225a8.93 8.93 0 0 1 1.559 1.33c1.063 1.145 1.797 2.548 2.218 4.041.284.982.434 1.998.495 3.017.044.743.044 1.491-.047 2.229-.149 1.27-.554 2.51-1.228 3.596a7.475 7.475 0 0 1-1.903 2.084c-1.244.928-2.877 1.482-4.436 1.114a3.916 3.916 0 0 1-.748-.258 4.692 4.692 0 0 1-.779-.45 6.08 6.08 0 0 1-1.244-1.105 6.507 6.507 0 0 1-1.049-1.747 7.366 7.366 0 0 1-.494-2.54c-.03-1.273.225-2.553.854-3.67a6.43 6.43 0 0 1 1.663-1.918c.225-.178.464-.333.704-.479l.016-.007a5.121 5.121 0 0 0-1.441-.12 4.963 4.963 0 0 0-1.228.24c-.359.12-.704.27-1.019.45a6.146 6.146 0 0 0-.733.494c-.211.18-.42.36-.615.555-1.123 1.153-1.768 2.682-2.022 4.256-.15.973-.15 1.96-.091 2.95.105 1.395.391 2.787.945 4.062a8.518 8.518 0 0 0 1.348 2.173 8.14 8.14 0 0 0 3.132 2.23 7.934 7.934 0 0 0 2.113.54c.074.015.149.015.209.015zm-2.934-.398a4.102 4.102 0 0 1-.45-.228 8.5 8.5 0 0 1-2.038-1.534c-1.094-1.137-1.827-2.566-2.247-4.08a15.184 15.184 0 0 1-.495-3.172 12.14 12.14 0 0 1 .046-2.082c.135-1.257.495-2.501 1.124-3.58a6.889 6.889 0 0 1 1.783-2.053 6.23 6.23 0 0 1 1.633-.9 5.363 5.363 0 0 1 3.522-.045c.029 0 .029 0 .045.03.015.015.045.015.06.03.045.016.104.045.165.074.239.12.479.271.704.42a6.294 6.294 0 0 1 2.097 2.502c.42.914.615 1.934.631 2.938.014 1.079-.18 2.157-.645 3.146a6.42 6.42 0 0 1-2.638 2.832c.09.03.18.045.271.075.225.044.449.074.688.074 1.468.045 2.892-.66 3.94-1.647.195-.18.375-.375.54-.585.225-.27.435-.54.614-.823.239-.375.435-.75.614-1.154a8.112 8.112 0 0 0 .509-1.664c.196-1.004.211-2.022.149-3.026-.135-2.022-.673-4.045-1.842-5.724a9.054 9.054 0 0 0-.555-.719 9.868 9.868 0 0 0-1.063-1.034 8.477 8.477 0 0 0-1.363-.915 9.927 9.927 0 0 0-1.692-.598l-.3-.06c-.209-.03-.42-.044-.634-.06a8.453 8.453 0 0 0-1.015.016c-.704.045-1.412.16-2.112.337C5.799 1.227 2.863 3.566 1.3 6.67A11.834 11.834 0 0 0 .238 9.801a11.81 11.81 0 0 0-.104 3.775c.12 1.02.374 2.023.778 2.977.227.57.511 1.124.825 1.648 1.094 1.783 2.683 3.236 4.51 4.24.688.39 1.408.69 2.157.944.226.074.45.15.689.21z"
599
+ })
600
+ }),
601
+ ts: (props) => /* @__PURE__ */ jsx("svg", {
602
+ xmlns: "http://www.w3.org/2000/svg",
603
+ viewBox: "0 0 24 24",
604
+ ...props,
605
+ children: /* @__PURE__ */ jsx("path", { d: "M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z" })
606
+ }),
607
+ css: (props) => /* @__PURE__ */ jsx("svg", {
608
+ xmlns: "http://www.w3.org/2000/svg",
609
+ viewBox: "0 0 24 24",
610
+ ...props,
611
+ children: /* @__PURE__ */ jsx("path", { d: "M0 0v20.16A3.84 3.84 0 0 0 3.84 24h16.32A3.84 3.84 0 0 0 24 20.16V3.84A3.84 3.84 0 0 0 20.16 0Zm14.256 13.08c1.56 0 2.28 1.08 2.304 2.64h-1.608c.024-.288-.048-.6-.144-.84-.096-.192-.288-.264-.552-.264-.456 0-.696.264-.696.84-.024.576.288.888.768 1.08.72.288 1.608.744 1.92 1.296q.432.648.432 1.656c0 1.608-.912 2.592-2.496 2.592-1.656 0-2.4-1.032-2.424-2.688h1.68c0 .792.264 1.176.792 1.176.264 0 .456-.072.552-.24.192-.312.24-1.176-.048-1.512-.312-.408-.912-.6-1.32-.816q-.828-.396-1.224-.936c-.24-.36-.36-.888-.36-1.536 0-1.44.936-2.472 2.424-2.448m5.4 0c1.584 0 2.304 1.08 2.328 2.64h-1.608c0-.288-.048-.6-.168-.84-.096-.192-.264-.264-.528-.264-.48 0-.72.264-.72.84s.288.888.792 1.08c.696.288 1.608.744 1.92 1.296.264.432.408.984.408 1.656.024 1.608-.888 2.592-2.472 2.592-1.68 0-2.424-1.056-2.448-2.688h1.68c0 .744.264 1.176.792 1.176.264 0 .456-.072.552-.24.216-.312.264-1.176-.048-1.512-.288-.408-.888-.6-1.32-.816-.552-.264-.96-.576-1.2-.936s-.36-.888-.36-1.536c-.024-1.44.912-2.472 2.4-2.448m-11.031.018c.711-.006 1.419.198 1.839.63.432.432.672 1.128.648 1.992H9.336c.024-.456-.096-.792-.432-.96-.312-.144-.768-.048-.888.24-.12.264-.192.576-.168.864v3.504c0 .744.264 1.128.768 1.128a.65.65 0 0 0 .552-.264c.168-.24.192-.552.168-.84h1.776c.096 1.632-.984 2.712-2.568 2.688-1.536 0-2.496-.864-2.472-2.472v-4.032c0-.816.24-1.44.696-1.848.432-.408 1.146-.624 1.857-.63" })
612
+ })
613
+ };
614
+ function getIconForLanguageExtension(language) {
615
+ switch (language) {
616
+ case "json": return /* @__PURE__ */ jsx(Icons.json, {});
617
+ case "css": return /* @__PURE__ */ jsx(Icons.css, { className: "fill-foreground" });
618
+ case "js":
619
+ case "jsx":
620
+ case "ts":
621
+ case "tsx":
622
+ case "typescript": return /* @__PURE__ */ jsx(Icons.ts, { className: "fill-foreground" });
623
+ default: return /* @__PURE__ */ jsx(FileIcon, {});
624
+ }
625
+ }
626
+
627
+ //#endregion
628
+ //#region src/ui/tooltip.tsx
629
+ function TooltipProvider({ delayDuration = 0, ...props }) {
630
+ return /* @__PURE__ */ jsx(Tooltip.Provider, {
631
+ "data-slot": "tooltip-provider",
632
+ delayDuration,
633
+ ...props
634
+ });
635
+ }
636
+ function Tooltip$1({ ...props }) {
637
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(Tooltip.Root, {
638
+ "data-slot": "tooltip",
639
+ ...props
640
+ }) });
641
+ }
642
+ function TooltipTrigger({ ...props }) {
643
+ return /* @__PURE__ */ jsx(Tooltip.Trigger, {
644
+ "data-slot": "tooltip-trigger",
645
+ ...props
646
+ });
647
+ }
648
+ function TooltipContent({ className, sideOffset = 0, children, ...props }) {
649
+ return /* @__PURE__ */ jsx(Tooltip.Portal, { children: /* @__PURE__ */ jsxs(Tooltip.Content, {
650
+ "data-slot": "tooltip-content",
651
+ sideOffset,
652
+ className: cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className),
653
+ ...props,
654
+ children: [children, /* @__PURE__ */ jsx(Tooltip.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" })]
655
+ }) });
656
+ }
657
+
658
+ //#endregion
659
+ //#region src/ui/skeleton.tsx
660
+ function Skeleton({ className, ...props }) {
661
+ return /* @__PURE__ */ jsx("div", {
662
+ "data-slot": "skeleton",
663
+ className: cn("bg-accent animate-pulse rounded-md", className),
664
+ ...props
665
+ });
666
+ }
667
+
668
+ //#endregion
669
+ //#region src/components/editor/codemirror/adapter.ts
670
+ var CodeMirrorEditorAdapter = class {
671
+ constructor(kind, instance) {
672
+ this.kind = kind;
673
+ this.instance = instance;
674
+ }
675
+ getValue() {
676
+ return this.instance.view?.state.doc.toString() ?? "";
677
+ }
678
+ setValue(value, addToHistory = false) {
679
+ const view = this.instance.view;
680
+ if (!view) return;
681
+ view.dispatch({
682
+ changes: {
683
+ from: 0,
684
+ to: view.state.doc.length,
685
+ insert: value
686
+ },
687
+ annotations: addToHistory ? void 0 : Transaction.addToHistory.of(false)
688
+ });
689
+ }
690
+ async format() {}
691
+ };
692
+
693
+ //#endregion
694
+ //#region src/components/editor/codemirror/index.tsx
695
+ const THEME = EditorView.theme({
696
+ "&": { fontSize: "14px" },
697
+ "&.cm-focused": { outline: "none" },
698
+ "&.cm-editor": { backgroundColor: "var(--background)" },
699
+ ".cm-gutters.cm-gutters": {
700
+ backgroundColor: "var(--background)",
701
+ border: "none"
702
+ },
703
+ ".cm-gutter": {
704
+ padding: "1px 4px 0px 12px",
705
+ minWidth: "36px"
706
+ },
707
+ ".cm-scroller": {
708
+ paddingTop: "8px",
709
+ fontFamily: "Fira Code"
710
+ },
711
+ ".cm-line": {
712
+ padding: "0 12px",
713
+ height: "24px",
714
+ lineHeight: "24px"
715
+ },
716
+ ".cm-gutterElement.cm-gutterElement": {
717
+ padding: "0px",
718
+ lineHeight: "24px"
719
+ },
720
+ ".cm-activeLine": { borderRadius: "4px" }
721
+ });
722
+ const LANGUAGE_EXTENSIONS = {
723
+ javascript: javascript({ jsx: true }),
724
+ markdown: markdown({
725
+ base: markdownLanguage,
726
+ codeLanguages: languages
727
+ })
728
+ };
729
+ const CodeMirror = {
730
+ kind: EditorEngine.CodeMirror,
731
+ Component: memo(function CodeMirror$1(props) {
732
+ const { id, basicSetup, extensions = [], width, height, fontFamily, lang, onMount, ...rest } = props;
733
+ const [mounted, setMounted] = useState(false);
734
+ const editorRef = useRef(null);
735
+ const allExtensions = useMemo(() => {
736
+ const exts = [THEME, ...extensions];
737
+ if (lang && LANGUAGE_EXTENSIONS[lang]) exts.unshift(LANGUAGE_EXTENSIONS[lang]);
738
+ else exts.unshift(LANGUAGE_EXTENSIONS.javascript);
739
+ if (fontFamily) exts.push(EditorView.theme({ "& .cm-scroller": { fontFamily } }));
740
+ return exts;
741
+ }, [extensions, fontFamily]);
742
+ useEffect(() => {
743
+ setMounted(true);
744
+ }, []);
745
+ useEffect(() => {
746
+ if (editorRef.current) onMount?.(editorRef.current);
747
+ }, [mounted]);
748
+ return /* @__PURE__ */ jsx("div", {
749
+ id,
750
+ style: { height },
751
+ children: !mounted ? /* @__PURE__ */ jsxs("div", {
752
+ className: "flex flex-col space-y-3 p-5",
753
+ style: { height },
754
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "w-full flex-1 rounded-xl" }), /* @__PURE__ */ jsxs("div", {
755
+ className: "space-y-3",
756
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-[80%]" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-[65%]" })]
757
+ })]
758
+ }) : /* @__PURE__ */ jsx(ReactCodeMirror, {
759
+ ref: editorRef,
760
+ width: width ?? "100%",
761
+ height,
762
+ basicSetup: typeof basicSetup === "boolean" ? basicSetup : {
763
+ lineNumbers: true,
764
+ foldGutter: false,
765
+ highlightActiveLine: false,
766
+ highlightActiveLineGutter: false,
767
+ ...basicSetup
768
+ },
769
+ extensions: allExtensions,
770
+ lang,
771
+ ...rest
772
+ })
773
+ });
774
+ }),
775
+ createAdapter: (instance) => {
776
+ return new CodeMirrorEditorAdapter(EditorEngine.CodeMirror, instance);
777
+ }
778
+ };
779
+
780
+ //#endregion
781
+ //#region src/components/editor/index.tsx
782
+ function propsTypeGuard(props, editor, kind) {
783
+ if ("editor" in props && props.editor?.kind === kind) return true;
784
+ return editor.kind === kind;
785
+ }
786
+ function CodesparkEditor(props) {
787
+ const { theme: globalTheme, editor: globalEditor, fontFamily: globalFontFamily } = useConfig();
788
+ const { workspace: contextWorkspace, theme: contextTheme } = useCodespark() || {};
789
+ const { id, value = "", theme = contextTheme ?? globalTheme ?? "light", editor = globalEditor ?? CodeMirror, className, toolbox = true, containerProps, debounceWait = 500 } = props;
790
+ const { files, currentFile, vendor, workspace } = useWorkspace(props.workspace ?? contextWorkspace ?? new Workspace({
791
+ entry: "./App.tsx",
792
+ files: { "./App.tsx": value }
793
+ }));
794
+ const uid$1 = useId();
795
+ const editorId = id ?? `editor${uid$1}`;
796
+ const editorRef = useRef(null);
797
+ const currentFileRef = useLatest(currentFile);
798
+ const { copyToClipboard, isCopied } = useCopyToClipboard();
799
+ const toolboxItems = {
800
+ reset: {
801
+ tooltip: "Reset Document",
802
+ icon: /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5!" }),
803
+ onClick: () => {
804
+ const { path } = currentFile;
805
+ const initialCode = workspace.initialFiles[path] ?? "";
806
+ editorRef.current?.setValue(initialCode);
807
+ workspace.setFile(path, initialCode);
808
+ }
809
+ },
810
+ format: {
811
+ tooltip: "Format Document",
812
+ icon: /* @__PURE__ */ jsx(RemoveFormatting, { className: "size-3.5!" }),
813
+ onClick: () => {
814
+ editorRef.current?.format();
815
+ }
816
+ },
817
+ copy: {
818
+ tooltip: isCopied ? "Copied" : "Copy to Clipboard",
819
+ icon: isCopied ? /* @__PURE__ */ jsx(Check, { className: "size-3.5!" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5!" }),
820
+ onClick: () => {
821
+ copyToClipboard(editorRef.current?.getValue() || "");
822
+ }
823
+ }
824
+ };
825
+ const handleEditorChange = useCallback(debounce((newValue) => {
826
+ const { code, path } = currentFileRef.current;
827
+ if (newValue === code) return;
828
+ workspace.setFile(path, newValue || "");
829
+ }, debounceWait, {
830
+ leading: true,
831
+ trailing: true
832
+ }), [debounceWait]);
833
+ const handleEditorMount = useCallback((adapter) => {
834
+ editorRef.current = adapter;
835
+ workspace[INTERNAL_REGISTER_EDITOR](editorId, adapter);
836
+ }, []);
837
+ const renderEditor = () => {
838
+ const id$1 = `${workspace.id}${editorId}`;
839
+ if (editor.kind === EditorEngine.Monaco && propsTypeGuard(props, editor, EditorEngine.Monaco)) {
840
+ const { height, width, wrapperProps, options, onChange, onMount } = props;
841
+ const { fontFamily = globalFontFamily } = options || {};
842
+ return /* @__PURE__ */ jsx(editor.Component, {
843
+ id: id$1,
844
+ value: value || currentFile.code,
845
+ path: `file:///${id$1}/${currentFile.path.replace(/^(\.\.?\/)+/, "")}`,
846
+ theme: theme === "light" ? "vitesse-light" : "vitesse-dark",
847
+ files,
848
+ imports: vendor.imports,
849
+ className,
850
+ height: height ?? 200,
851
+ width,
852
+ wrapperProps,
853
+ language: currentFile.language,
854
+ options: {
855
+ padding: {
856
+ top: 12,
857
+ bottom: 12
858
+ },
859
+ lineDecorationsWidth: 12,
860
+ ...options,
861
+ fontFamily
862
+ },
863
+ onChange: (newValue, evt) => {
864
+ onChange?.(newValue, evt);
865
+ handleEditorChange(newValue);
866
+ },
867
+ onMount: (editorInstance, monacoInstance) => {
868
+ onMount?.(editorInstance, monacoInstance);
869
+ handleEditorMount(editor.createAdapter(editorInstance));
870
+ }
871
+ });
872
+ }
873
+ if (editor.kind === EditorEngine.CodeMirror && propsTypeGuard(props, editor, EditorEngine.CodeMirror)) {
874
+ const { height, width, basicSetup, fontFamily, readOnly, onChange, onMount } = props;
875
+ return /* @__PURE__ */ jsx(editor.Component, {
876
+ id: id$1,
877
+ className,
878
+ value: value || currentFile.code,
879
+ height: height ?? "200px",
880
+ width,
881
+ theme,
882
+ basicSetup,
883
+ readOnly,
884
+ fontFamily: fontFamily ?? globalFontFamily,
885
+ lang: currentFile.language,
886
+ onChange: (newValue, viewUpdate) => {
887
+ onChange?.(newValue, viewUpdate);
888
+ handleEditorChange(newValue);
889
+ },
890
+ onMount: (editorInstance) => {
891
+ onMount?.(editorInstance);
892
+ handleEditorMount(editor.createAdapter(editorInstance));
893
+ }
894
+ });
895
+ }
896
+ return null;
897
+ };
898
+ useEffect(() => {
899
+ const editorValue = editorRef.current?.getValue();
900
+ if (editorValue && editorValue !== currentFile.code) editorRef.current?.setValue(currentFile.code ?? "");
901
+ }, [currentFile.code]);
902
+ useEffect(() => {
903
+ if (!value) return;
904
+ workspace.setFile(workspace.entry, value);
905
+ }, [value]);
906
+ useEffect(() => {
907
+ return () => {
908
+ workspace[INTERNAL_UNREGISTER_EDITOR](editorId);
909
+ };
910
+ }, []);
911
+ return /* @__PURE__ */ jsxs("div", {
912
+ ...containerProps,
913
+ className: cn("h-full divide-y", containerProps?.className),
914
+ children: [toolbox ? /* @__PURE__ */ jsxs("div", {
915
+ className: "border-border flex items-center justify-between p-2",
916
+ children: [/* @__PURE__ */ jsxs("div", {
917
+ className: "[&_svg]:text-code-foreground flex items-center gap-x-2 px-2 [&_svg]:size-4 [&_svg]:opacity-70",
918
+ children: [getIconForLanguageExtension("typescript"), /* @__PURE__ */ jsx("span", {
919
+ className: "text-card-foreground",
920
+ children: currentFile.path.replace(/^(\.\.?\/)+/, "")
921
+ })]
922
+ }), isValidElement(toolbox) ? toolbox : /* @__PURE__ */ jsx("div", {
923
+ className: "flex items-center",
924
+ children: (Array.isArray(toolbox) ? toolbox : [
925
+ "reset",
926
+ "format",
927
+ "copy"
928
+ ]).map((t, index) => {
929
+ if (isValidElement(t)) return t;
930
+ const item = typeof t === "string" ? toolboxItems[t] : t;
931
+ if (!item) return null;
932
+ const { tooltip, icon, asChild = true, onClick, render } = item;
933
+ function renderTriggerContent() {
934
+ if (icon) return /* @__PURE__ */ jsx(Button, {
935
+ variant: "ghost",
936
+ size: "icon-sm",
937
+ onClick: () => onClick?.(editorRef.current),
938
+ children: icon
939
+ });
940
+ if (render) return render(editorRef.current);
941
+ return null;
942
+ }
943
+ return /* @__PURE__ */ jsxs(Tooltip$1, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
944
+ asChild,
945
+ children: renderTriggerContent()
946
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })] }, index);
947
+ })
948
+ })]
949
+ }) : null, renderEditor()]
950
+ });
951
+ }
952
+
953
+ //#endregion
954
+ //#region src/ui/collapsible.tsx
955
+ function Collapsible$1({ ...props }) {
956
+ return /* @__PURE__ */ jsx(Collapsible.Root, {
957
+ "data-slot": "collapsible",
958
+ ...props
959
+ });
960
+ }
961
+ function CollapsibleTrigger({ ...props }) {
962
+ return /* @__PURE__ */ jsx(Collapsible.CollapsibleTrigger, {
963
+ "data-slot": "collapsible-trigger",
964
+ ...props
965
+ });
966
+ }
967
+ function CollapsibleContent({ ...props }) {
968
+ return /* @__PURE__ */ jsx(Collapsible.CollapsibleContent, {
969
+ "data-slot": "collapsible-content",
970
+ ...props
971
+ });
972
+ }
973
+
974
+ //#endregion
975
+ //#region src/ui/tabs.tsx
976
+ function Tabs$1({ className, ...props }) {
977
+ return /* @__PURE__ */ jsx(Tabs.Root, {
978
+ "data-slot": "tabs",
979
+ className: cn("flex flex-col gap-2", className),
980
+ ...props
981
+ });
982
+ }
983
+ function TabsList({ className, ...props }) {
984
+ return /* @__PURE__ */ jsx(Tabs.List, {
985
+ "data-slot": "tabs-list",
986
+ className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", className),
987
+ ...props
988
+ });
989
+ }
990
+ function TabsTrigger({ className, ...props }) {
991
+ return /* @__PURE__ */ jsx(Tabs.Trigger, {
992
+ "data-slot": "tabs-trigger",
993
+ className: cn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
994
+ ...props
995
+ });
996
+ }
997
+
998
+ //#endregion
999
+ //#region src/components/file-explorer/index.tsx
1000
+ const sortNodes = (nodes) => {
1001
+ return [...nodes].sort((a, b) => {
1002
+ if (a.type !== b.type) return a.type === "folder" ? -1 : 1;
1003
+ return a.name.localeCompare(b.name);
1004
+ });
1005
+ };
1006
+ const FileTreeItem = ({ node, defaultOpen, depth = 0, currentPath, renderItem }) => {
1007
+ const isSelected = node.type === "file" && node.path === currentPath;
1008
+ const [open, setOpen] = useState(defaultOpen);
1009
+ const customContent = renderItem?.({
1010
+ node,
1011
+ depth,
1012
+ isSelected,
1013
+ isOpen: node.type === "file" ? void 0 : open
1014
+ });
1015
+ if (node.type === "file") return /* @__PURE__ */ jsx(TabsTrigger, {
1016
+ value: node.path,
1017
+ "data-type": "file",
1018
+ "data-path": node.path,
1019
+ className: "h-8 w-full justify-start border-transparent",
1020
+ style: { paddingLeft: depth * 8 + 8 },
1021
+ children: customContent ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Braces, { className: "size-4" }), /* @__PURE__ */ jsx("span", {
1022
+ className: "truncate",
1023
+ children: node.name
1024
+ })] })
1025
+ });
1026
+ return /* @__PURE__ */ jsxs(Collapsible$1, {
1027
+ defaultOpen,
1028
+ open,
1029
+ onOpenChange: setOpen,
1030
+ className: "flex w-full flex-col gap-1",
1031
+ children: [/* @__PURE__ */ jsx(CollapsibleTrigger, {
1032
+ asChild: true,
1033
+ children: /* @__PURE__ */ jsx(Button, {
1034
+ variant: "ghost",
1035
+ "data-type": "folder",
1036
+ "data-path": node.path,
1037
+ className: "hover:bg-sidebar-accent text-foreground h-8 w-full justify-start border border-transparent py-1",
1038
+ style: {
1039
+ paddingLeft: depth * 8 + 8,
1040
+ paddingRight: 8
1041
+ },
1042
+ children: customContent ?? /* @__PURE__ */ jsxs(Fragment, { children: [
1043
+ /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 transition-transform duration-200 [[data-state=open]>&]:rotate-90" }),
1044
+ /* @__PURE__ */ jsx(Folder, { className: "size-4" }),
1045
+ /* @__PURE__ */ jsx("span", {
1046
+ className: "truncate",
1047
+ children: node.name
1048
+ })
1049
+ ] })
1050
+ })
1051
+ }), node.children?.length ? /* @__PURE__ */ jsx(CollapsibleContent, {
1052
+ className: "flex flex-col gap-1",
1053
+ children: sortNodes(node.children).map((child) => /* @__PURE__ */ jsx(FileTreeItem, {
1054
+ node: child,
1055
+ depth: depth + 1,
1056
+ currentPath,
1057
+ defaultOpen,
1058
+ renderItem
1059
+ }, child.path))
1060
+ }) : null]
1061
+ });
1062
+ };
1063
+ /**
1064
+ * CodesparkFileExplorer - A file tree explorer component for navigating multi-file workspaces.
1065
+ *
1066
+ * Displays a hierarchical view of files and folders in the workspace.
1067
+ * Supports file selection to switch the active file in the editor.
1068
+ * Automatically sorts items with folders first, then files alphabetically.
1069
+ */
1070
+ const CodesparkFileExplorer = forwardRef((props, ref) => {
1071
+ const { className, defaultOpen = false, renderItem, ...rest } = props;
1072
+ const { fileTree, currentFile, workspace } = useWorkspace();
1073
+ return /* @__PURE__ */ jsx(Tabs$1, {
1074
+ ref,
1075
+ className: cn("bg-sidebar border-border box-border w-50 p-2", className),
1076
+ orientation: "vertical",
1077
+ value: currentFile.path,
1078
+ onValueChange: (path) => workspace.setCurrentFile(path),
1079
+ ...rest,
1080
+ children: /* @__PURE__ */ jsx(TabsList, {
1081
+ className: "bg-sidebar h-fit w-full flex-col items-start gap-1 p-0",
1082
+ children: sortNodes(fileTree).map((node) => {
1083
+ return /* @__PURE__ */ jsx(FileTreeItem, {
1084
+ node,
1085
+ currentPath: currentFile.path,
1086
+ defaultOpen,
1087
+ renderItem
1088
+ }, node.path);
1089
+ })
1090
+ })
1091
+ });
1092
+ });
1093
+ CodesparkFileExplorer.displayName = "CodesparkFileExplorer";
1094
+
1095
+ //#endregion
1096
+ //#region src/components/inject/index.tsx
1097
+ /**
1098
+ * Style - Injects custom CSS styles into the preview iframe.
1099
+ *
1100
+ * A declarative component for adding inline styles to the sandboxed preview.
1101
+ * Renders nothing in the React tree but injects a `<style>` tag into the iframe.
1102
+ *
1103
+ * @example
1104
+ * ```tsx
1105
+ * <CodesparkPreview>
1106
+ * <Style>{`.custom { color: red; }`}</Style>
1107
+ * </CodesparkPreview>
1108
+ * ```
1109
+ */
1110
+ function Style(_props) {
1111
+ return null;
1112
+ }
1113
+ /**
1114
+ * Script - Injects custom JavaScript into the preview iframe.
1115
+ *
1116
+ * A declarative component for adding inline or external scripts to the sandboxed preview.
1117
+ * Renders nothing in the React tree but injects a `<script>` tag into the iframe.
1118
+ *
1119
+ * @example
1120
+ * ```tsx
1121
+ * // Inline script
1122
+ * <CodesparkPreview>
1123
+ * <Script>{`console.log('Hello from preview');`}<\/Script>
1124
+ * </CodesparkPreview>
1125
+ *
1126
+ * // External script
1127
+ * <CodesparkPreview>
1128
+ * <Script src="https://example.com/script.js" />
1129
+ * </CodesparkPreview>
1130
+ * ```
1131
+ */
1132
+ function Script(_props) {
1133
+ return null;
1134
+ }
1135
+ /**
1136
+ * Link - Injects external resources into the preview iframe.
1137
+ *
1138
+ * A declarative component for adding `<link>` tags to the sandboxed preview.
1139
+ * Commonly used for external stylesheets, fonts, or other linked resources.
1140
+ * Renders nothing in the React tree but injects a `<link>` tag into the iframe.
1141
+ *
1142
+ * @example
1143
+ * ```tsx
1144
+ * // External stylesheet
1145
+ * <CodesparkPreview>
1146
+ * <Link rel="stylesheet" href="https://example.com/styles.css" />
1147
+ * </CodesparkPreview>
1148
+ *
1149
+ * // Google Fonts
1150
+ * <CodesparkPreview>
1151
+ * <Link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter" />
1152
+ * </CodesparkPreview>
1153
+ * ```
1154
+ */
1155
+ function Link(_props) {
1156
+ return null;
1157
+ }
1158
+ function useInjections(children) {
1159
+ const [injections, setInjections] = useState([]);
1160
+ useEffect(() => {
1161
+ const result = [];
1162
+ Children.forEach(children, (child) => {
1163
+ if (isValidElement(child)) {
1164
+ if (child.type === Style) {
1165
+ const { children: children$1, ...attrs } = child.props;
1166
+ result.push(`<style${serializeAttributes(attrs)}>${children$1?.trim() || ""}</style>`);
1167
+ } else if (child.type === Script) {
1168
+ const { children: children$1, ...attrs } = child.props;
1169
+ result.push(`<script${serializeAttributes(attrs)}>${children$1?.trim() || ""}<\/script>`);
1170
+ } else if (child.type === Link) {
1171
+ const attrs = child.props;
1172
+ result.push(`<link${serializeAttributes(attrs)} />`);
1173
+ }
1174
+ }
1175
+ });
1176
+ setInjections(result);
1177
+ }, [children]);
1178
+ return injections;
1179
+ }
1180
+
1181
+ //#endregion
1182
+ //#region ./srcdoc.html?raw
1183
+ var srcdoc_default = "<!doctype html>\n<html class=\"DEFAULT_THEME\" style=\"color-scheme: DEFAULT_THEME\">\n <head>\n <style>\n :root {\n font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;\n font-size: 16px;\n line-height: 1.5;\n font-synthesis: none;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n\n html,\n body {\n margin: 0;\n overflow: hidden;\n }\n\n html {\n width: 100vw;\n height: 100vh;\n padding: 0;\n }\n\n body {\n background: var(--background);\n color: var(--foreground);\n font-size: 14px;\n height: 100%;\n padding: 12px;\n overflow: auto;\n box-sizing: border-box;\n display: flex;\n }\n\n #root {\n margin: auto;\n }\n </style>\n <script type=\"importmap\">\n <!-- IMPORT_MAP -->\n <\/script>\n <!-- PRESET_TAG -->\n <script>\n (() => {\n // Monitor module loading via PerformanceObserver\n const observer = new PerformanceObserver(list => {\n for (const entry of list.getEntries()) {\n if (entry.initiatorType === 'script' || entry.initiatorType === 'link') {\n const url = entry.name;\n // Extract package name from URL (e.g., esm.sh/react@18.2.0/jsx-runtime -> react@18.2.0/jsx-runtime)\n const match = url.match(/esm\\.sh\\/([^\\s?#]+)/);\n const name = match ? match[1] : url;\n loadingModules.delete(name);\n parent.postMessage(\n {\n action: 'fetch_progress',\n args: { loaded: name, remaining: [...loadingModules] }\n },\n '*'\n );\n }\n }\n });\n observer.observe({ entryTypes: ['resource'] });\n\n const scriptEls = [];\n const loadingModules = new Set();\n\n // Queue for sequential eval execution\n let evalQueue = Promise.resolve();\n\n window.__vite_plugin_react_preamble_installed__ = {};\n window.__modules__ = {};\n window.__export__ = (mod, key, get) => {\n Object.defineProperty(mod, key, {\n enumerable: true,\n configurable: true,\n get\n });\n };\n window.__dynamic_import__ = key => {\n return Promise.resolve(window.__modules__[key]);\n };\n window.__render_complete__ = () => {\n parent.postMessage({ action: 'render_complete' }, '*');\n };\n\n async function processEval(ev) {\n const { cmd_id } = ev.data;\n const send_message = payload => parent.postMessage({ ...payload }, ev.origin);\n const send_reply = payload => send_message({ ...payload, cmd_id });\n const send_ok = () => send_reply({ action: 'cmd_ok' });\n const send_error = (message, stack) => send_reply({ action: 'cmd_error', message, stack });\n\n try {\n if (scriptEls.length) {\n scriptEls.forEach(el => {\n document.head.removeChild(el);\n });\n scriptEls.length = 0;\n }\n\n let { script: scripts } = ev.data.args;\n if (typeof scripts === 'string') scripts = [scripts];\n\n for (const script of scripts) {\n const scriptEl = document.createElement('script');\n scriptEl.setAttribute('type', 'module');\n // send ok in the module script to ensure sequential evaluation\n // of multiple proxy.eval() calls\n const done = new Promise(resolve => {\n window.__next__ = resolve;\n });\n scriptEl.innerHTML = script;\n document.head.appendChild(scriptEl);\n scriptEl.onerror = err => {\n send_error(err.message, err.stack);\n window.__next__?.(); // unblock queue on error\n };\n scriptEls.push(scriptEl);\n await done;\n }\n window.__next__ = undefined;\n send_ok();\n } catch (e) {\n send_error(e.message, e.stack);\n }\n }\n\n function handle_message(ev) {\n const { action, cmd_id } = ev.data;\n const send_message = payload => parent.postMessage({ ...payload }, ev.origin);\n const send_reply = payload => send_message({ ...payload, cmd_id });\n const send_ok = () => send_reply({ action: 'cmd_ok' });\n const send_error = (message, stack) => send_reply({ action: 'cmd_error', message, stack });\n\n if (action === 'eval') {\n // Queue eval requests to ensure sequential execution\n evalQueue = evalQueue.then(() => processEval(ev));\n return;\n }\n\n if (action === 'catch_clicks') {\n try {\n const top_origin = ev.origin;\n document.body.addEventListener('click', event => {\n if (event.which !== 1) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey) return;\n if (event.defaultPrevented) return;\n\n // ensure target is a link\n let el = event.target;\n while (el && el.nodeName !== 'A') el = el.parentNode;\n if (!el || el.nodeName !== 'A') return;\n\n if (el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target) return;\n\n event.preventDefault();\n\n if (el.href.startsWith(top_origin)) {\n const url = new URL(el.href);\n if (url.hash[0] === '#') {\n window.location.hash = url.hash;\n return;\n }\n }\n\n window.open(el.href, '_blank');\n });\n send_ok();\n } catch (e) {\n send_error(e.message, e.stack);\n }\n }\n }\n\n window.addEventListener('message', handle_message, false);\n\n window.onerror = function (msg, url, lineNo, columnNo, error) {\n try {\n parent.postMessage({ action: 'error', value: error }, '*');\n } catch (e) {\n parent.postMessage({ action: 'error', value: msg }, '*');\n }\n window.__next__?.(); // unblock eval queue on error\n };\n\n window.addEventListener('unhandledrejection', event => {\n if (event.reason?.message.includes('Cross-origin')) {\n event.preventDefault();\n return;\n }\n try {\n parent.postMessage({ action: 'unhandledrejection', value: event.reason }, '*');\n } catch (e) {\n parent.postMessage({ action: 'unhandledrejection', value: event.reason.message }, '*');\n }\n });\n\n let previous = { level: null, args: null };\n\n ['clear', 'log', 'info', 'dir', 'warn', 'error', 'table'].forEach(level => {\n const original = console[level];\n console[level] = (...args) => {\n const msg = String(args[0]);\n try {\n const stringifiedArgs = stringify(args);\n if (previous.level === level && previous.args && previous.args === stringifiedArgs) {\n parent.postMessage({ action: 'console', level, args, duplicate: true }, '*');\n } else {\n previous = { level, args: stringifiedArgs };\n parent.postMessage({ action: 'console', level, args }, '*');\n }\n } catch (err) {\n parent.postMessage(\n {\n action: 'console',\n level,\n args: args.map(a => {\n return a instanceof Error ? a.message : String(a);\n })\n },\n '*'\n );\n }\n\n original(...args);\n };\n });\n\n [\n { method: 'group', action: 'console_group' },\n { method: 'groupEnd', action: 'console_group_end' },\n { method: 'groupCollapsed', action: 'console_group_collapsed' }\n ].forEach(group_action => {\n const original = console[group_action.method];\n console[group_action.method] = label => {\n parent.postMessage({ action: group_action.action, label }, '*');\n\n original(label);\n };\n });\n\n const timers = new Map();\n const original_time = console.time;\n const original_timelog = console.timeLog;\n const original_timeend = console.timeEnd;\n\n console.time = (label = 'default') => {\n original_time(label);\n timers.set(label, performance.now());\n };\n console.timeLog = (label = 'default') => {\n original_timelog(label);\n const now = performance.now();\n if (timers.has(label))\n parent.postMessage(\n {\n action: 'console',\n level: 'system-log',\n args: [`${label}: ${now - timers.get(label)}ms`]\n },\n '*'\n );\n else\n parent.postMessage(\n {\n action: 'console',\n level: 'system-warn',\n args: [`Timer '${label}' does not exist`]\n },\n '*'\n );\n };\n console.timeEnd = (label = 'default') => {\n original_timeend(label);\n const now = performance.now();\n if (timers.has(label))\n parent.postMessage(\n {\n action: 'console',\n level: 'system-log',\n args: [`${label}: ${now - timers.get(label)}ms`]\n },\n '*'\n );\n else\n parent.postMessage(\n {\n action: 'console',\n level: 'system-warn',\n args: [`Timer '${label}' does not exist`]\n },\n '*'\n );\n\n timers.delete(label);\n };\n\n const original_assert = console.assert;\n console.assert = (condition, ...args) => {\n if (condition) {\n const stack = new Error().stack;\n parent.postMessage({ action: 'console', level: 'assert', args, stack }, '*');\n }\n original_assert(condition, ...args);\n };\n\n const counter = new Map();\n const original_count = console.count;\n const original_countreset = console.countReset;\n\n console.count = (label = 'default') => {\n counter.set(label, (counter.get(label) || 0) + 1);\n parent.postMessage(\n {\n action: 'console',\n level: 'system-log',\n args: `${label}: ${counter.get(label)}`\n },\n '*'\n );\n original_count(label);\n };\n\n console.countReset = (label = 'default') => {\n if (counter.has(label)) counter.set(label, 0);\n else\n parent.postMessage(\n {\n action: 'console',\n level: 'system-warn',\n args: `Count for '${label}' does not exist`\n },\n '*'\n );\n\n original_countreset(label);\n };\n\n const original_trace = console.trace;\n\n console.trace = (...args) => {\n const stack = new Error().stack;\n parent.postMessage({ action: 'console', level: 'trace', args, stack }, '*');\n original_trace(...args);\n };\n\n function stringify(args) {\n try {\n return JSON.stringify(args);\n } catch (error) {\n return null;\n }\n }\n })();\n <\/script>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>\n";
1184
+
1185
+ //#endregion
1186
+ //#region src/lib/preview-proxy/index.ts
1187
+ let uid = 1;
1188
+ var PreviewProxy = class {
1189
+ iframe;
1190
+ handleEvent;
1191
+ pending_cmds;
1192
+ handlers;
1193
+ constructor(config) {
1194
+ const { id, root, handlers, defaultTheme = "light", defaultImports = {}, defaultPresets = [] } = config || {};
1195
+ if (root) this.iframe = root;
1196
+ else {
1197
+ this.iframe = document.createElement("iframe");
1198
+ this.iframe.id = id ?? "proxy_iframe";
1199
+ }
1200
+ this.iframe.setAttribute("sandbox", [
1201
+ "allow-forms",
1202
+ "allow-modals",
1203
+ "allow-pointer-lock",
1204
+ "allow-popups",
1205
+ "allow-same-origin",
1206
+ "allow-scripts",
1207
+ "allow-top-navigation-by-user-activation"
1208
+ ].join(" "));
1209
+ this.iframe.src = URL.createObjectURL(new Blob([srcdoc_default.replace(/DEFAULT_THEME/g, defaultTheme).replace(/<!-- IMPORT_MAP -->/, JSON.stringify({ imports: defaultImports })).replace(/<!-- PRESET_TAG -->/, defaultPresets.join("\n"))], { type: "text/html" }));
1210
+ this.handlers = handlers;
1211
+ this.pending_cmds = /* @__PURE__ */ new Map();
1212
+ this.handleEvent = (e) => this.handleReplMessage(e);
1213
+ window.addEventListener("message", this.handleEvent, false);
1214
+ this.iframe.addEventListener("load", () => {
1215
+ URL.revokeObjectURL(this.iframe.src);
1216
+ });
1217
+ }
1218
+ eval(script) {
1219
+ return this.iframeCommand("eval", { script });
1220
+ }
1221
+ destroy() {
1222
+ window.removeEventListener("message", this.handleEvent);
1223
+ }
1224
+ iframeCommand(action, args) {
1225
+ return new Promise((resolve, reject) => {
1226
+ const cmd_id = uid++;
1227
+ this.pending_cmds.set(cmd_id, {
1228
+ resolve,
1229
+ reject
1230
+ });
1231
+ this.iframe.contentWindow?.postMessage({
1232
+ action,
1233
+ cmd_id,
1234
+ args
1235
+ }, "*");
1236
+ });
1237
+ }
1238
+ handleCommandMessage(cmd_data) {
1239
+ const action = cmd_data.action;
1240
+ const id = cmd_data.cmd_id;
1241
+ const handler = this.pending_cmds.get(id);
1242
+ if (handler) {
1243
+ this.pending_cmds.delete(id);
1244
+ if (action === "cmd_error") {
1245
+ const { message, stack } = cmd_data;
1246
+ const e = new Error(message);
1247
+ e.stack = stack;
1248
+ handler.reject(e);
1249
+ }
1250
+ if (action === "cmd_ok") handler.resolve(cmd_data.args);
1251
+ }
1252
+ }
1253
+ handleReplMessage(event) {
1254
+ if (event.source !== this.iframe.contentWindow) return;
1255
+ const { action, args } = event.data;
1256
+ switch (action) {
1257
+ case "cmd_error":
1258
+ case "cmd_ok": return this.handleCommandMessage(event.data);
1259
+ case "fetch_progress": return this.handlers?.on_fetch_progress?.(args);
1260
+ case "render_complete": return this.handlers?.on_render_complete?.();
1261
+ case "error": return this.handlers?.on_error?.(event.data);
1262
+ case "unhandledrejection": return this.handlers?.on_unhandled_rejection?.(event.data);
1263
+ case "console": return this.handlers?.on_console?.(event.data);
1264
+ case "console_group": return this.handlers?.on_console_group?.(event.data);
1265
+ case "console_group_collapsed": return this.handlers?.on_console_group_collapsed?.(event.data);
1266
+ case "console_group_end": return this.handlers?.on_console_group_end?.(event.data);
1267
+ }
1268
+ }
1269
+ handleLinks() {
1270
+ return this.iframeCommand("catch_clicks", {});
1271
+ }
1272
+ changeTheme(theme) {
1273
+ const root = this.iframe.contentDocument?.querySelector("html");
1274
+ if (root) {
1275
+ root.classList.remove("light", "dark");
1276
+ root.classList.add(theme);
1277
+ root.setAttribute("style", `color-scheme: ${theme}`);
1278
+ }
1279
+ }
1280
+ injectTags(tags) {
1281
+ const doc = this.iframe.contentDocument;
1282
+ if (!doc) return;
1283
+ doc.querySelectorAll("[data-injected]").forEach((el) => el.remove());
1284
+ if (tags?.length) tags.forEach((tag) => {
1285
+ const container = doc.createElement("div");
1286
+ container.innerHTML = tag;
1287
+ const el = container.firstElementChild;
1288
+ if (!el) return;
1289
+ if (el.tagName === "SCRIPT") {
1290
+ const script = doc.createElement("script");
1291
+ Array.from(el.attributes).forEach((attr) => script.setAttribute(attr.name, attr.value));
1292
+ script.textContent = el.textContent;
1293
+ script.setAttribute("data-injected", "");
1294
+ doc.head.appendChild(script);
1295
+ } else {
1296
+ el.setAttribute("data-injected", "");
1297
+ doc.head.appendChild(el);
1298
+ }
1299
+ });
1300
+ }
1301
+ setImportMap(imports) {
1302
+ const doc = this.iframe.contentDocument;
1303
+ if (!doc) return;
1304
+ const oldMap = doc.querySelector("script[type=\"importmap\"]");
1305
+ if (oldMap) oldMap.remove();
1306
+ const script = doc.createElement("script");
1307
+ script.type = "importmap";
1308
+ script.textContent = JSON.stringify({ imports: imports || {} });
1309
+ doc.head.insertBefore(script, doc.head.firstChild);
1310
+ }
1311
+ };
1312
+ function usePreview(options) {
1313
+ const { presets, imports, theme = "light", onLoad, onError, onFetchProgress, onRenderComplete, onConsole } = options || {};
1314
+ const [running, setRunning] = useState(true);
1315
+ const proxyRef = useRef(void 0);
1316
+ const iframeRef = useRef(null);
1317
+ const readyRef = useRef(Promise.withResolvers());
1318
+ const preview = async (...code) => {
1319
+ try {
1320
+ setRunning(true);
1321
+ await readyRef.current.promise;
1322
+ await proxyRef.current?.eval(code);
1323
+ } catch (error) {
1324
+ onError?.(error);
1325
+ }
1326
+ };
1327
+ useEffect(() => {
1328
+ if (iframeRef.current) {
1329
+ const proxy = new PreviewProxy({
1330
+ root: iframeRef.current,
1331
+ defaultTheme: theme,
1332
+ handlers: {
1333
+ on_console: onConsole,
1334
+ on_fetch_progress: onFetchProgress,
1335
+ on_render_complete: () => {
1336
+ onRenderComplete?.();
1337
+ setRunning(false);
1338
+ },
1339
+ on_error: (event) => {
1340
+ onError?.(event.value instanceof Error ? event.value : new Error(event.value));
1341
+ },
1342
+ on_unhandled_rejection: (event) => {
1343
+ onError?.(/* @__PURE__ */ new Error(`Uncaught (in promise): ${event.value}`));
1344
+ }
1345
+ }
1346
+ });
1347
+ iframeRef.current.addEventListener("load", (e) => {
1348
+ readyRef.current.resolve(e.target.contentDocument);
1349
+ onLoad?.(proxy);
1350
+ });
1351
+ proxyRef.current = proxy;
1352
+ return () => proxy.destroy();
1353
+ }
1354
+ }, []);
1355
+ useEffect(() => {
1356
+ readyRef.current.promise.then(() => {
1357
+ proxyRef.current?.changeTheme(theme);
1358
+ });
1359
+ }, [theme]);
1360
+ useEffect(() => {
1361
+ readyRef.current.promise.then(() => {
1362
+ proxyRef.current?.injectTags(presets);
1363
+ });
1364
+ }, [presets?.join("\n")]);
1365
+ useEffect(() => {
1366
+ readyRef.current.promise.then(() => {
1367
+ proxyRef.current?.setImportMap(imports);
1368
+ });
1369
+ }, [JSON.stringify(imports)]);
1370
+ return {
1371
+ iframeRef,
1372
+ proxyRef,
1373
+ readyRef,
1374
+ preview,
1375
+ running
1376
+ };
1377
+ }
1378
+
1379
+ //#endregion
1380
+ //#region node_modules/tailwindcss/index.css?raw
1381
+ var tailwindcss_default = "@layer theme, base, components, utilities;\n\n@layer theme {\n @theme default {\n --font-sans:\n ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\",\n \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --font-serif: ui-serif, Georgia, Cambria, \"Times New Roman\", Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\",\n \"Courier New\", monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 0);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 0);\n --color-neutral-100: oklch(97% 0 0);\n --color-neutral-200: oklch(92.2% 0 0);\n --color-neutral-300: oklch(87% 0 0);\n --color-neutral-400: oklch(70.8% 0 0);\n --color-neutral-500: oklch(55.6% 0 0);\n --color-neutral-600: oklch(43.9% 0 0);\n --color-neutral-700: oklch(37.1% 0 0);\n --color-neutral-800: oklch(26.9% 0 0);\n --color-neutral-900: oklch(20.5% 0 0);\n --color-neutral-950: oklch(14.5% 0 0);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md:\n 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg:\n 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl:\n 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075),\n 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1),\n 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1),\n 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(\n --font-sans--font-feature-settings,\n initial\n );\n --default-font-variation-settings: --theme(\n --font-sans--font-variation-settings,\n initial\n );\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(\n --font-mono--font-feature-settings,\n initial\n );\n --default-mono-font-variation-settings: --theme(\n --font-mono--font-variation-settings,\n initial\n );\n }\n\n /* Deprecated */\n @theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n }\n}\n\n@layer base {\n /*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n }\n\n /*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user's configured `sans` font-family by default.\n 5. Use the user's configured `sans` font-feature-settings by default.\n 6. Use the user's configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\n html,\n :host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n ); /* 4 */\n font-feature-settings: --theme(\n --default-font-feature-settings,\n normal\n ); /* 5 */\n font-variation-settings: --theme(\n --default-font-variation-settings,\n normal\n ); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n }\n\n /*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\n hr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n }\n\n /*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n\n /*\n Remove the default font size and weight for headings.\n*/\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n /*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n /*\n Add the correct font weight in Edge and Safari.\n*/\n\n b,\n strong {\n font-weight: bolder;\n }\n\n /*\n 1. Use the user's configured `mono` font-family by default.\n 2. Use the user's configured `mono` font-feature-settings by default.\n 3. Use the user's configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\n code,\n kbd,\n samp,\n pre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n \"Liberation Mono\",\n \"Courier New\",\n monospace\n ); /* 1 */\n font-feature-settings: --theme(\n --default-mono-font-feature-settings,\n normal\n ); /* 2 */\n font-variation-settings: --theme(\n --default-mono-font-variation-settings,\n normal\n ); /* 3 */\n font-size: 1em; /* 4 */\n }\n\n /*\n Add the correct font size in all browsers.\n*/\n\n small {\n font-size: 80%;\n }\n\n /*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n /*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\n table {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n }\n\n /*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n :-moz-focusring {\n outline: auto;\n }\n\n /*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\n progress {\n vertical-align: baseline;\n }\n\n /*\n Add the correct display in Chrome and Safari.\n*/\n\n summary {\n display: list-item;\n }\n\n /*\n Make lists unstyled by default.\n*/\n\n ol,\n ul,\n menu {\n list-style: none;\n }\n\n /*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n }\n\n /*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n /*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n }\n\n /*\n Restore default font weight.\n*/\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n /*\n Restore indentation.\n*/\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n /*\n Restore space after button.\n*/\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n /*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n ::placeholder {\n opacity: 1;\n }\n\n /*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(…)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n @supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n\n /*\n Prevent resizing textareas horizontally by default.\n*/\n\n textarea {\n resize: vertical;\n }\n\n /*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n /*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n ::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n }\n\n /*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n /*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit,\n ::-webkit-datetime-edit-year-field,\n ::-webkit-datetime-edit-month-field,\n ::-webkit-datetime-edit-day-field,\n ::-webkit-datetime-edit-hour-field,\n ::-webkit-datetime-edit-minute-field,\n ::-webkit-datetime-edit-second-field,\n ::-webkit-datetime-edit-millisecond-field,\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n /*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n /*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n /*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\n button,\n input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]),\n ::file-selector-button {\n appearance: button;\n }\n\n /*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n /*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n\n@layer utilities {\n @tailwind utilities;\n}\n";
1382
+
1383
+ //#endregion
1384
+ //#region node_modules/tailwindcss/preflight.css?raw
1385
+ var preflight_default = "/*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n*,\n::after,\n::before,\n::backdrop,\n::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n}\n\n/*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user's configured `sans` font-family by default.\n 5. Use the user's configured `sans` font-feature-settings by default.\n 6. Use the user's configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n ui-sans-serif,\n system-ui,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol',\n 'Noto Color Emoji'\n ); /* 4 */\n font-feature-settings: --theme(--default-font-feature-settings, normal); /* 5 */\n font-variation-settings: --theme(--default-font-variation-settings, normal); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\n Remove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n}\n\n/*\n Add the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n 1. Use the user's configured `mono` font-family by default.\n 2. Use the user's configured `mono` font-feature-settings by default.\n 3. Use the user's configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n 'Liberation Mono',\n 'Courier New',\n monospace\n ); /* 1 */\n font-feature-settings: --theme(--default-mono-font-feature-settings, normal); /* 2 */\n font-variation-settings: --theme(--default-mono-font-variation-settings, normal); /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\n Add the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\n Add the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\n Make lists unstyled by default.\n*/\n\nol,\nul,\nmenu {\n list-style: none;\n}\n\n/*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\nbutton,\ninput,\nselect,\noptgroup,\ntextarea,\n::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n}\n\n/*\n Restore default font weight.\n*/\n\n:where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n}\n\n/*\n Restore indentation.\n*/\n\n:where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n}\n\n/*\n Restore space after button.\n*/\n\n::file-selector-button {\n margin-inline-end: 4px;\n}\n\n/*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n::placeholder {\n opacity: 1;\n}\n\n/*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(…)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n@supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n}\n\n/*\n Prevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n}\n\n/*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n::-webkit-datetime-edit {\n display: inline-flex;\n}\n\n/*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n}\n\n::-webkit-datetime-edit,\n::-webkit-datetime-edit-year-field,\n::-webkit-datetime-edit-month-field,\n::-webkit-datetime-edit-day-field,\n::-webkit-datetime-edit-hour-field,\n::-webkit-datetime-edit-minute-field,\n::-webkit-datetime-edit-second-field,\n::-webkit-datetime-edit-millisecond-field,\n::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n}\n\n/*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n::-webkit-calendar-picker-indicator {\n line-height: 1;\n}\n\n/*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\nbutton,\ninput:where([type='button'], [type='reset'], [type='submit']),\n::file-selector-button {\n appearance: button;\n}\n\n/*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n[hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n}\n";
1386
+
1387
+ //#endregion
1388
+ //#region node_modules/tailwindcss/theme.css?raw
1389
+ var theme_default = "@theme default {\n --font-sans:\n ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',\n 'Noto Color Emoji';\n --font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 0);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 0);\n --color-neutral-100: oklch(97% 0 0);\n --color-neutral-200: oklch(92.2% 0 0);\n --color-neutral-300: oklch(87% 0 0);\n --color-neutral-400: oklch(70.8% 0 0);\n --color-neutral-500: oklch(55.6% 0 0);\n --color-neutral-600: oklch(43.9% 0 0);\n --color-neutral-700: oklch(37.1% 0 0);\n --color-neutral-800: oklch(26.9% 0 0);\n --color-neutral-900: oklch(20.5% 0 0);\n --color-neutral-950: oklch(14.5% 0 0);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(--font-sans--font-feature-settings, initial);\n --default-font-variation-settings: --theme(--font-sans--font-variation-settings, initial);\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(--font-mono--font-feature-settings, initial);\n --default-mono-font-variation-settings: --theme(--font-mono--font-variation-settings, initial);\n}\n\n/* Deprecated */\n@theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n}\n";
1390
+
1391
+ //#endregion
1392
+ //#region node_modules/tailwindcss/utilities.css?raw
1393
+ var utilities_default = "@tailwind utilities;\n";
1394
+
1395
+ //#endregion
1396
+ //#region src/lib/tailwindcss/assets.ts
1397
+ const css = {
1398
+ index: tailwindcss_default,
1399
+ preflight: preflight_default,
1400
+ theme: theme_default,
1401
+ utilities: utilities_default
1402
+ };
1403
+
1404
+ //#endregion
1405
+ //#region src/lib/tailwindcss/index.ts
1406
+ var TailwindCSSJit = class TailwindCSSJit {
1407
+ static STYLE_TYPE = "text/tailwindcss";
1408
+ compiler;
1409
+ classes = /* @__PURE__ */ new Set();
1410
+ lastCss = "";
1411
+ buildQueue = Promise.resolve("");
1412
+ constructor(env = document) {
1413
+ this.env = env;
1414
+ }
1415
+ rebuild(kind) {
1416
+ const run = async () => {
1417
+ if (!this.compiler && kind !== "full") return;
1418
+ if (kind === "full") await this.createCompiler();
1419
+ return this.build(kind);
1420
+ };
1421
+ this.buildQueue = this.buildQueue.then(run);
1422
+ return this.buildQueue;
1423
+ }
1424
+ get stylesheets() {
1425
+ return this.env.querySelectorAll(`style[type="${TailwindCSSJit.STYLE_TYPE}"]`);
1426
+ }
1427
+ async createCompiler() {
1428
+ let css$1 = "";
1429
+ for (const sheet of this.stylesheets) css$1 += sheet.textContent + "\n";
1430
+ if (!css$1.includes("@import")) css$1 = `@import "tailwindcss";${css$1}`;
1431
+ if (this.lastCss === css$1) return;
1432
+ this.lastCss = css$1;
1433
+ try {
1434
+ this.compiler = await tailwindcss.compile(css$1, {
1435
+ base: "/",
1436
+ loadStylesheet: this.loadStylesheet,
1437
+ loadModule: this.loadModule
1438
+ });
1439
+ } finally {
1440
+ this.classes.clear();
1441
+ }
1442
+ }
1443
+ async build(kind) {
1444
+ if (!this.compiler) return;
1445
+ const newClasses = /* @__PURE__ */ new Set();
1446
+ for (const element of this.env.querySelectorAll("[class]")) for (const c of element.classList) {
1447
+ if (this.classes.has(c)) continue;
1448
+ this.classes.add(c);
1449
+ newClasses.add(c);
1450
+ }
1451
+ if (newClasses.size === 0 && kind === "incremental") return;
1452
+ return this.compiler.build(Array.from(newClasses));
1453
+ }
1454
+ async loadStylesheet(id, base) {
1455
+ const stylesheet = {
1456
+ tailwindcss: {
1457
+ path: "virtual:tailwindcss/index.css",
1458
+ content: css.index
1459
+ },
1460
+ "tailwindcss/preflight": {
1461
+ path: "virtual:tailwindcss/preflight.css",
1462
+ content: css.preflight
1463
+ },
1464
+ "tailwindcss/preflight.css": {
1465
+ path: "virtual:tailwindcss/preflight.css",
1466
+ content: css.preflight
1467
+ },
1468
+ "./preflight.css": {
1469
+ path: "virtual:tailwindcss/preflight.css",
1470
+ content: css.preflight
1471
+ },
1472
+ "tailwindcss/theme": {
1473
+ path: "virtual:tailwindcss/theme.css",
1474
+ content: css.theme
1475
+ },
1476
+ "tailwindcss/theme.css": {
1477
+ path: "virtual:tailwindcss/theme.css",
1478
+ content: css.theme
1479
+ },
1480
+ "./theme.css": {
1481
+ path: "virtual:tailwindcss/theme.css",
1482
+ content: css.theme
1483
+ },
1484
+ "tailwindcss/utilities": {
1485
+ path: "virtual:tailwindcss/utilities.css",
1486
+ content: css.utilities
1487
+ },
1488
+ "tailwindcss/utilities.css": {
1489
+ path: "virtual:tailwindcss/utilities.css",
1490
+ content: css.utilities
1491
+ },
1492
+ "./utilities.css": {
1493
+ path: "virtual:tailwindcss/utilities.css",
1494
+ content: css.utilities
1495
+ }
1496
+ }[id];
1497
+ if (stylesheet) return {
1498
+ ...stylesheet,
1499
+ base
1500
+ };
1501
+ throw new Error(`The browser build does not support @import for "${id}"`);
1502
+ }
1503
+ async loadModule() {
1504
+ throw new Error(`The browser build does not support plugins or config files.`);
1505
+ }
1506
+ };
1507
+ function useTailwindCSS() {
1508
+ const jitRef = useRef(null);
1509
+ const sheetRef = useRef(null);
1510
+ const styleObserverRef = useRef(null);
1511
+ const observerRef = useRef(null);
1512
+ const observeStyle = (style) => {
1513
+ styleObserverRef.current?.observe(style, {
1514
+ attributes: true,
1515
+ attributeFilter: ["type"],
1516
+ characterData: true,
1517
+ subtree: true,
1518
+ childList: true
1519
+ });
1520
+ };
1521
+ const rebuild = async (kind) => {
1522
+ const css$1 = await jitRef.current?.rebuild(kind);
1523
+ if (css$1 !== void 0 && sheetRef.current) sheetRef.current.textContent = css$1;
1524
+ };
1525
+ const mount = (doc) => {
1526
+ jitRef.current ??= new TailwindCSSJit(doc);
1527
+ sheetRef.current ??= doc.createElement("style");
1528
+ styleObserverRef.current = new MutationObserver(() => rebuild("full"));
1529
+ observerRef.current = new MutationObserver((records) => {
1530
+ let full = 0;
1531
+ let incremental = 0;
1532
+ for (const record of records) {
1533
+ for (const node of record.addedNodes) {
1534
+ if (node.nodeType !== Node.ELEMENT_NODE) continue;
1535
+ if (node.tagName !== "STYLE") continue;
1536
+ if (node.getAttribute("type") !== TailwindCSSJit.STYLE_TYPE) continue;
1537
+ observeStyle(node);
1538
+ full++;
1539
+ }
1540
+ for (const node of record.addedNodes) {
1541
+ if (node.nodeType !== 1) continue;
1542
+ if (node === sheetRef.current) continue;
1543
+ incremental++;
1544
+ }
1545
+ if (record.type === "attributes") incremental++;
1546
+ }
1547
+ if (full > 0) rebuild("full");
1548
+ else if (incremental > 0) rebuild("incremental");
1549
+ });
1550
+ for (const style of jitRef.current.stylesheets) observeStyle(style);
1551
+ observerRef.current.observe(doc, {
1552
+ attributes: true,
1553
+ attributeFilter: ["class"],
1554
+ childList: true,
1555
+ subtree: true
1556
+ });
1557
+ rebuild("full");
1558
+ doc.head.appendChild(sheetRef.current);
1559
+ };
1560
+ const unmount = () => {
1561
+ styleObserverRef.current?.disconnect();
1562
+ observerRef.current?.disconnect();
1563
+ sheetRef.current?.remove();
1564
+ styleObserverRef.current = null;
1565
+ observerRef.current = null;
1566
+ sheetRef.current = null;
1567
+ jitRef.current = null;
1568
+ };
1569
+ return {
1570
+ mount,
1571
+ unmount
1572
+ };
1573
+ }
1574
+
1575
+ //#endregion
1576
+ //#region src/components/preview/index.tsx
1577
+ /**
1578
+ * CodesparkPreview - A sandboxed preview component that renders compiled code in an iframe.
1579
+ *
1580
+ * Executes compiled React code in an isolated iframe environment with ES module support.
1581
+ * Supports Tailwind CSS, custom scripts/styles injection, and console output capture.
1582
+ * Displays a loading indicator during code compilation and execution.
1583
+ */
1584
+ function CodesparkPreview(props) {
1585
+ const { imports: globalImports, theme: globalTheme } = useConfig();
1586
+ const { workspace: contextWorkspace, imports: contextImports, theme: contextTheme, framework: contextFramework } = useCodespark() || {};
1587
+ const { code = "", framework = contextFramework, className, tailwindcss: tailwindcss$1 = true, imports, theme = contextTheme ?? globalTheme ?? "light", children, height = 200, onError, onLoad, onRendered, onConsole } = props;
1588
+ const { compiled, vendor, workspace } = useWorkspace(props.workspace ?? contextWorkspace ?? new Workspace({
1589
+ entry: "./App.tsx",
1590
+ files: { "./App.tsx": code },
1591
+ framework
1592
+ }));
1593
+ const { mount: mountTailwind, unmount: unmountTailwind } = useTailwindCSS();
1594
+ const { iframeRef, readyRef, preview, running } = usePreview({
1595
+ theme,
1596
+ presets: [
1597
+ ...useInjections(children),
1598
+ ...vendor.styles.map(({ content, attributes }) => `<style${serializeAttributes(attributes)}>${content}</style>`),
1599
+ ...vendor.scripts.map(({ content, attributes }) => `<script${serializeAttributes(attributes)}>${content}<\/script>`)
1600
+ ],
1601
+ imports: {
1602
+ ...vendor.imports,
1603
+ ...globalImports,
1604
+ ...contextImports,
1605
+ ...imports
1606
+ },
1607
+ onError,
1608
+ onLoad: (proxy) => {
1609
+ onLoad?.(proxy.iframe);
1610
+ },
1611
+ onRenderComplete: onRendered,
1612
+ onConsole
1613
+ });
1614
+ useEffect(() => {
1615
+ if (!tailwindcss$1) unmountTailwind();
1616
+ else readyRef.current.promise.then((doc) => {
1617
+ if (doc) mountTailwind(doc);
1618
+ });
1619
+ return unmountTailwind;
1620
+ }, [tailwindcss$1]);
1621
+ useEffect(() => {
1622
+ if (typeof window === "undefined" || !code) return;
1623
+ workspace.setFile(workspace.entry, code);
1624
+ }, [code]);
1625
+ useEffect(() => {
1626
+ if (typeof window === "undefined" || !compiled) return;
1627
+ preview(compiled);
1628
+ }, [compiled]);
1629
+ return /* @__PURE__ */ jsxs("div", {
1630
+ className: cn("relative flex items-center justify-center", className),
1631
+ style: { height },
1632
+ children: [running ? /* @__PURE__ */ jsx("div", {
1633
+ className: "absolute right-2 bottom-2 z-10 h-8 w-8 **:box-border",
1634
+ children: /* @__PURE__ */ jsx("div", {
1635
+ className: "flex -translate-x-1 translate-y-[9px] scale-[0.13] **:absolute **:h-24 **:w-24",
1636
+ children: /* @__PURE__ */ jsxs("div", {
1637
+ className: "fill-mode-forwards **:border-foreground **:bg-background transform-[rotateX(-25.5deg)_rotateY(45deg)] animate-[cube-rotate_1s_linear_infinite] transform-3d **:rounded-lg **:border-10",
1638
+ children: [
1639
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateX(90deg)_translateZ(44px)]" }),
1640
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateY(90deg)_translateZ(44px)]" }),
1641
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateX(-90deg)_translateZ(44px)]" }),
1642
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateY(-90deg)_translateZ(44px)]" }),
1643
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateY(0deg)_translateZ(44px)]" }),
1644
+ /* @__PURE__ */ jsx("div", { className: "origin-[50%_50%] transform-[rotateY(-180deg)_translateZ(44px)]" })
1645
+ ]
1646
+ })
1647
+ })
1648
+ }) : null, /* @__PURE__ */ jsx("iframe", {
1649
+ ref: iframeRef,
1650
+ className: "h-full w-full"
1651
+ })]
1652
+ });
1653
+ }
1654
+
1655
+ //#endregion
1656
+ //#region src/index.tsx
1657
+ registerFramework(react);
1658
+ /**
1659
+ * Codespark - A browser-based React code playground with live preview.
1660
+ *
1661
+ * This component integrates a code editor, file explorer, and preview area
1662
+ * to provide a complete interactive code demonstration experience.
1663
+ * Supports both single-file mode (via `code` prop) and multi-file mode (via `files` prop).
1664
+ */
1665
+ function Codespark(props) {
1666
+ const { code, files, name = "./App.tsx", theme, editor, framework = "react", showEditor = true, showPreview = true, showFileExplorer = true, readonly: readOnly, className, toolbox, tailwindcss: tailwindcss$1, onConsole, onError, children, defaultExpanded, getWorkspace, editorHeight, previewHeight, orientation = "vertical" } = props;
1667
+ const { workspace, fileTree, compileError } = useWorkspace({
1668
+ entry: name,
1669
+ files: files ?? { [name]: code || "" },
1670
+ framework
1671
+ });
1672
+ const [runtimeError, setRuntimeError] = useState(null);
1673
+ const [expanded, setExpanded] = useState(defaultExpanded ?? fileTree.length > 1);
1674
+ const renderEditor = () => {
1675
+ const sharedProps = {
1676
+ containerProps: { className: "w-0 flex-1" },
1677
+ toolbox: toolbox ?? [
1678
+ "reset",
1679
+ "format",
1680
+ {
1681
+ tooltip: "Toggle File Explorer",
1682
+ icon: /* @__PURE__ */ jsx(Maximize, { className: "size-3.5!" }),
1683
+ onClick: () => setExpanded((v) => !v)
1684
+ },
1685
+ "copy"
1686
+ ],
1687
+ onChange: () => {
1688
+ setRuntimeError(null);
1689
+ }
1690
+ };
1691
+ if (editor?.kind === EditorEngine.Monaco) return /* @__PURE__ */ jsx(CodesparkEditor, {
1692
+ editor,
1693
+ ...sharedProps,
1694
+ height: editorHeight,
1695
+ options: { readOnly }
1696
+ });
1697
+ const height = editorHeight ? typeof editorHeight === "string" ? editorHeight : `${editorHeight}px` : void 0;
1698
+ return /* @__PURE__ */ jsx(CodesparkEditor, {
1699
+ editor,
1700
+ ...sharedProps,
1701
+ height,
1702
+ readOnly
1703
+ });
1704
+ };
1705
+ useEffect(() => {
1706
+ setRuntimeError(compileError);
1707
+ }, [compileError]);
1708
+ useEffect(() => {
1709
+ if (getWorkspace) getWorkspace.current = workspace;
1710
+ }, []);
1711
+ return /* @__PURE__ */ jsx(CodesparkProvider, {
1712
+ workspace,
1713
+ theme,
1714
+ children: /* @__PURE__ */ jsxs("div", {
1715
+ className: cn("border-border relative grid w-full overflow-hidden rounded-lg border", orientation === "horizontal" && "grid-cols-[2fr_1fr]", className),
1716
+ children: [/* @__PURE__ */ jsxs("div", {
1717
+ className: cn("border-border relative", showPreview && showEditor ? orientation === "vertical" ? "border-b" : "border-l" : "", orientation === "horizontal" && "order-2"),
1718
+ children: [showPreview ? /* @__PURE__ */ jsx(CodesparkPreview, {
1719
+ tailwindcss: tailwindcss$1,
1720
+ onConsole,
1721
+ onError: (error) => {
1722
+ onError?.(error);
1723
+ setRuntimeError(error);
1724
+ },
1725
+ height: previewHeight,
1726
+ children
1727
+ }) : null, runtimeError ? /* @__PURE__ */ jsxs("div", {
1728
+ className: "bg-background absolute inset-0 z-20 overflow-auto p-6",
1729
+ children: [/* @__PURE__ */ jsx("div", {
1730
+ className: "text-2xl text-red-500",
1731
+ children: runtimeError.name
1732
+ }), /* @__PURE__ */ jsx("div", {
1733
+ className: "mt-3 font-mono",
1734
+ children: runtimeError.stack || runtimeError.message
1735
+ })]
1736
+ }) : null]
1737
+ }), showEditor ? /* @__PURE__ */ jsxs("div", {
1738
+ className: cn("flex h-full w-full divide-x", orientation === "horizontal" && "order-1"),
1739
+ children: [expanded && showFileExplorer ? /* @__PURE__ */ jsx(CodesparkFileExplorer, {}) : null, renderEditor()]
1740
+ }) : null]
1741
+ })
1742
+ });
1743
+ }
1744
+ const useMDXComponents = () => {
1745
+ return {
1746
+ Codespark,
1747
+ CodesparkEditor,
1748
+ CodesparkPreview
1749
+ };
1750
+ };
1751
+
1752
+ //#endregion
1753
+ export { Codespark, CodesparkEditor, CodesparkFileExplorer, CodesparkPreview, CodesparkProvider, ConfigProvider, EditorEngine, Link, Script, Style, Workspace, createWorkspace, useMDXComponents, useWorkspace };