{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shell-error-panel",
  "title": "Error panel",
  "description": "Words a failed read or write by its problem kind, with a support reference and an optional retry button.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/lib-content",
    "@registrystack/lib-format",
    "@registrystack/lib-notice",
    "@registrystack/shell-content",
    "@registrystack/shell-page-heading",
    "@registrystack/ui-button"
  ],
  "files": [
    {
      "path": "shell/error-panel.tsx",
      "content": "import { useEffect, useRef } from \"react\";\nimport { problemView, refusalDetail } from \"@registrystack/app-runtime\";\nimport { Button } from \"@/components/ui/button\";\nimport { Notice } from \"@/blocks/lib/notice\";\nimport { useStandsAsPageTitle } from \"@/blocks/shell/page-heading\";\nimport { useShellContent } from \"@/blocks/shell/shell-content\";\n\nexport function ErrorPanel({\n  error,\n  retry,\n  unavailableTitle,\n  recordWrite,\n}: {\n  error: unknown;\n  retry?: () => void;\n  /** What is unavailable is called on this page, when not the default. */\n  unavailableTitle?: string;\n  /** The problem answers a record write, whose conflict is with the values sent. */\n  recordWrite?: boolean;\n}) {\n  const c = useShellContent();\n  const panel = useRef<HTMLDivElement>(null);\n  const problem = problemView(error);\n  const standsAsTitle = useStandsAsPageTitle();\n  useEffect(() => panel.current?.focus(), [error]);\n  // Typed Casework problems carry maintained user-facing sentences. Any\n  // other host answer uses local safe wording because its detail can carry\n  // facts that are not meant as page copy.\n  let title = c.serviceUnavailable,\n    body = c.serviceUnavailableBody;\n  if (problem.worded) {\n    // The registry's own words for a refused write, from its UI model.\n    title = c.registryRefusedTitle;\n    body = problem.message!;\n  } else if (problem.casework) {\n    title =\n      problem.kind === \"refused\"\n        ? c.caseworkRefusedTitle\n        : problem.kind === \"unavailable\"\n          ? (unavailableTitle ?? c.unavailable)\n          : problem.kind === \"stale\"\n            ? c.staleTitle\n            : problem.kind === \"conflict\"\n              ? c.conflictTitle\n              : c.serviceUnavailable;\n    // Casework words a missing source profile for the host, not the officer.\n    body =\n      refusalDetail(problem) === \"source-profile-required\"\n        ? c.sourceProfileRequired\n        : problem.message!;\n  } else if (problem.kind === \"refused\") {\n    title = c.refusedTitle;\n    body =\n      refusalDetail(problem) === \"outside-boundary\"\n        ? c.outsideBoundaryBody\n        : c.refusedBody;\n  } else if (problem.kind === \"contract-changed\") {\n    title = c.contractChangedTitle;\n    body = c.contractChangedBody;\n  } else if (problem.kind === \"session-ended\") {\n    title = c.expiredTitle;\n    body = c.expiredBody;\n  } else if (problem.kind === \"stale\" && problem.code === \"action.guard_failed\") {\n    // The record did not change under the person: the action is not allowed\n    // for it as it is now, and a reload shows the action unavailable.\n    title = c.actionUnavailableTitle;\n    body = c.actionUnavailableBody;\n  } else if (problem.kind === \"stale\") {\n    title = c.staleTitle;\n    body = c.staleBody;\n  } else if (\n    problem.kind === \"conflict\" &&\n    recordWrite &&\n    problem.code === \"action.conflict\"\n  ) {\n    // A record write has no request to move on; its values clash with a\n    // record or a rule. The registry does not say which, so neither do we.\n    // An expired or mismatched action, or a record that moved, is no value\n    // clash: the form must be reopened, so it keeps the conflict wording.\n    title = c.valuesConflictTitle;\n    body = c.valuesConflictBody;\n  } else if (problem.kind === \"conflict\") {\n    title = c.conflictTitle;\n    body = c.conflictBody;\n  } else if (problem.code === \"validation.failed\") {\n    title = c.invalidTitle;\n    body = c.invalidBody;\n  } else if (problem.kind === \"capacity\") {\n    title = c.capacityTitle;\n    body = c.capacityBody;\n  } else if (problem.kind === \"unavailable\") {\n    // What is unavailable has its own name on each page; the caller supplies\n    // it through `unavailableTitle` so this generic panel does not misname it.\n    title = unavailableTitle ?? c.unavailable;\n    body = c.unavailableBody;\n  }\n  return (\n    <div className=\"error-panel\" ref={panel} tabIndex={-1}>\n      <Notice tone=\"warning\">\n        {standsAsTitle ? (\n          <div role=\"heading\" aria-level={1} className=\"notice-title\">\n            {title}\n          </div>\n        ) : (\n          <h2>{title}</h2>\n        )}\n        <p>{body}</p>\n        {retry && (\n          <Button variant=\"outline\" onClick={retry}>\n            {c.retry}\n          </Button>\n        )}\n        {problem.supportReference && (\n          <details className=\"reference\">\n            <summary>{c.receipt}</summary>\n            <p>{c.receiptHelp}</p>\n            <p className=\"font-mono\">{problem.supportReference}</p>\n          </details>\n        )}\n      </Notice>\n    </div>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/shell/error-panel.tsx"
    }
  ],
  "type": "registry:block"
}