{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "desktop-shell",
  "title": "Desktop Shell",
  "description": "Full Mac OS 9 desktop that fills its container: menu bar with clock and Application menu, desktop icons, overlapping draggable windows with click-to-front, and the Control Strip.",
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-app-switcher.json",
    "https://nostalgia-ui.com/r/retro-control-strip.json",
    "https://nostalgia-ui.com/r/retro-desktop.json",
    "https://nostalgia-ui.com/r/retro-dropdown-menu.json",
    "https://nostalgia-ui.com/r/retro-icons.json",
    "https://nostalgia-ui.com/r/retro-menu-bar.json",
    "https://nostalgia-ui.com/r/retro-textarea.json",
    "https://nostalgia-ui.com/r/retro-tree-view.json",
    "https://nostalgia-ui.com/r/retro-window.json"
  ],
  "files": [
    {
      "path": "registry/new-york/blocks/desktop-shell.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { RetroAppSwitcher } from \"@/registry/new-york/ui/retro-app-switcher\"\nimport {\n  RetroControlStrip,\n  RetroControlStripModule,\n} from \"@/registry/new-york/ui/retro-control-strip\"\nimport {\n  RetroDesktopArea,\n  RetroDesktopIcon,\n  RetroDesktopMenuBar,\n} from \"@/registry/new-york/ui/retro-desktop\"\nimport {\n  RetroDropdownMenuRadioGroup,\n  RetroDropdownMenuRadioItem,\n} from \"@/registry/new-york/ui/retro-dropdown-menu\"\nimport {\n  RetroIconApplication,\n  RetroIconDocument,\n  RetroIconFinder,\n  RetroIconFolder,\n  RetroIconHardDrive,\n  RetroIconTrash,\n} from \"@/registry/new-york/ui/retro-icons\"\nimport {\n  RetroMenuBar,\n  RetroMenuBarContent,\n  RetroMenuBarItem,\n  RetroMenuBarMenu,\n  RetroMenuBarRadioGroup,\n  RetroMenuBarRadioItem,\n  RetroMenuBarSeparator,\n  RetroMenuBarShortcut,\n  RetroMenuBarTrigger,\n} from \"@/registry/new-york/ui/retro-menu-bar\"\nimport { RetroTextarea } from \"@/registry/new-york/ui/retro-textarea\"\nimport {\n  RetroTreeView,\n  type RetroTreeViewColumn,\n  type TreeNode,\n} from \"@/registry/new-york/ui/retro-tree-view\"\nimport { RetroWindow } from \"@/registry/new-york/ui/retro-window\"\n\n/* ------------------------------------------------------------------ */\n/*  Types & data                                                       */\n/* ------------------------------------------------------------------ */\n\ntype ShellWindowId = \"finder\" | \"note\"\n\ninterface DesktopShellBlockProps extends React.HTMLAttributes<HTMLDivElement> {\n  /** Startup disk name: the hard disk icon and Finder window title. Defaults to \"Macintosh HD\". */\n  title?: string\n  /** Contents of the Finder window (Finder list view nodes). */\n  finderItems?: TreeNode[]\n  /** Text of the SimpleText \"Read Me\" note. */\n  noteText?: string\n  /** Extra windows or content rendered on the desktop, above the icons. */\n  children?: React.ReactNode\n}\n\nconst DEFAULT_ITEMS: TreeNode[] = [\n  {\n    id: \"apps\",\n    label: \"Applications\",\n    kind: \"folder\",\n    children: [\n      { id: \"simpletext\", label: \"SimpleText\", size: \"668K\", kind: \"application program\" },\n      { id: \"calc\", label: \"Graphing Calculator\", size: \"1.9 MB\", kind: \"application program\" },\n    ],\n  },\n  {\n    id: \"docs\",\n    label: \"Documents\",\n    kind: \"folder\",\n    children: [\n      { id: \"letter\", label: \"Letter to Grandma\", size: \"4K\", kind: \"SimpleText document\" },\n      { id: \"budget\", label: \"Budget 2002\", size: \"22K\", kind: \"AppleWorks document\" },\n    ],\n  },\n  { id: \"system\", label: \"System Folder\", kind: \"folder\", children: [] },\n  { id: \"readme\", label: \"Read Me\", size: \"12K\", kind: \"SimpleText document\" },\n]\n\nconst DEFAULT_NOTE = `Welcome to Mac OS 9!\n\nDrag windows by their title bars. Click a window to bring it to the front, or double-click its title bar to roll it up.\n\nDouble-click the hard disk icon to reopen the Finder window.`\n\nconst COLUMNS: RetroTreeViewColumn[] = [\n  { key: \"label\", header: \"Name\", width: \"minmax(120px,1fr)\" },\n  { key: \"size\", header: \"Size\", width: 56, align: \"right\", sortable: false },\n  { key: \"kind\", header: \"Kind\", width: 130 },\n]\n\n/* ------------------------------------------------------------------ */\n/*  Control Strip glyphs (16x16)                                       */\n/* ------------------------------------------------------------------ */\n\nfunction SpeakerGlyph() {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n      <path d=\"M2.5 6.5H5.5L9.5 3.5V12.5L5.5 9.5H2.5Z\" fill=\"var(--os9-gray-300)\" stroke=\"var(--os9-black)\" />\n      <path d=\"M11.5 6C12.2 6.8 12.2 9.2 11.5 10M13 4.5C14.5 6.5 14.5 9.5 13 11.5\" fill=\"none\" stroke=\"var(--os9-black)\" />\n    </svg>\n  )\n}\n\nfunction MonitorGlyph() {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n      <rect x=\"1.5\" y=\"2.5\" width=\"13\" height=\"9\" fill=\"var(--os9-gray-300)\" stroke=\"var(--os9-black)\" />\n      <rect x=\"3.5\" y=\"4.5\" width=\"9\" height=\"5\" fill=\"var(--os9-azul)\" />\n      <path d=\"M5.5 13.5H10.5\" stroke=\"var(--os9-black)\" />\n    </svg>\n  )\n}\n\nfunction NetworkGlyph() {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n      <rect x=\"1.5\" y=\"2.5\" width=\"5\" height=\"4\" fill=\"var(--os9-white)\" stroke=\"var(--os9-black)\" />\n      <rect x=\"9.5\" y=\"9.5\" width=\"5\" height=\"4\" fill=\"var(--os9-white)\" stroke=\"var(--os9-black)\" />\n      <path d=\"M4 6.5V11.5H9.5M12 9.5V4.5H6.5\" fill=\"none\" stroke=\"var(--os9-black)\" />\n    </svg>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Clock (client-only, avoids hydration mismatch)                     */\n/* ------------------------------------------------------------------ */\n\nfunction MenuBarClock() {\n  const [time, setTime] = React.useState(\"\")\n  React.useEffect(() => {\n    const format = () => {\n      const d = new Date()\n      const h = d.getHours()\n      return `${h % 12 || 12}:${String(d.getMinutes()).padStart(2, \"0\")} ${h >= 12 ? \"PM\" : \"AM\"}`\n    }\n    const update = () => setTime(format())\n    const first = setTimeout(update, 0)\n    const timer = setInterval(update, 15_000)\n    return () => {\n      clearTimeout(first)\n      clearInterval(timer)\n    }\n  }, [])\n  return (\n    <span className=\"min-w-[52px] shrink-0 text-right tabular-nums @max-[420px]:hidden\" aria-live=\"off\">\n      {time}\n    </span>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  DesktopShellBlock                                                  */\n/* ------------------------------------------------------------------ */\n\nconst DesktopShellBlock = React.forwardRef<HTMLDivElement, DesktopShellBlockProps>(\n  function DesktopShellBlock(\n    {\n      title = \"Macintosh HD\",\n      finderItems = DEFAULT_ITEMS,\n      noteText = DEFAULT_NOTE,\n      className,\n      children,\n      ...props\n    },\n    ref\n  ) {\n    /* Window stack: last id is frontmost. */\n    const [stack, setStack] = React.useState<ShellWindowId[]>([\"finder\", \"note\"])\n    const bringToFront = (id: ShellWindowId) =>\n      setStack((s) => (s[s.length - 1] === id ? s : [...s.filter((x) => x !== id), id]))\n    const close = (id: ShellWindowId) => setStack((s) => s.filter((x) => x !== id))\n\n    const [hidden, setHidden] = React.useState<ShellWindowId[]>([])\n    const [selectedIcon, setSelectedIcon] = React.useState<string | null>(null)\n    const [finderView, setFinderView] = React.useState(\"list\")\n    const [volume, setVolume] = React.useState(\"4\")\n    const [depth, setDepth] = React.useState(\"millions\")\n    const [appleTalk, setAppleTalk] = React.useState(\"on\")\n\n    const visible = stack.filter((id) => !hidden.includes(id))\n    const front = visible[visible.length - 1] as ShellWindowId | undefined\n    const activeApp = front === \"note\" ? \"simpletext\" : \"finder\"\n\n    const open = (id: ShellWindowId) => {\n      setHidden((h) => h.filter((x) => x !== id))\n      bringToFront(id)\n    }\n\n    const iconAction: Record<string, () => void> = {\n      hd: () => open(\"finder\"),\n      readme: () => open(\"note\"),\n    }\n\n    const windowFrame = (id: ShellWindowId) => ({\n      style: { zIndex: 10 + stack.indexOf(id) },\n      onPointerDownCapture: () => bringToFront(id),\n      onFocusCapture: () => bringToFront(id),\n    })\n\n    return (\n      <div\n        ref={ref}\n        className={cn(\n          \"@container relative flex h-full min-h-[420px] w-full flex-col overflow-hidden bg-os9-gray-200\",\n          className\n        )}\n        {...props}\n      >\n        {/* ---------------- Menu bar ---------------- */}\n        <RetroDesktopMenuBar showClock={false} className=\"relative z-[100] pr-0\">\n          <RetroMenuBar className=\"h-[19px] min-w-0 gap-0 overflow-hidden border-0 bg-transparent px-0 shadow-none\">\n            <RetroMenuBarMenu>\n              <RetroMenuBarTrigger className=\"h-[19px] px-[7px] font-bold\">File</RetroMenuBarTrigger>\n              <RetroMenuBarContent>\n                <RetroMenuBarItem disabled>\n                  New Folder<RetroMenuBarShortcut>⌘N</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem\n                  disabled={!selectedIcon || !iconAction[selectedIcon]}\n                  onSelect={() => selectedIcon && iconAction[selectedIcon]?.()}\n                >\n                  Open<RetroMenuBarShortcut>⌘O</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem disabled={!front} onSelect={() => front && close(front)}>\n                  Close Window<RetroMenuBarShortcut>⌘W</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarSeparator />\n                <RetroMenuBarItem disabled>\n                  Get Info<RetroMenuBarShortcut>⌘I</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem disabled>\n                  Find…<RetroMenuBarShortcut>⌘F</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n              </RetroMenuBarContent>\n            </RetroMenuBarMenu>\n\n            <RetroMenuBarMenu>\n              <RetroMenuBarTrigger className=\"h-[19px] px-[7px]\">Edit</RetroMenuBarTrigger>\n              <RetroMenuBarContent>\n                <RetroMenuBarItem disabled>\n                  Undo<RetroMenuBarShortcut>⌘Z</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarSeparator />\n                <RetroMenuBarItem disabled>\n                  Cut<RetroMenuBarShortcut>⌘X</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem disabled>\n                  Copy<RetroMenuBarShortcut>⌘C</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem disabled>\n                  Paste<RetroMenuBarShortcut>⌘V</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarSeparator />\n                <RetroMenuBarItem disabled>\n                  Select All<RetroMenuBarShortcut>⌘A</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n              </RetroMenuBarContent>\n            </RetroMenuBarMenu>\n\n            <RetroMenuBarMenu>\n              <RetroMenuBarTrigger className=\"h-[19px] px-[7px]\">View</RetroMenuBarTrigger>\n              <RetroMenuBarContent>\n                <RetroMenuBarRadioGroup value={finderView} onValueChange={setFinderView}>\n                  <RetroMenuBarRadioItem value=\"list\">as List</RetroMenuBarRadioItem>\n                  <RetroMenuBarRadioItem value=\"plain\">as Plain List</RetroMenuBarRadioItem>\n                </RetroMenuBarRadioGroup>\n              </RetroMenuBarContent>\n            </RetroMenuBarMenu>\n\n            <RetroMenuBarMenu>\n              <RetroMenuBarTrigger className=\"h-[19px] px-[7px] @max-[480px]:hidden\">Special</RetroMenuBarTrigger>\n              <RetroMenuBarContent>\n                <RetroMenuBarItem disabled>Empty Trash…</RetroMenuBarItem>\n                <RetroMenuBarItem disabled>\n                  Eject<RetroMenuBarShortcut>⌘E</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarSeparator />\n                <RetroMenuBarItem>Sleep</RetroMenuBarItem>\n                <RetroMenuBarItem>Restart</RetroMenuBarItem>\n                <RetroMenuBarItem>Shut Down</RetroMenuBarItem>\n              </RetroMenuBarContent>\n            </RetroMenuBarMenu>\n\n            <RetroMenuBarMenu>\n              <RetroMenuBarTrigger className=\"h-[19px] px-[7px] @max-[480px]:hidden\">Help</RetroMenuBarTrigger>\n              <RetroMenuBarContent>\n                <RetroMenuBarItem>\n                  Mac Help<RetroMenuBarShortcut>⌘?</RetroMenuBarShortcut>\n                </RetroMenuBarItem>\n                <RetroMenuBarItem>Show Balloons</RetroMenuBarItem>\n              </RetroMenuBarContent>\n            </RetroMenuBarMenu>\n          </RetroMenuBar>\n\n          <div className=\"ml-auto flex h-full shrink-0 items-center gap-[8px]\">\n            <MenuBarClock />\n            <RetroAppSwitcher\n              apps={[\n                { id: \"finder\", name: \"Finder\", icon: <RetroIconFinder size=\"sm\" /> },\n                {\n                  id: \"simpletext\",\n                  name: \"SimpleText\",\n                  icon: <RetroIconApplication size=\"sm\" />,\n                  hidden: hidden.includes(\"note\"),\n                },\n              ]}\n              activeApp={activeApp}\n              onActiveAppChange={(app) => open(app === \"simpletext\" ? \"note\" : \"finder\")}\n              onHide={(app) =>\n                setHidden((h) => [...h, app === \"simpletext\" ? \"note\" : \"finder\"])\n              }\n              onHideOthers={(app) => setHidden(app === \"simpletext\" ? [\"finder\"] : [\"note\"])}\n              onShowAll={() => setHidden([])}\n              className=\"@max-[560px]:[&>span:last-child]:hidden\"\n            />\n          </div>\n        </RetroDesktopMenuBar>\n\n        {/* ---------------- Desktop ---------------- */}\n        <RetroDesktopArea\n          style={{\n            backgroundColor: \"var(--os9-lavender)\",\n            backgroundImage: \"radial-gradient(var(--os9-focus) 0.7px, transparent 0.7px)\",\n            backgroundSize: \"4px 4px\",\n          }}\n          onClick={(e) => {\n            if (e.target === e.currentTarget) setSelectedIcon(null)\n          }}\n        >\n          {/* Icons along the right edge */}\n          <div className=\"absolute right-[8px] top-[8px] z-[1] flex flex-col items-center gap-[6px]\">\n            {[\n              { id: \"hd\", label: title, icon: <RetroIconHardDrive /> },\n              { id: \"docs\", label: \"Documents\", icon: <RetroIconFolder /> },\n              { id: \"readme\", label: \"Read Me\", icon: <RetroIconDocument /> },\n            ].map((icon) => (\n              <RetroDesktopIcon\n                key={icon.id}\n                icon={icon.icon}\n                label={icon.label}\n                selected={selectedIcon === icon.id}\n                onSelect={() => setSelectedIcon(icon.id)}\n                onDoubleClick={() => iconAction[icon.id]?.()}\n                onKeyDown={(e) => {\n                  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === \"o\") {\n                    e.preventDefault()\n                    iconAction[icon.id]?.()\n                  }\n                }}\n              />\n            ))}\n          </div>\n          <RetroDesktopIcon\n            icon={<RetroIconTrash />}\n            label=\"Trash\"\n            selected={selectedIcon === \"trash\"}\n            onSelect={() => setSelectedIcon(\"trash\")}\n            className=\"absolute bottom-[8px] right-[8px] z-[1]\"\n          />\n\n          {/* Finder window */}\n          {visible.includes(\"finder\") && (\n            <div className=\"absolute left-[16px] top-[16px]\" {...windowFrame(\"finder\")}>\n              <RetroWindow\n                title={title}\n                active={front === \"finder\"}\n                draggable\n                resizable\n                minWidth={220}\n                minHeight={140}\n                onClose={() => close(\"finder\")}\n                contentClassName=\"flex flex-col p-0\"\n                className=\"h-[260px] w-[min(440px,calc(100cqw-120px))] min-w-[220px]\"\n              >\n                <p className=\"shrink-0 border-b border-os9-black py-[3px] text-center font-[family-name:var(--os9-font-sans)] text-[10px] text-os9-black\">\n                  {finderItems.length} items, 1.2 GB available\n                </p>\n                <RetroTreeView\n                  aria-label={title}\n                  items={finderItems}\n                  columns={finderView === \"list\" ? COLUMNS : undefined}\n                  defaultSort={{ column: \"label\", direction: \"asc\" }}\n                  className=\"min-h-0 flex-1 border-0 pb-[15px] shadow-none\"\n                  onActivate={(node) => {\n                    if (node.id === \"readme\") open(\"note\")\n                  }}\n                />\n              </RetroWindow>\n            </div>\n          )}\n\n          {/* SimpleText note */}\n          {visible.includes(\"note\") && (\n            <div\n              className=\"absolute left-[max(24px,min(260px,calc(100cqw-380px)))] top-[120px]\"\n              {...windowFrame(\"note\")}\n            >\n              <RetroWindow\n                title=\"Read Me\"\n                active={front === \"note\"}\n                draggable\n                resizable\n                minWidth={200}\n                minHeight={120}\n                onClose={() => close(\"note\")}\n                contentClassName=\"flex p-0\"\n                className=\"h-[220px] w-[min(340px,calc(100cqw-120px))] min-w-[200px]\"\n              >\n                <RetroTextarea\n                  aria-label=\"Read Me\"\n                  size=\"sm\"\n                  defaultValue={noteText}\n                  className=\"h-full min-h-0 resize-none border-0 pb-[18px] shadow-none focus:shadow-none\"\n                />\n              </RetroWindow>\n            </div>\n          )}\n\n          {children}\n\n          {/* Control Strip */}\n          <RetroControlStrip className=\"absolute bottom-[12px] left-0 z-[90]\">\n            <RetroControlStripModule\n              icon={<SpeakerGlyph />}\n              label=\"Sound Volume\"\n              menu={\n                <RetroDropdownMenuRadioGroup value={volume} onValueChange={setVolume}>\n                  {[\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\"].map((v) => (\n                    <RetroDropdownMenuRadioItem key={v} value={v}>\n                      {v === \"0\" ? \"Mute\" : `Level ${v}`}\n                    </RetroDropdownMenuRadioItem>\n                  ))}\n                </RetroDropdownMenuRadioGroup>\n              }\n            />\n            <RetroControlStripModule\n              icon={<MonitorGlyph />}\n              label=\"Monitor Bit Depth\"\n              menu={\n                <RetroDropdownMenuRadioGroup value={depth} onValueChange={setDepth}>\n                  <RetroDropdownMenuRadioItem value=\"256\">256 Colors</RetroDropdownMenuRadioItem>\n                  <RetroDropdownMenuRadioItem value=\"thousands\">Thousands</RetroDropdownMenuRadioItem>\n                  <RetroDropdownMenuRadioItem value=\"millions\">Millions</RetroDropdownMenuRadioItem>\n                </RetroDropdownMenuRadioGroup>\n              }\n            />\n            <RetroControlStripModule\n              icon={<NetworkGlyph />}\n              label=\"AppleTalk\"\n              menu={\n                <RetroDropdownMenuRadioGroup value={appleTalk} onValueChange={setAppleTalk}>\n                  <RetroDropdownMenuRadioItem value=\"on\">AppleTalk Active</RetroDropdownMenuRadioItem>\n                  <RetroDropdownMenuRadioItem value=\"off\">AppleTalk Inactive</RetroDropdownMenuRadioItem>\n                </RetroDropdownMenuRadioGroup>\n              }\n            />\n          </RetroControlStrip>\n        </RetroDesktopArea>\n      </div>\n    )\n  }\n)\nDesktopShellBlock.displayName = \"DesktopShellBlock\"\n\nexport { DesktopShellBlock }\nexport type { DesktopShellBlockProps }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:block"
}