{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shell-work-frame",
  "title": "Work frame",
  "description": "Resolves a route to its current place and wires the staff work shell's navigation and sign-out error to hash routing, with the app's accent, description and switch account.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/casework-work-shell",
    "@registrystack/shell-branding",
    "@registrystack/shell-content",
    "@registrystack/shell-error-panel",
    "@registrystack/shell-language-switch",
    "@registrystack/shell-routing",
    "@registrystack/shell-sign-out"
  ],
  "files": [
    {
      "path": "shell/work-frame.tsx",
      "content": "import { useMemo, type ReactNode } from \"react\";\nimport {\n  WorkShell as BlockWorkShell,\n  currentPlace,\n  type NavGroup,\n} from \"@/blocks/casework/work-shell\";\nimport { useEndSession } from \"@registrystack/app-runtime/react\";\nimport { useBranding } from \"@/blocks/shell/branding\";\nimport { ErrorPanel } from \"@/blocks/shell/error-panel\";\nimport {\n  LanguageMenuGroup,\n  useOfferedLanguages,\n} from \"@/blocks/shell/language-switch\";\nimport { splitRoute } from \"@/blocks/shell/routing\";\nimport { useShellContent } from \"@/blocks/shell/shell-content\";\nimport { switchAccount } from \"@/blocks/shell/sign-out\";\n\n/**\n * Resolves a route to the current place and wires the staff work shell's\n * navigation and sign-out error to hash routing. It applies the UI model's\n * accent, shows its app description, and offers the UI model's languages and\n * switching account into the session's own app. Which places exist for a\n * session, and which one its root route stands for, are the caller's own\n * decisions; this block only works out which of the given places the\n * current route is under.\n */\nexport function WorkFrame({\n  displayName,\n  app,\n  brand,\n  groups,\n  homePath,\n  route,\n  children,\n}: {\n  displayName?: string;\n  /** The id of the app the session signs in to; switching account returns to it. */\n  app?: string;\n  brand: string;\n  groups: NavGroup[];\n  /** The place the root route stands for, so it is marked current there. */\n  homePath: string;\n  route: string;\n  children: ReactNode;\n}) {\n  const c = useShellContent();\n  const branding = useBranding();\n  const languages = useOfferedLanguages();\n  const endSession = useEndSession();\n  const items = useMemo(() => groups.flat(), [groups]);\n  const { path: routePath, query } = splitRoute(route);\n  // A form opened from a page, or one that returns to it, belongs to that\n  // page's place, however that page was narrowed.\n  const openedFrom = query.get(\"return\") ?? query.get(\"back\");\n  const placePath =\n    openedFrom && /^\\/(?![/\\\\])/.test(openedFrom)\n      ? splitRoute(openedFrom).path\n      : routePath;\n  const current = currentPlace(items, placePath === \"/\" ? homePath : placePath);\n  return (\n    <BlockWorkShell\n      displayName={displayName}\n      brand={brand}\n      description={branding.description}\n      accountChoices={languages && <LanguageMenuGroup {...languages} />}\n      switchAccount={\n        app === undefined\n          ? undefined\n          : {\n              label: c.switchAccount,\n              run: () =>\n                switchAccount(endSession, (url) => window.location.assign(url), app),\n            }\n      }\n      groups={groups}\n      current={current}\n      route={route}\n      hrefFor={(path) => `#${path}`}\n      navigate={(path) => {\n        location.hash = path;\n      }}\n      renderSignOutError={(error) => <ErrorPanel error={error} />}\n    >\n      {children}\n    </BlockWorkShell>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/shell/work-frame.tsx"
    }
  ],
  "type": "registry:block"
}