{"version":3,"file":"index.cjs","names":["FolderIcon","IS_MAC","KbdGroup","Kbd","Button","bundledThemesInfo","Combobox","loader","bundledThemes","Button","SaveIcon","IconButton","CollapseIcon","ExpandIcon","Editor","panelPopupStyle","FolderIcon","Tooltip","ToolbarButton","Popover"],"sources":["../src/fs.ts","../src/FolderAccessPrompt.tsx","../src/store.ts","../src/PreviewSettings.tsx","../src/highlight.ts","../src/monaco.ts","../src/styles.ts","../src/utils.ts","../src/SourcePreview.tsx","../src/index.tsx"],"sourcesContent":["export interface FileSystemService {\n  /** Whether the File System Access API is available in this browser */\n  isSupported: boolean\n  /** Whether the user has already granted directory access */\n  hasAccess: boolean\n  /**\n   * Silently try to restore a previously granted directory handle from\n   * IndexedDB and re-request permission. Resolves true if successful.\n   * Call this on app mount to avoid prompting on every reload.\n   */\n  tryRestore(): Promise<boolean>\n  /**\n   * Prompt the user to pick the project root directory via showDirectoryPicker().\n   * The handle is persisted in IndexedDB for future sessions.\n   */\n  requestAccess(): Promise<boolean>\n  /**\n   * Subscribe to hasAccess changes (e.g. after requestAccess / tryRestore).\n   * Returns an unsubscribe function.\n   */\n  subscribe(listener: () => void): () => void\n  /**\n   * Read a file by its relative path (relative to the granted directory).\n   * If no access has been granted yet, triggers requestAccess() first.\n   */\n  read(relativePath: string): Promise<string>\n  /**\n   * Write content to a file by its relative path. Triggers requestAccess() if needed.\n   * Written files trigger HMR automatically in the dev server.\n   */\n  write(relativePath: string, content: string): Promise<void>\n}\n\n/**\n * Why the File System Access API can't be used, when it can't:\n * - `insecure-context`: `showDirectoryPicker` is only exposed in secure\n *   contexts (localhost or HTTPS). This is the common WSL case, where the dev\n *   server is reached via the VM's IP address (e.g. http://172.x.x.x:3000)\n *   rather than http://localhost — see issue #8.\n * - `unsupported-browser`: a non-Chromium browser (Firefox, Safari) that\n *   doesn't implement the File System Access API at all.\n */\nexport type FileSystemSupport =\n  | { supported: true }\n  | { supported: false; reason: 'insecure-context' | 'unsupported-browser' }\n\nexport function getFileSystemSupport(): FileSystemSupport {\n  if (typeof window === 'undefined')\n    return { supported: false, reason: 'unsupported-browser' }\n  // Read before the `in` check below: lib.dom types `showDirectoryPicker` as\n  // always-present, so that narrowing collapses `window` to `never` and any\n  // later `window.*` access stops type-checking.\n  const secureContext = window.isSecureContext\n  if ('showDirectoryPicker' in window) return { supported: true }\n  // The API is missing. In an insecure context it's stripped from `window`\n  // even on Chromium, so treat that as the more actionable reason.\n  if (!secureContext)\n    return { supported: false, reason: 'insecure-context' }\n  return { supported: false, reason: 'unsupported-browser' }\n}\n\nconst IDB_NAME = 'react-trace'\nconst IDB_STORE = 'handles'\nconst IDB_KEY = 'root-directory'\n\nfunction openDB(): Promise<IDBDatabase> {\n  return new Promise((resolve, reject) => {\n    const req = indexedDB.open(IDB_NAME, 1)\n    req.onupgradeneeded = () => req.result.createObjectStore(IDB_STORE)\n    req.onsuccess = () => resolve(req.result)\n    req.onerror = () => reject(req.error)\n  })\n}\n\nasync function saveHandle(handle: FileSystemDirectoryHandle): Promise<void> {\n  const db = await openDB()\n  return new Promise((resolve, reject) => {\n    const tx = db.transaction(IDB_STORE, 'readwrite')\n    tx.objectStore(IDB_STORE).put(handle, IDB_KEY)\n    tx.oncomplete = () => resolve()\n    tx.onerror = () => reject(tx.error)\n  })\n}\n\nasync function loadHandle(): Promise<FileSystemDirectoryHandle | null> {\n  try {\n    const db = await openDB()\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction(IDB_STORE, 'readonly')\n      const req = tx.objectStore(IDB_STORE).get(IDB_KEY)\n      req.onsuccess = () =>\n        resolve((req.result as FileSystemDirectoryHandle) ?? null)\n      req.onerror = () => reject(req.error)\n    })\n  } catch {\n    return null\n  }\n}\n\n/**\n * Traverses the directory handle tree to reach the target file.\n * Returns null if any segment of the path doesn't exist.\n */\nasync function getFileHandle(\n  dir: FileSystemDirectoryHandle,\n  relativePath: string,\n  create = false,\n): Promise<FileSystemFileHandle | null> {\n  const parts = relativePath.split('/').filter(Boolean)\n  if (parts.length === 0) return null\n\n  let current: FileSystemDirectoryHandle = dir\n\n  for (let i = 0; i < parts.length - 1; i++) {\n    try {\n      current = await current.getDirectoryHandle(parts[i]!, { create })\n    } catch {\n      return null\n    }\n  }\n\n  try {\n    return await current.getFileHandle(parts.at(-1)!, { create })\n  } catch {\n    return null\n  }\n}\n\nclass FileSystemServiceImpl implements FileSystemService {\n  private _handle: FileSystemDirectoryHandle | null = null\n  private _listeners = new Set<() => void>()\n\n  get isSupported(): boolean {\n    return getFileSystemSupport().supported\n  }\n\n  get hasAccess(): boolean {\n    return this._handle !== null\n  }\n\n  subscribe(listener: () => void): () => void {\n    this._listeners.add(listener)\n    return () => this._listeners.delete(listener)\n  }\n\n  private notify(): void {\n    this._listeners.forEach((l) => l())\n  }\n\n  async tryRestore(): Promise<boolean> {\n    if (!this.isSupported) return false\n    try {\n      const handle = await loadHandle()\n      if (!handle) return false\n      const perm = await handle.requestPermission({ mode: 'readwrite' })\n      if (perm === 'granted') {\n        this._handle = handle\n        this.notify()\n        return true\n      }\n    } catch {\n      // handle gone or permission denied — fall through\n    }\n    return false\n  }\n\n  async requestAccess(): Promise<boolean> {\n    if (!this.isSupported) return false\n    try {\n      const handle = await window.showDirectoryPicker({ mode: 'readwrite' })\n      await saveHandle(handle)\n      this._handle = handle\n      this.notify()\n      return true\n    } catch {\n      // User cancelled the picker\n      return false\n    }\n  }\n\n  /** Ensure we have access — try restore silently first, then prompt. */\n  private async ensureAccess(): Promise<boolean> {\n    if (this._handle) return true\n    const restored = await this.tryRestore()\n    if (restored) return true\n    return this.requestAccess()\n  }\n\n  async read(relativePath: string): Promise<string> {\n    const ok = await this.ensureAccess()\n    if (!ok || !this._handle)\n      throw new Error('[react-trace] File system access denied')\n\n    const file = await getFileHandle(this._handle, relativePath)\n    if (!file) throw new Error(`[react-trace] File not found: ${relativePath}`)\n\n    return (await file.getFile()).text()\n  }\n\n  async write(relativePath: string, content: string): Promise<void> {\n    const ok = await this.ensureAccess()\n    if (!ok || !this._handle)\n      throw new Error('[react-trace] File system access denied')\n\n    const file = await getFileHandle(this._handle, relativePath, true)\n    if (!file)\n      throw new Error(\n        `[react-trace] Cannot open file for writing: ${relativePath}`,\n      )\n\n    const writable = await file.createWritable()\n    await writable.write(content)\n    await writable.close()\n  }\n}\n\nexport const fileSystemService: FileSystemService = new FileSystemServiceImpl()\n","import { IS_MAC } from '@react-trace/core'\nimport { Button, FolderIcon, Kbd, KbdGroup } from '@react-trace/ui-components'\n\nimport { getFileSystemSupport } from './fs'\n\nexport function FolderAccessPrompt({\n  root,\n  onGrant,\n  onCancel,\n}: {\n  root: string | undefined\n  onGrant(): void\n  onCancel(): void\n}) {\n  const support = getFileSystemSupport()\n\n  // When the File System Access API isn't available, \"Grant access\" would\n  // silently do nothing (the native folder picker never opens). Explain why\n  // and how to fix it instead — this is what WSL users hit (issue #8).\n  if (!support.supported) {\n    return <UnsupportedPrompt reason={support.reason} onCancel={onCancel} />\n  }\n\n  return (\n    <div\n      style={{\n        display: 'flex',\n        flexDirection: 'column',\n        alignItems: 'center',\n        justifyContent: 'center',\n        gap: 12,\n        padding: '20px 16px',\n        height: '100%',\n        boxSizing: 'border-box',\n        textAlign: 'center',\n        fontFamily: 'system-ui, sans-serif',\n      }}\n    >\n      <span style={{ color: '#52525b' }}>\n        <FolderIcon />\n      </span>\n      <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>\n        <span style={{ fontSize: 13, fontWeight: 600, color: '#fafafa' }}>\n          Folder access needed\n        </span>\n        <span style={{ fontSize: 12, color: '#71717a', lineHeight: 1.5 }}>\n          {root ? (\n            <span style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>\n              <span>\n                The project root path will be copied to your clipboard. Navigate\n                to it in the folder picker.\n              </span>\n              {IS_MAC && (\n                <span>\n                  <KbdGroup>\n                    <Kbd>⌘</Kbd>\n                    <Kbd>⇧</Kbd>\n                    <Kbd>G</Kbd>\n                  </KbdGroup>\n                  <span> to paste the path directly.</span>\n                </span>\n              )}\n            </span>\n          ) : (\n            'Grant access to your project folder to preview source files.'\n          )}\n        </span>\n        {root && (\n          <span\n            style={{\n              fontSize: 11,\n              fontFamily: 'ui-monospace, monospace',\n              color: '#3b82f6',\n              wordBreak: 'break-all',\n            }}\n          >\n            {root}\n          </span>\n        )}\n      </div>\n      <div style={{ display: 'flex', gap: 8 }}>\n        <Button variant=\"secondary\" onClick={onCancel}>\n          Cancel\n        </Button>\n        <Button variant=\"primary\" onClick={onGrant}>\n          Grant access\n        </Button>\n      </div>\n    </div>\n  )\n}\n\nfunction UnsupportedPrompt({\n  reason,\n  onCancel,\n}: {\n  reason: 'insecure-context' | 'unsupported-browser'\n  onCancel(): void\n}) {\n  return (\n    <div\n      style={{\n        display: 'flex',\n        flexDirection: 'column',\n        alignItems: 'center',\n        justifyContent: 'center',\n        gap: 12,\n        padding: '20px 16px',\n        height: '100%',\n        boxSizing: 'border-box',\n        textAlign: 'center',\n        fontFamily: 'system-ui, sans-serif',\n      }}\n    >\n      <span style={{ color: '#52525b' }}>\n        <FolderIcon />\n      </span>\n      <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>\n        <span style={{ fontSize: 13, fontWeight: 600, color: '#fafafa' }}>\n          Folder access unavailable\n        </span>\n        <span style={{ fontSize: 12, color: '#71717a', lineHeight: 1.5 }}>\n          {reason === 'insecure-context' ? (\n            <span style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>\n              <span>\n                Source preview needs a secure context. Open the app from{' '}\n                <span\n                  style={{\n                    fontFamily: 'ui-monospace, monospace',\n                    color: '#3b82f6',\n                  }}\n                >\n                  http://localhost\n                </span>{' '}\n                (or HTTPS) rather than an IP address.\n              </span>\n              <span>\n                In WSL, reach the dev server via localhost instead of the VM's\n                IP.\n              </span>\n            </span>\n          ) : (\n            \"Your browser doesn't support the File System Access API. Use a Chromium-based browser such as Chrome or Edge.\"\n          )}\n        </span>\n      </div>\n      <Button variant=\"secondary\" onClick={onCancel}>\n        Close\n      </Button>\n    </div>\n  )\n}\n\n/**\n * Copies the root path to clipboard then calls requestAccess().\n */\nexport async function handleGrantAccess(\n  root: string,\n  requestAccess: () => Promise<boolean>,\n): Promise<boolean> {\n  await navigator.clipboard.writeText(root).catch(() => {})\n  return requestAccess()\n}\n","import type { TraceSettings } from '@react-trace/core'\nimport { settingsPluginAtom } from '@react-trace/core'\nimport type { WritableAtom } from 'jotai'\nimport type { BundledTheme } from 'shiki'\n\ndeclare module '@react-trace/core' {\n  interface TraceSettings {\n    preview?: {\n      disabled: boolean\n      theme: BundledTheme\n    }\n  }\n}\n\nexport const previewSettingsAtom = settingsPluginAtom(\n  'preview',\n) as WritableAtom<TraceSettings['preview'], [TraceSettings['preview']], void>\n","import { useWidgetPortalContainer } from '@react-trace/core'\nimport { Combobox } from '@react-trace/ui-components'\nimport { useAtom } from 'jotai'\nimport type { CSSProperties } from 'react'\nimport { useRef, useState } from 'react'\nimport type { BundledTheme } from 'shiki'\nimport { bundledThemesInfo } from 'shiki'\n\nimport { previewSettingsAtom } from './store'\n\nconst themes = bundledThemesInfo.map((theme) => ({\n  value: theme.id as BundledTheme,\n  label: theme.displayName,\n}))\n\nconst themesLookup = themes.reduce<\n  Record<(typeof themes)[number]['value'], (typeof themes)[number]>\n>(\n  (acc, theme) => {\n    acc[theme.value] = theme\n    return acc\n  },\n  {} as Record<(typeof themes)[number]['value'], (typeof themes)[number]>,\n)\n\nconst LABEL_STYLE: CSSProperties = {\n  fontSize: 12,\n  color: '#d4d4d8',\n  fontFamily: 'system-ui, sans-serif',\n}\n\nexport function PreviewSettings() {\n  const portalContainer = useWidgetPortalContainer()\n  const [themesOpen, setThemesOpen] = useState(false)\n\n  const [\n    previewSettings = { disabled: false, theme: 'one-dark-pro' },\n    setPreviewSettings,\n  ] = useAtom(previewSettingsAtom)\n\n  const anchorRef = useRef<HTMLDivElement>(null)\n\n  return (\n    <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>\n      <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>\n        <label style={LABEL_STYLE}>\n          <input\n            type=\"checkbox\"\n            checked={previewSettings.disabled ?? false}\n            onChange={(e) =>\n              setPreviewSettings({\n                ...previewSettings,\n                disabled: e.target.checked,\n              })\n            }\n          />{' '}\n          Code editing disabled\n        </label>\n      </div>\n      <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>\n        <label style={LABEL_STYLE}>Theme</label>\n        <Combobox.Root\n          value={themesLookup[previewSettings.theme]}\n          onValueChange={(theme) => {\n            if (theme) {\n              setPreviewSettings({ ...previewSettings, theme: theme.value })\n            }\n          }}\n          items={themes}\n          open={themesOpen}\n          onOpenChange={setThemesOpen}\n        >\n          <div ref={anchorRef}>\n            <Combobox.Trigger\n              onClick={(e) => e.stopPropagation()}\n              onKeyDown={(e) => e.stopPropagation()}\n            >\n              <Combobox.Input />\n            </Combobox.Trigger>\n          </div>\n\n          <Combobox.Portal container={portalContainer}>\n            <Combobox.Positioner\n              style={{ zIndex: 100000000, pointerEvents: 'auto' }}\n              anchor={anchorRef}\n            >\n              <Combobox.Popup>\n                <Combobox.Empty>No themes found</Combobox.Empty>\n                <Combobox.List\n                  style={{\n                    overscrollBehavior: 'contain',\n                    maxHeight: 500,\n                    overflowY: 'auto',\n                  }}\n                >\n                  {(option: (typeof themes)[number]) => (\n                    <Combobox.Item\n                      key={option.value}\n                      value={option}\n                      onClick={(e) => e.stopPropagation()}\n                    >\n                      <span>{option.label}</span>\n                    </Combobox.Item>\n                  )}\n                </Combobox.List>\n              </Combobox.Popup>\n            </Combobox.Positioner>\n          </Combobox.Portal>\n        </Combobox.Root>\n      </div>\n    </div>\n  )\n}\n","/** Injects the CSS animation for the highlighted source line — idempotent. */\nexport function ensureHighlightStyle() {\n  if (document.getElementById('react-trace-highlighted-line')) return\n\n  const style = document.createElement('style')\n  style.id = 'react-trace-highlighted-line'\n  style.textContent = `\n    .react-trace-highlighted-line {\n      background-color: rgba(0, 200, 255, 0.25);\n      animation: react-trace-highlight-flash 1.2s ease-out;\n    }\n\n    @keyframes react-trace-highlight-flash {\n      from { background-color: rgba(0, 200, 255, 0.6); }\n      to   { background-color: rgba(0, 200, 255, 0.25); }\n    }\n  `\n  document.head.appendChild(style)\n}\n","import { loader } from '@monaco-editor/react'\nimport type { Monaco } from '@monaco-editor/react'\nimport { shikiToMonaco } from '@shikijs/monaco'\nimport { bundledThemes, createHighlighter } from 'shiki'\n\n// Kick off the Monaco CDN download as soon as the plugin module is imported\nloader.init()\n\nexport const langs = ['typescript', 'javascript', 'graphql', 'css']\n\nexport const highlighterPromise = createHighlighter({\n  themes: Object.values(bundledThemes),\n  langs,\n})\n\n/**\n * Monaco `beforeMount` callback — disables the built-in TS/JS language server\n * (no project types available in the browser) and wires Shiki for highlighting.\n */\nexport function configureBefore(monaco: Monaco) {\n  const noValidation = {\n    noSemanticValidation: true,\n    noSyntaxValidation: true,\n  }\n  const { typescriptDefaults, javascriptDefaults } = monaco.languages.typescript\n\n  typescriptDefaults.setDiagnosticsOptions(noValidation)\n  javascriptDefaults.setDiagnosticsOptions(noValidation)\n\n  const compilerOptions = {\n    jsx: monaco.languages.typescript.JsxEmit.ReactJSX,\n    allowJs: true,\n  }\n  typescriptDefaults.setCompilerOptions(compilerOptions)\n  javascriptDefaults.setCompilerOptions(compilerOptions)\n\n  for (const id of langs) monaco.languages.register({ id })\n  highlighterPromise.then((h) => shikiToMonaco(h, monaco))\n}\n","export const LINE_HEIGHT = 19\nexport const INLINE_LINES = 12\nexport const INLINE_HEIGHT = INLINE_LINES * LINE_HEIGHT\nexport const EDITOR_WIDTH = 480\nexport const TOOLBAR_HEIGHT = 33\n","import type { Monaco } from '@monaco-editor/react'\nimport type { Uri } from 'monaco-types'\n\nexport function detectLanguage(fileName: string): string {\n  const ext = fileName.split('.').pop()?.toLowerCase() ?? ''\n  const map: Record<string, string> = {\n    ts: 'typescript',\n    tsx: 'typescript',\n    js: 'javascript',\n    jsx: 'javascript',\n    mjs: 'javascript',\n    cjs: 'javascript',\n  }\n  return map[ext] ?? 'plaintext'\n}\n\n/** Convert a file path (URL or absolute) to a monaco file:// URI. */\nexport function pathToUri(monaco: Monaco, path: string): Uri {\n  try {\n    const { pathname } = new URL(path)\n    return monaco.Uri.parse(`file://${pathname}`)\n  } catch {\n    const normalized = path.replace(/\\\\/g, '/')\n    return monaco.Uri.parse(\n      normalized.startsWith('/')\n        ? `file://${normalized}`\n        : `file:///${normalized}`,\n    )\n  }\n}\n","import Editor from '@monaco-editor/react'\nimport { useProjectRoot, useSelectedSource } from '@react-trace/core'\nimport {\n  Button,\n  CollapseIcon,\n  ExpandIcon,\n  IconButton,\n  panelPopupStyle,\n  SaveIcon,\n} from '@react-trace/ui-components'\nimport { useAtom } from 'jotai'\nimport type { editor } from 'monaco-types'\nimport { useRef, useState } from 'react'\n\nimport { FolderAccessPrompt, handleGrantAccess } from './FolderAccessPrompt'\nimport { fileSystemService } from './fs'\nimport { ensureHighlightStyle } from './highlight'\nimport { configureBefore } from './monaco'\nimport { previewSettingsAtom } from './store'\nimport {\n  EDITOR_WIDTH,\n  INLINE_HEIGHT,\n  LINE_HEIGHT,\n  TOOLBAR_HEIGHT,\n} from './styles'\nimport type { PreviewPluginOptions } from './types'\nimport { detectLanguage, pathToUri } from './utils'\n\ntype LoadState = 'needs-access' | 'loading' | 'ready'\n\ntype SourcePreviewProps = {\n  options: PreviewPluginOptions\n}\nexport function SourcePreview({ options }: SourcePreviewProps) {\n  let { theme = 'one-dark-pro', disabled = false } = options\n  const [persistedOptions, setPreviewSettings] = useAtom(previewSettingsAtom)\n  if (!persistedOptions) {\n    setPreviewSettings({ theme, disabled })\n  }\n  theme = persistedOptions?.theme || theme\n  disabled = persistedOptions?.disabled ?? disabled\n\n  const root = useProjectRoot()\n  const source = useSelectedSource()\n  const [expanded, setExpanded] = useState(false)\n  const [dirty, setDirty] = useState(false)\n  const [loadState, setLoadState] = useState<LoadState>(\n    fileSystemService.hasAccess ? 'loading' : 'needs-access',\n  )\n  const editorRef = useRef<editor.ICodeEditor>(null)\n\n  if (!source) return null\n\n  const currentPath = source.relativePath\n\n  const handleGrant = async () => {\n    const granted = await handleGrantAccess(root, () =>\n      fileSystemService.requestAccess(),\n    )\n    if (granted) setLoadState('loading')\n  }\n\n  const handleSave = () => {\n    const val = editorRef.current?.getValue()\n    if (val != null) {\n      fileSystemService\n        .write(currentPath, val)\n        .then(() => setDirty(false))\n        .catch(() => {})\n    }\n  }\n\n  const editorHeight = expanded\n    ? `calc(80vh - ${!disabled ? TOOLBAR_HEIGHT : 0}px)`\n    : INLINE_HEIGHT - (!disabled ? TOOLBAR_HEIGHT : 0)\n\n  const toolbar = !disabled ? (\n    <div\n      style={{\n        display: 'flex',\n        alignItems: 'center',\n        justifyContent: 'space-between',\n        height: TOOLBAR_HEIGHT,\n        padding: '0 10px',\n        borderBottom: '1px solid #27272a',\n        flexShrink: 0,\n      }}\n    >\n      <span\n        style={{\n          fontSize: 11,\n          fontFamily: 'ui-monospace, monospace',\n          color: '#52525b',\n        }}\n      >\n        {source.relativePath.split('/').slice(-2).join('/')}\n        <span style={{ color: '#3f3f46' }}>:{source.lineNumber}</span>\n      </span>\n      <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>\n        {dirty && (\n          <Button variant=\"accent\" onClick={handleSave} title=\"Save (⌘S)\">\n            <SaveIcon /> Save\n          </Button>\n        )}\n        <IconButton\n          onClick={() => setExpanded((prev) => !prev)}\n          title={expanded ? 'Collapse (Esc)' : 'Expand'}\n        >\n          {expanded ? <CollapseIcon /> : <ExpandIcon />}\n        </IconButton>\n      </div>\n    </div>\n  ) : null\n\n  const [dismissed, setDismissed] = useState(false)\n\n  const content =\n    loadState === 'needs-access' && !dismissed ? (\n      <FolderAccessPrompt\n        root={root}\n        onGrant={handleGrant}\n        onCancel={() => setDismissed(true)}\n      />\n    ) : (\n      <Editor\n        height={editorHeight}\n        width=\"100%\"\n        theme={theme}\n        options={{\n          readOnly: disabled,\n          minimap: { enabled: false },\n          lineNumbers: 'on',\n          scrollBeyondLastLine: false,\n          fontSize: 12,\n          lineHeight: LINE_HEIGHT,\n          folding: false,\n          glyphMargin: false,\n          automaticLayout: true,\n          padding: { top: 6, bottom: 6 },\n          fixedOverflowWidgets: true,\n        }}\n        beforeMount={configureBefore}\n        onMount={(editor, monaco) => {\n          editorRef.current = editor\n          if (!disabled) {\n            editor.addCommand(\n              monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS,\n              handleSave,\n            )\n            editor.addCommand(monaco.KeyCode.Escape, () => setExpanded(false))\n          }\n          editor.updateOptions({ theme })\n\n          const key = source.relativePath\n          const uri = pathToUri(monaco, key)\n\n          fileSystemService\n            .read(key)\n            .then((fileContent) => {\n              if (!monaco.editor.getModel(uri)) {\n                monaco.editor.createModel(fileContent, detectLanguage(key), uri)\n              }\n              const model = monaco.editor.getModel(uri)\n              if (model) {\n                const { lineNumber } = source\n                editor.setModel(model)\n                editor.revealLineInCenter(lineNumber)\n\n                ensureHighlightStyle()\n                const highlight = editor.createDecorationsCollection()\n                highlight.set([\n                  {\n                    range: new monaco.Range(lineNumber, 1, lineNumber, 1),\n                    options: {\n                      isWholeLine: true,\n                      className: 'react-trace-highlighted-line',\n                    },\n                  },\n                ])\n              }\n            })\n            .catch(() => {})\n        }}\n        onChange={() => setDirty(true)}\n        loading={\n          <div style={{ padding: '8px 12px', color: '#52525b', fontSize: 11 }}>\n            Loading…\n          </div>\n        }\n      />\n    )\n\n  // stopPropagation on keydown prevents Base UI's Menu from capturing letter\n  // keys for its typeahead navigation (which would swallow 'a', 'b', etc.)\n  const panel = (\n    <div\n      style={{\n        display: 'flex',\n        flexDirection: 'column',\n        width: '100%',\n        height: '100%',\n        background: '#18181b',\n        overflow: 'hidden',\n      }}\n      onKeyDown={(e) => e.stopPropagation()}\n    >\n      {toolbar}\n      {content}\n    </div>\n  )\n\n  if (!expanded) {\n    return (\n      <div onClick={(e) => e.stopPropagation()} style={{ width: EDITOR_WIDTH }}>\n        {panel}\n      </div>\n    )\n  }\n\n  return (\n    <div\n      ref={(el) => {\n        const parentElement = el?.parentElement?.parentElement\n        if (!parentElement) return\n        const transform = parentElement.style.transform\n        parentElement.style.transform = ''\n        return () => {\n          parentElement.style.transform = transform\n        }\n      }}\n      style={{\n        position: 'absolute',\n        inset: 0,\n        zIndex: 9999999,\n        display: 'flex',\n        alignItems: 'center',\n        justifyContent: 'center',\n      }}\n      onClick={() => setExpanded(false)}\n    >\n      <div\n        style={{\n          ...panelPopupStyle,\n          position: 'fixed',\n          top: '10vw',\n          left: '10vw',\n          overflow: 'hidden',\n          width: '80vw',\n          height: '80vh',\n        }}\n        onClick={(e) => e.stopPropagation()}\n      >\n        {panel}\n      </div>\n    </div>\n  )\n}\n","import type { TracePlugin } from '@react-trace/core'\nimport {\n  useDeactivateInspector,\n  useProjectRoot,\n  useWidgetPortalContainer,\n} from '@react-trace/core'\nimport {\n  FolderIcon,\n  Popover,\n  ToolbarButton,\n  Tooltip,\n} from '@react-trace/ui-components'\nimport { useEffect, useRef, useState, useSyncExternalStore } from 'react'\n\nimport { FolderAccessPrompt, handleGrantAccess } from './FolderAccessPrompt'\nimport { fileSystemService } from './fs'\nimport { PreviewSettings } from './PreviewSettings'\nimport { SourcePreview } from './SourcePreview'\nimport type { PreviewPluginOptions } from './types'\n\nexport type { PreviewPluginOptions }\n\nfunction FolderToolbarIcon({ hasAccess }: { hasAccess: boolean }) {\n  return (\n    <span style={{ position: 'relative', display: 'inline-flex' }}>\n      <FolderIcon />\n      {hasAccess && (\n        <span\n          style={{\n            position: 'absolute',\n            top: -4,\n            right: -4,\n            width: 6,\n            height: 6,\n            borderRadius: '50%',\n            background: '#22c55e',\n            border: '1.5px solid #18181b',\n            pointerEvents: 'none',\n          }}\n        />\n      )}\n    </span>\n  )\n}\n\nfunction PreviewToolbar() {\n  const projectRoot = useProjectRoot()\n  const portalContainer = useWidgetPortalContainer()\n  const deactivateInspector = useDeactivateInspector()\n  const buttonRef = useRef<HTMLButtonElement>(null)\n  const [isPromptOpen, setIsPromptOpen] = useState(false)\n  const hasAccess = useSyncExternalStore(\n    fileSystemService.subscribe.bind(fileSystemService),\n    () => fileSystemService.hasAccess,\n    () => false,\n  )\n\n  // Silently try to restore a previously granted FS handle on mount\n  useEffect(() => {\n    fileSystemService.tryRestore().catch(() => {})\n  }, [])\n\n  const handleClick = () => {\n    deactivateInspector()\n\n    if (fileSystemService.hasAccess) {\n      fileSystemService.requestAccess().catch(() => {})\n      return\n    }\n\n    setIsPromptOpen(true)\n  }\n\n  const handleGrant = async () => {\n    const granted = await handleGrantAccess(projectRoot, () =>\n      fileSystemService.requestAccess(),\n    )\n    if (granted) setIsPromptOpen(false)\n  }\n\n  return (\n    <>\n      <Tooltip\n        label={hasAccess ? 'Project folder connected' : 'Select project folder'}\n        container={portalContainer}\n        render={<ToolbarButton ref={buttonRef} />}\n        aria-label=\"Project folder\"\n        style={{\n          color: hasAccess ? '#22c55e' : '#52525b',\n        }}\n        onClick={handleClick}\n      >\n        <FolderToolbarIcon hasAccess={hasAccess} />\n      </Tooltip>\n\n      <Popover.Root\n        open={isPromptOpen}\n        onOpenChange={(open: boolean) => {\n          if (!open) setIsPromptOpen(false)\n        }}\n      >\n        <Popover.Portal container={portalContainer}>\n          <Popover.Positioner\n            anchor={buttonRef.current}\n            side=\"top\"\n            align=\"end\"\n            sideOffset={8}\n            collisionPadding={8}\n            positionMethod=\"fixed\"\n            style={{ zIndex: 9999999, pointerEvents: 'auto' }}\n          >\n            <Popover.Popup\n              style={{ width: 280, overflow: 'hidden' }}\n              onClick={(event) => event.stopPropagation()}\n              onKeyDown={(event) => event.stopPropagation()}\n            >\n              <FolderAccessPrompt\n                root={projectRoot}\n                onGrant={handleGrant}\n                onCancel={() => setIsPromptOpen(false)}\n              />\n            </Popover.Popup>\n          </Popover.Positioner>\n        </Popover.Portal>\n      </Popover.Root>\n    </>\n  )\n}\n\nexport function PreviewPlugin(options: PreviewPluginOptions = {}): TracePlugin {\n  function PreviewActionPanel() {\n    return <SourcePreview options={options} />\n  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