{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-workflow-builder",
  "type": "registry:block",
  "title": "Workflow builder",
  "description": "Building an automation on a raised page: steps on a canvas joined by lines with a + to insert one, a condition that splits the flow, the selected step’s settings in a panel beside it, and a switch that turns the workflow on once every step is complete.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/app-shell.json",
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/breadcrumbs.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/divider.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/form-field.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/select.json",
    "https://wideset.co/r/sidebar.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/status-modal.json",
    "https://wideset.co/r/switch.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/textarea.json",
    "https://wideset.co/r/toast.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/workflow-builder/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/brand-mark.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nconst TILE =\n  'M0 16C0 8.45753 0 4.68629 2.34315 2.34315C4.68629 0 8.45753 0 16 0C23.5425 0 27.3137 0 29.6569 2.34315C32 4.68629 32 8.45753 32 16C32 23.5425 32 27.3137 29.6569 29.6569C27.3137 32 23.5425 32 16 32C8.45753 32 4.68629 32 2.34315 29.6569C0 27.3137 0 23.5425 0 16Z';\n\n/**\n * Orbit's mark: a planet and its ring on the inverse tile, so it inverts in dark mode. It takes\n * the size of its place (32px in a sidebar, 36px in a larger switcher). Decorative beside the\n * product's name; give it a `label` when it stands alone.\n */\nexport function BrandMark({ className, label }: { className?: string; label?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 32 32\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn('size-ws-14 shrink-0', className)}\n    >\n      <path d={TILE} className=\"fill-(--ws-static-fill-inverse-background)\" />\n      <ellipse\n        cx=\"16\"\n        cy=\"16\"\n        rx=\"10.5\"\n        ry=\"4\"\n        transform=\"rotate(-28 16 16)\"\n        strokeWidth=\"1.75\"\n        className=\"fill-none stroke-(--ws-static-text-inverse-strong)\"\n      />\n      <circle cx=\"16\" cy=\"16\" r=\"4.75\" className=\"fill-(--ws-static-text-inverse-strong)\" />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/connector.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/connector.tsx",
      "content": "'use client';\n\n// TODO(custom): the lines that join steps on a canvas (straight, and the elbow where a condition splits); Wideset has no flow connector.\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { StepKind } from './data';\nimport { InsertMenu } from './insert-menu';\n\n/**\n * A vertical piece of line, as tall as its class makes it. Connectors are drawn in the border\n * grey, never black, so the steps stay the heaviest thing; the stroke stays 1px at any zoom.\n */\nexport function Line({ className }: { className?: string }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 2 10\"\n      preserveAspectRatio=\"none\"\n      className={cn('w-ws-2 shrink-0 overflow-visible', className)}\n    >\n      <line\n        x1=\"1\"\n        y1=\"0\"\n        x2=\"1\"\n        y2=\"10\"\n        vectorEffect=\"non-scaling-stroke\"\n        className=\"stroke-(--ws-static-stroke-base)\"\n      />\n    </svg>\n  );\n}\n\n/**\n * Where a condition splits: half of the bar across the two branches and the drop into this one.\n * The two branch columns touch, so their halves meet under the condition.\n */\nexport function Elbow({ side }: { side: 'left' | 'right' }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 100 10\"\n      preserveAspectRatio=\"none\"\n      className=\"h-ws-7 w-full shrink-0 overflow-visible\"\n    >\n      <path\n        d={side === 'left' ? 'M50 10 V0 H100' : 'M0 0 H50 V10'}\n        fill=\"none\"\n        vectorEffect=\"non-scaling-stroke\"\n        className=\"stroke-(--ws-static-stroke-base)\"\n      />\n    </svg>\n  );\n}\n\n/**\n * The line into a step with its \"+\" in the middle. At the end of a line (`end`) it stops at the\n * \"+\", which then adds the line's last step.\n */\nexport function Connector({\n  label,\n  end = false,\n  onInsert,\n}: {\n  label: string;\n  end?: boolean;\n  onInsert: (kind: StepKind) => void;\n}) {\n  return (\n    <div className=\"flex flex-col items-center\">\n      <Line className=\"h-ws-9\" />\n      <InsertMenu label={label} onInsert={onInsert} />\n      {!end && <Line className=\"h-ws-9\" />}\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBankCardLine,\n  RiContactsBook3Line,\n  RiFlashlightFill,\n  RiFlashlightLine,\n  RiGitBranchLine,\n  RiHandCoinLine,\n  RiHome5Line,\n  RiHourglass2Line,\n  RiInbox2Line,\n  RiKey2Line,\n  RiLineChartLine,\n  RiMailLine,\n  RiPieChart2Line,\n  RiPlugLine,\n  RiQuestionLine,\n  RiSettings3Line,\n  RiSlackLine,\n  RiTaskLine,\n  RiTeamLine,\n} from '@remixicon/react';\n\n/*\n  One automation in Orbit, still a draft: when a deal moves to Negotiation, a condition on the\n  amount splits it. Deals of $25,000 or more message the owner's manager in Slack and give the\n  manager a review task; smaller ones give the owner a task and e-mail the manager a summary, whose\n  template nobody has picked yet. That one missing field keeps the workflow from being turned on.\n*/\n\n/** The product is Orbit; the workspace is Lumen Studio. */\nexport const product = { name: 'Orbit' };\nexport const workspace = { name: 'Lumen Studio', initials: 'LS' };\nexport const account = { name: 'Maya Okafor', email: 'maya@lumenstudio.co', initials: 'MO' };\n\nexport type NavLink = {\n  id: string;\n  label: string;\n  icon: RemixiconComponentType;\n  /** The icon while the page is open (a line icon swaps for its fill). */\n  activeIcon?: RemixiconComponentType;\n};\n\nexport const mainLinks: NavLink[] = [\n  { id: 'home', label: 'Home', icon: RiHome5Line },\n  { id: 'inbox', label: 'Inbox', icon: RiInbox2Line },\n  { id: 'customers', label: 'Customers', icon: RiContactsBook3Line },\n  { id: 'deals', label: 'Deals', icon: RiHandCoinLine },\n  { id: 'revenue', label: 'Revenue', icon: RiLineChartLine },\n  { id: 'reports', label: 'Reports', icon: RiPieChart2Line },\n  {\n    id: 'automations',\n    label: 'Automations',\n    icon: RiFlashlightLine,\n    activeIcon: RiFlashlightFill,\n  },\n];\n\nexport const settingsLinks: NavLink[] = [\n  { id: 'general', label: 'General', icon: RiSettings3Line },\n  { id: 'members', label: 'Members', icon: RiTeamLine },\n  { id: 'billing', label: 'Billing', icon: RiBankCardLine },\n  { id: 'integrations', label: 'Integrations', icon: RiPlugLine },\n  { id: 'api-keys', label: 'API keys', icon: RiKey2Line },\n];\n\nexport const helpLink: NavLink = { id: 'help', label: 'Help and support', icon: RiQuestionLine };\n\nexport type StepKind = 'trigger' | 'condition' | 'email' | 'slack' | 'task' | 'wait';\n\n/** A step of the workflow. A condition ends its sequence: what follows sits on its branches. */\nexport type Step = {\n  id: string;\n  kind: StepKind;\n  /** The step's settings, by field name; an empty string is a field not filled in yet. */\n  fields: Record<string, string>;\n  /** A condition's branches: the steps when it holds, and when it does not. */\n  yes?: Step[];\n  no?: Step[];\n};\n\ntype Option = { value: string; label: string };\n\nexport type Field = {\n  name: string;\n  label: string;\n  control: 'select' | 'text' | 'textarea';\n  options?: Option[];\n  placeholder?: string;\n  helperText?: string;\n  /** Says how to fill the field in; set on the fields a step cannot run without. */\n  missing?: string;\n  /** For a required field, whether what was typed is usable; empty is never usable. */\n  valid?: (text: string) => boolean;\n};\n\nexport type StepType = {\n  /** What the step does, as the insert menu and the node name it. */\n  label: string;\n  /** One line under the panel's title: what the step is for. */\n  description: string;\n  icon: RemixiconComponentType;\n  fields: Field[];\n  /** The settings a new step starts with. */\n  defaults: Record<string, string>;\n  /** The node's line: what this step does with its settings. */\n  summary: (fields: Record<string, string>) => string;\n};\n\nexport const STAGES: Option[] = [\n  { value: 'qualified', label: 'Qualified' },\n  { value: 'discovery', label: 'Discovery' },\n  { value: 'proposal', label: 'Proposal' },\n  { value: 'negotiation', label: 'Negotiation' },\n  { value: 'commit', label: 'Commit' },\n  { value: 'won', label: 'Closed won' },\n  { value: 'lost', label: 'Closed lost' },\n];\n\nconst PEOPLE: Option[] = [\n  { value: 'owner', label: 'Deal owner' },\n  { value: 'manager', label: 'Owner’s manager' },\n];\n\n/** The same people inside a sentence on a node. */\nconst WHO: Record<string, string> = {\n  owner: 'the deal owner',\n  manager: 'the owner’s manager',\n  contact: 'the customer contact',\n  'deal-desk': '#deal-desk',\n};\n\nconst RULES: Option[] = [\n  { value: 'gte', label: 'Is at least' },\n  { value: 'lt', label: 'Is less than' },\n];\n\nconst DURATIONS: Option[] = [\n  { value: '1h', label: '1 hour' },\n  { value: '1d', label: '1 day' },\n  { value: '2d', label: '2 days' },\n  { value: '1w', label: '1 week' },\n];\n\nconst usd = new Intl.NumberFormat('en-US', {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n});\n\n/** The amount a condition compares with, from what was typed (\"25,000\", \"$25000\"). */\nexport const parseAmount = (text: string) => Number(text.replace(/[^0-9.]/g, '')) || 0;\n\nconst labelOf = (options: Option[], value: string) =>\n  options.find((option) => option.value === value)?.label ?? '';\n\n/** Every kind of step: its name, icon, settings and how its node reads. */\nexport const STEP_TYPES: Record<StepKind, StepType> = {\n  trigger: {\n    label: 'Trigger',\n    description: 'Starts the workflow when a deal changes stage.',\n    icon: RiFlashlightLine,\n    fields: [\n      { name: 'stage', label: 'Deal moves to', control: 'select', options: STAGES },\n      {\n        name: 'pipeline',\n        label: 'Pipeline',\n        control: 'select',\n        options: [\n          { value: 'new-business', label: 'New business' },\n          { value: 'renewals', label: 'Renewals' },\n          { value: 'any', label: 'Any pipeline' },\n        ],\n      },\n    ],\n    defaults: { stage: 'negotiation', pipeline: 'new-business' },\n    summary: (fields) => `Deal moves to ${labelOf(STAGES, fields.stage)}`,\n  },\n  condition: {\n    label: 'Condition',\n    description: 'Splits the workflow in two by the deal’s amount.',\n    icon: RiGitBranchLine,\n    fields: [\n      { name: 'rule', label: 'Deal amount', control: 'select', options: RULES },\n      {\n        name: 'amount',\n        label: 'Amount',\n        control: 'text',\n        placeholder: '25,000',\n        helperText: 'In US dollars, before discounts.',\n        missing: 'Enter an amount, like 25,000.',\n        valid: (text) => parseAmount(text) > 0,\n      },\n    ],\n    defaults: { rule: 'gte', amount: '' },\n    summary: (fields) =>\n      parseAmount(fields.amount)\n        ? `Amount ${labelOf(RULES, fields.rule).toLowerCase()} ${usd.format(parseAmount(fields.amount))}`\n        : 'Amount not set',\n  },\n  email: {\n    label: 'Send e-mail',\n    description: 'Sends an e-mail from Orbit in the owner’s name.',\n    icon: RiMailLine,\n    fields: [\n      {\n        name: 'to',\n        label: 'To',\n        control: 'select',\n        options: [...PEOPLE, { value: 'contact', label: 'Customer contact' }],\n      },\n      {\n        name: 'template',\n        label: 'Template',\n        control: 'select',\n        placeholder: 'Choose a template',\n        options: [\n          { value: 'summary', label: 'Deal summary' },\n          { value: 'handover', label: 'Handover to the manager' },\n          { value: 'pricing', label: 'Pricing approval request' },\n        ],\n        missing: 'Choose the template to send.',\n      },\n    ],\n    defaults: { to: 'manager', template: '' },\n    summary: (fields) => `E-mail ${WHO[fields.to]}`,\n  },\n  slack: {\n    label: 'Notify in Slack',\n    description: 'Posts a message in Slack, to a person or a channel.',\n    icon: RiSlackLine,\n    fields: [\n      {\n        name: 'to',\n        label: 'Send to',\n        control: 'select',\n        options: [...PEOPLE, { value: 'deal-desk', label: '#deal-desk' }],\n      },\n      {\n        name: 'message',\n        label: 'Message',\n        control: 'textarea',\n        placeholder: 'What should they know?',\n        missing: 'Write the message to send.',\n      },\n    ],\n    defaults: { to: 'manager', message: '' },\n    summary: (fields) => `Message ${WHO[fields.to]}`,\n  },\n  task: {\n    label: 'Create task',\n    description: 'Adds a task to someone’s list in Orbit.',\n    icon: RiTaskLine,\n    fields: [\n      {\n        name: 'title',\n        label: 'Task',\n        control: 'text',\n        placeholder: 'Call the customer',\n        missing: 'Name the task.',\n      },\n      { name: 'assignee', label: 'Assign to', control: 'select', options: PEOPLE },\n      {\n        name: 'due',\n        label: 'Due',\n        control: 'select',\n        options: [\n          { value: '1', label: 'In 1 day' },\n          { value: '2', label: 'In 2 days' },\n          { value: '7', label: 'In a week' },\n        ],\n      },\n    ],\n    defaults: { title: '', assignee: 'owner', due: '2' },\n    summary: (fields) => fields.title.trim() || 'Untitled task',\n  },\n  wait: {\n    label: 'Wait',\n    description: 'Pauses before the next step.',\n    icon: RiHourglass2Line,\n    fields: [\n      {\n        name: 'duration',\n        label: 'Wait for',\n        control: 'select',\n        options: DURATIONS,\n      },\n    ],\n    defaults: { duration: '1d' },\n    summary: (fields) => `Wait ${labelOf(DURATIONS, fields.duration)}`,\n  },\n};\n\n/** The steps the \"+\" on a line can insert, in the menu's order. */\nexport const INSERTABLE: StepKind[] = ['email', 'slack', 'task', 'wait', 'condition'];\n\nexport const initialName = 'Negotiation handover';\n\n/** The workflow as the page opens. */\nexport const initialFlow: Step[] = [\n  { id: 'trigger', kind: 'trigger', fields: { stage: 'negotiation', pipeline: 'new-business' } },\n  {\n    id: 'deal-size',\n    kind: 'condition',\n    fields: { rule: 'gte', amount: '25,000' },\n    yes: [\n      {\n        id: 'notify-manager',\n        kind: 'slack',\n        fields: {\n          to: 'manager',\n          message:\n            'A deal you oversee moved to Negotiation. Review the terms before the next call.',\n        },\n      },\n      {\n        id: 'review-terms',\n        kind: 'task',\n        fields: { title: 'Review the terms', assignee: 'manager', due: '2' },\n      },\n    ],\n    no: [\n      {\n        id: 'order-form',\n        kind: 'task',\n        fields: { title: 'Send the order form', assignee: 'owner', due: '1' },\n      },\n      { id: 'summary-email', kind: 'email', fields: { to: 'manager', template: '' } },\n    ],\n  },\n];\n\n/** The deal a test run uses: under $25,000, so it takes the No branch. */\nexport const sampleDeal = { name: 'Halcyon Freight renewal', amount: 24_000 };\n"
    },
    {
      "path": "src/blocks/workflow-builder/flow-node.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/flow-node.tsx",
      "content": "'use client';\n\n// TODO(custom): a step on the workflow canvas (type icon, kind, what it does, a problem mark); Wideset has no node or canvas item.\nimport { RiErrorWarningFill } from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { type Step, STEP_TYPES } from './data';\nimport { isComplete } from './flow';\n\n/**\n * One step as a node: one button, so Tab walks the steps in order and Enter selects. Every kind is\n * drawn the same way and only the icon tells them apart; the brand colour marks the selected node,\n * and a step that cannot run yet carries a small negative mark, nothing louder.\n */\nexport function FlowNode({\n  step,\n  selected,\n  onSelect,\n  onDeleteKey,\n}: {\n  step: Step;\n  selected: boolean;\n  onSelect: () => void;\n  onDeleteKey: (id: string) => void;\n}) {\n  const { label, icon: Icon, summary } = STEP_TYPES[step.kind];\n  const complete = isComplete(step);\n\n  return (\n    <button\n      type=\"button\"\n      id={`step-${step.id}`}\n      data-step={step.id}\n      aria-pressed={selected}\n      onClick={onSelect}\n      onKeyDown={(event) => {\n        if (event.key !== 'Delete' && event.key !== 'Backspace') return;\n        event.preventDefault();\n        onDeleteKey(step.id);\n      }}\n      className={cn(\n        'p-ws-7 gap-ws-7 rounded-ws-container-md bg-ws-static-foreground flex w-[18rem] shrink-0 items-center border text-left',\n        'outline-ws-dynamic-primary-strong-default focus-visible:wds-focus-visible',\n        selected\n          ? 'border-ws-dynamic-primary-default outline-ws-dynamic-primary-default/20 focus-visible:outline-ws-dynamic-primary-strong-default outline-2'\n          : 'border-ws-static-base hover:border-ws-static-strong',\n      )}\n    >\n      <span className=\"size-ws-14 rounded-ws-control-lg bg-ws-static-alpha-subtle flex shrink-0 items-center justify-center\">\n        <Icon aria-hidden=\"true\" className=\"size-ws-9 text-ws-static-base\" />\n      </span>\n      <span className=\"flex min-w-0 flex-1 flex-col\">\n        <span className=\"typography-caption-md text-ws-static-subtle\">{label}</span>\n        <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n          {summary(step.fields)}\n        </span>\n      </span>\n      {!complete && (\n        <>\n          <RiErrorWarningFill\n            aria-hidden=\"true\"\n            className=\"size-ws-9 text-ws-semantic-negative shrink-0\"\n          />\n          <span className=\"sr-only\">, needs attention</span>\n        </>\n      )}\n    </button>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/flow-sequence.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/flow-sequence.tsx",
      "content": "'use client';\n\nimport { Fragment } from 'react';\n\nimport { Connector, Elbow, Line } from './connector';\nimport { type Step, STEP_TYPES, type StepKind } from './data';\nimport type { SequenceKey } from './flow';\nimport { FlowNode } from './flow-node';\n\ntype SequenceProps = {\n  steps: Step[];\n  sequence: SequenceKey;\n  /** A branch opens with a \"+\" too, so a step can go first on it. */\n  leading?: boolean;\n  selectedId: string;\n  onSelect: (id: string) => void;\n  onInsert: (sequence: SequenceKey, index: number, kind: StepKind) => void;\n  /** Delete or Backspace on a node: removes the selected step. */\n  onDeleteKey: (id: string) => void;\n};\n\n/**\n * One line of steps, top to bottom, with a \"+\" between each two and one at the end. A condition\n * ends its line and splits it in two branches, each a line of its own, so the flow is drawn by\n * laying it out, not by measuring it.\n */\nexport function FlowSequence({\n  steps,\n  sequence,\n  leading = false,\n  selectedId,\n  onSelect,\n  onInsert,\n  onDeleteKey,\n}: SequenceProps) {\n  const last = steps.at(-1);\n  const insertAt = (index: number) => (kind: StepKind) => onInsert(sequence, index, kind);\n  const after = (index: number) =>\n    index === 0\n      ? 'Add the first step on this branch'\n      : `Add a step after ${STEP_TYPES[steps[index - 1].kind].label}`;\n\n  return (\n    <div className=\"flex flex-col items-center\">\n      {steps.map((step, index) => (\n        <Fragment key={step.id}>\n          {(index > 0 || leading) && <Connector label={after(index)} onInsert={insertAt(index)} />}\n          <FlowNode\n            step={step}\n            selected={step.id === selectedId}\n            onSelect={() => onSelect(step.id)}\n            onDeleteKey={onDeleteKey}\n          />\n          {step.kind === 'condition' && (\n            <>\n              <Line className=\"h-ws-7\" />\n              {/* Two columns of the same width, touching, so the split sits under the node. */}\n              <div className=\"grid grid-cols-2\">\n                {(['yes', 'no'] as const).map((branch) => (\n                  <div key={branch} className=\"flex flex-col items-center\">\n                    <Elbow side={branch === 'yes' ? 'left' : 'right'} />\n                    <span className=\"typography-caption-strong-md text-ws-static-subtle py-ws-2\">\n                      {branch === 'yes' ? 'Yes' : 'No'}\n                    </span>\n                    <div className=\"px-ws-9\">\n                      <FlowSequence\n                        steps={step[branch] ?? []}\n                        sequence={`${step.id}:${branch}`}\n                        leading\n                        selectedId={selectedId}\n                        onSelect={onSelect}\n                        onInsert={onInsert}\n                        onDeleteKey={onDeleteKey}\n                      />\n                    </div>\n                  </div>\n                ))}\n              </div>\n            </>\n          )}\n        </Fragment>\n      ))}\n      {/* An empty branch is only this \"+\". */}\n      {last?.kind !== 'condition' && (\n        <Connector label={after(steps.length)} end onInsert={insertAt(steps.length)} />\n      )}\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/flow.ts",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/flow.ts",
      "content": "import { type Field, type Step, STEP_TYPES, type StepKind } from './data';\n\n/**\n * Where a step sits: `root` is the main line, `<conditionId>:yes` and `<conditionId>:no` a\n * condition's branches.\n */\nexport type SequenceKey = 'root' | `${string}:${'yes' | 'no'}`;\n\n/** Every step in reading order: down the line, the Yes branch before the No branch. */\nexport function allSteps(flow: Step[]): Step[] {\n  return flow.flatMap((step) => [step, ...allSteps(step.yes ?? []), ...allSteps(step.no ?? [])]);\n}\n\n/** Whether a field holds what the step needs: anything for an optional field, else usable text. */\nexport const isFilled = (field: Field, value = '') =>\n  !field.missing || (value.trim() !== '' && (field.valid?.(value) ?? true));\n\n/** A step cannot run while a field it needs is empty or unusable (\"abc\" for an amount). */\nexport const isComplete = (step: Step) =>\n  STEP_TYPES[step.kind].fields.every((field) => isFilled(field, step.fields[field.name]));\n\n/** Applies `edit` to one sequence of the tree and returns the new tree. */\nfunction editSequence(\n  sequence: Step[],\n  key: SequenceKey,\n  edit: (sequence: Step[]) => Step[],\n  own: SequenceKey = 'root',\n): Step[] {\n  const here = own === key ? edit(sequence) : sequence;\n  return here.map((step) =>\n    step.kind === 'condition'\n      ? {\n          ...step,\n          yes: editSequence(step.yes ?? [], key, edit, `${step.id}:yes`),\n          no: editSequence(step.no ?? [], key, edit, `${step.id}:no`),\n        }\n      : step,\n  );\n}\n\nlet created = 0;\n\n/** A new step of a kind, with its defaults. */\nexport function newStep(kind: StepKind): Step {\n  created += 1;\n  const step: Step = { id: `${kind}-${created}`, kind, fields: { ...STEP_TYPES[kind].defaults } };\n  return kind === 'condition' ? { ...step, yes: [], no: [] } : step;\n}\n\n/**\n * Puts a step at `index` of a sequence. A condition ends its sequence, so the steps after it move\n * onto its Yes branch.\n */\nexport const insertStep = (flow: Step[], key: SequenceKey, index: number, step: Step) =>\n  editSequence(flow, key, (sequence) =>\n    step.kind === 'condition'\n      ? [...sequence.slice(0, index), { ...step, yes: sequence.slice(index), no: [] }]\n      : [...sequence.slice(0, index), step, ...sequence.slice(index)],\n  );\n\n/** Where a step sits: its sequence and its index there. */\nexport function locate(\n  flow: Step[],\n  id: string,\n  key: SequenceKey = 'root',\n): { key: SequenceKey; index: number } | undefined {\n  for (const [index, step] of flow.entries()) {\n    if (step.id === id) return { key, index };\n    const found =\n      locate(step.yes ?? [], id, `${step.id}:yes`) ?? locate(step.no ?? [], id, `${step.id}:no`);\n    if (found) return found;\n  }\n  return undefined;\n}\n\n/** The steps of one sequence, if it still exists. */\nfunction sequenceOf(flow: Step[], key: SequenceKey, own: SequenceKey = 'root'): Step[] | undefined {\n  if (own === key) return flow;\n  for (const step of flow) {\n    if (step.kind !== 'condition') continue;\n    const found =\n      sequenceOf(step.yes ?? [], key, `${step.id}:yes`) ??\n      sequenceOf(step.no ?? [], key, `${step.id}:no`);\n    if (found) return found;\n  }\n  return undefined;\n}\n\nconst endsInCondition = (sequence: Step[]) => sequence.at(-1)?.kind === 'condition';\n\n/**\n * Where `step` can go back into `sequence`, near `index`, keeping a condition last: a step lands\n * before a condition that now ends the sequence; a condition lands at the end, or nowhere when\n * another condition ends it.\n */\nfunction slotIn(sequence: Step[], index: number, step: Step): number | undefined {\n  if (step.kind === 'condition') return endsInCondition(sequence) ? undefined : sequence.length;\n  const at = Math.min(index, sequence.length);\n  return endsInCondition(sequence) ? Math.min(at, sequence.length - 1) : at;\n}\n\n/**\n * Puts a removed step back as it was, branches and all, near `index` of its sequence, against the\n * tree as it is now. When that sequence is gone (its condition was deleted since) or cannot take\n * it, the step goes to the end of the main line; a condition follows the Yes branches down to the\n * first line that does not already end in one.\n */\nexport function restoreStep(flow: Step[], key: SequenceKey, index: number, step: Step): Step[] {\n  const put = (into: SequenceKey, at: number) =>\n    editSequence(flow, into, (sequence) => [...sequence.slice(0, at), step, ...sequence.slice(at)]);\n\n  const own = sequenceOf(flow, key);\n  const there = own && slotIn(own, index, step);\n  if (there !== undefined) return put(key, there);\n\n  let line: SequenceKey = 'root';\n  let sequence = flow;\n  while (step.kind === 'condition' && endsInCondition(sequence)) {\n    const last = sequence[sequence.length - 1];\n    line = `${last.id}:yes`;\n    sequence = last.yes ?? [];\n  }\n  return put(line, slotIn(sequence, sequence.length, step) ?? sequence.length);\n}\n\n/** Takes a step out, with everything on its branches when it is a condition. */\nexport function removeStep(flow: Step[], id: string): Step[] {\n  return flow\n    .filter((step) => step.id !== id)\n    .map((step) =>\n      step.kind === 'condition'\n        ? { ...step, yes: removeStep(step.yes ?? [], id), no: removeStep(step.no ?? [], id) }\n        : step,\n    );\n}\n\nexport function updateFields(flow: Step[], id: string, fields: Record<string, string>): Step[] {\n  return flow.map((step) =>\n    step.id === id\n      ? { ...step, fields }\n      : step.kind === 'condition'\n        ? {\n            ...step,\n            yes: updateFields(step.yes ?? [], id, fields),\n            no: updateFields(step.no ?? [], id, fields),\n          }\n        : step,\n  );\n}\n\n/** The step to select once `id` is gone: the one above it on its line, or its condition. */\nexport function stepAbove(flow: Step[], id: string, parent?: Step): Step | undefined {\n  for (const [index, step] of flow.entries()) {\n    if (step.id === id) return flow[index - 1] ?? parent;\n    const found = stepAbove(step.yes ?? [], id, step) ?? stepAbove(step.no ?? [], id, step);\n    if (found) return found;\n  }\n  return undefined;\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { RiSideBarLine } from '@remixicon/react';\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { Breadcrumbs } from '@/components/ui/wideset/breadcrumbs/Breadcrumbs';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { Toast } from '@/components/ui/wideset/toast/Toast';\nimport { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';\nimport { type ReactNode, useEffect, useId, useRef, useState } from 'react';\n\nimport {\n  initialFlow,\n  initialName,\n  sampleDeal,\n  STAGES,\n  type Step,\n  STEP_TYPES,\n  type StepKind,\n} from './data';\nimport {\n  allSteps,\n  insertStep,\n  isComplete,\n  isFilled,\n  locate,\n  newStep,\n  removeStep,\n  restoreStep,\n  type SequenceKey,\n  stepAbove,\n  updateFields,\n} from './flow';\nimport { WorkflowSidebar } from './sidebar';\nimport { StepPanel } from './step-panel';\nimport { TurnOnDialog } from './turn-on-dialog';\nimport { WorkflowCanvas } from './workflow-canvas';\nimport { WorkflowHeader, type WorkflowState } from './workflow-header';\n\n/**\n * The editor inside the card, under the toasts. It holds the workflow: its name, its state, the\n * steps and which one is selected. Every edit is kept as it is made, so there is no Save: the\n * switch that turns the workflow on is the page's one primary control.\n */\nfunction WorkflowEditor({ sidebarToggle }: { sidebarToggle: ReactNode }) {\n  const { showToast, dismissToast } = useToast();\n  const [name, setName] = useState(initialName);\n  const [state, setState] = useState<WorkflowState>('draft');\n  const [flow, setFlow] = useState(initialFlow);\n  const [selectedId, setSelectedId] = useState('notify-manager');\n  const [confirming, setConfirming] = useState(false);\n  const switchRef = useRef<HTMLButtonElement>(null);\n  // A step to move the focus to once it is on screen (after a delete or its undo).\n  const [focusId, setFocusId] = useState<string>();\n\n  useEffect(() => {\n    if (!focusId) return;\n    document.getElementById(`step-${focusId}`)?.focus();\n    setFocusId(undefined);\n  }, [focusId]);\n\n  const steps = allSteps(flow);\n  const selected = steps.find((step) => step.id === selectedId) ?? flow[0];\n  const unfinished = steps.filter((step) => !isComplete(step));\n  const stage = STAGES.find((option) => option.value === flow[0].fields.stage)?.label ?? '';\n\n  const insert = (sequence: SequenceKey, index: number, kind: StepKind) => {\n    const step = newStep(kind);\n    setFlow(insertStep(flow, sequence, index, step));\n    setSelectedId(step.id);\n  };\n\n  const remove = (step: Step) => {\n    if (step.kind === 'trigger') return;\n    const at = locate(flow, step.id) ?? { key: 'root' as const, index: flow.length };\n    const above = stepAbove(flow, step.id) ?? flow[0];\n    setFlow(removeStep(flow, step.id));\n    setSelectedId(above.id);\n    setFocusId(above.id);\n\n    const inside = allSteps([step]).length - 1;\n    const id = showToast({\n      content:\n        step.kind === 'condition' && inside > 0\n          ? `Condition deleted with its ${inside === 1 ? 'step' : `${inside} steps`}`\n          : `${STEP_TYPES[step.kind].label} step deleted`,\n      action: (\n        <Toast.Action\n          preset=\"ghost\"\n          onClick={() => {\n            // Only this step (and its branches) comes back; edits made since stay.\n            setFlow((current) =>\n              allSteps(current).some((item) => item.id === step.id)\n                ? current\n                : restoreStep(current, at.key, at.index, step),\n            );\n            setSelectedId(step.id);\n            setFocusId(step.id);\n            dismissToast(id);\n          }}\n        >\n          Undo\n        </Toast.Action>\n      ),\n    });\n  };\n\n  const switchTo = (on: boolean) => {\n    // The first time it goes on, it asks; after that the switch applies at once.\n    if (on && state === 'draft') {\n      setConfirming(true);\n      return;\n    }\n    setState(on ? 'on' : 'off');\n    showToast(\n      on\n        ? { status: 'success', content: 'Workflow on' }\n        : { content: 'Workflow off. Deals that change stage no longer run it.' },\n    );\n  };\n\n  const testRun = () => {\n    const stuck = unfinished[0];\n    if (stuck) {\n      const field = STEP_TYPES[stuck.kind].fields.find(\n        (option) => !isFilled(option, stuck.fields[option.name]),\n      );\n      setSelectedId(stuck.id);\n      showToast({\n        status: 'error',\n        content: `Test run stopped at ${STEP_TYPES[stuck.kind].label}. ${field?.missing ?? ''}`,\n      });\n      return;\n    }\n    showToast({\n      status: 'success',\n      content: `Test run passed with ${sampleDeal.name}. Nothing was sent.`,\n    });\n  };\n\n  return (\n    <>\n      <div className=\"h-ws-18 border-ws-static-base flex shrink-0 items-center border-b\">\n        {/* The bar belongs to the surround: it runs edge to edge. The sidebar's toggle is pulled\n            left so its glyph, not its box, sits 20px from the edge; the crumbs follow it. */}\n        <div className=\"gap-ws-5 px-ws-11 flex w-full items-center\">\n          {sidebarToggle}\n          <Breadcrumbs separator=\"arrow\">\n            <Breadcrumbs.Item asChild>\n              <a href=\"#automations\">Automations</a>\n            </Breadcrumbs.Item>\n            <Breadcrumbs.Item>{name}</Breadcrumbs.Item>\n          </Breadcrumbs>\n        </div>\n      </div>\n\n      <WorkflowHeader\n        name={name}\n        onNameChange={setName}\n        description={`Starts when a deal moves to ${stage}. Changes save as you go.`}\n        state={state}\n        unfinished={unfinished.length}\n        onSwitch={switchTo}\n        switchRef={switchRef}\n        onTestRun={testRun}\n      />\n\n      {/* The canvas fills the card under the header; the panel runs beside it, full height. */}\n      <div className=\"flex min-h-0 flex-1\">\n        <WorkflowCanvas\n          flow={flow}\n          selectedId={selected.id}\n          onSelect={setSelectedId}\n          onInsert={insert}\n          onDeleteKey={(id) => {\n            // The step with focus, which need not be the selected one.\n            const step = steps.find((item) => item.id === id);\n            if (step) remove(step);\n          }}\n        />\n        <StepPanel\n          step={selected}\n          onFieldsChange={(fields) => setFlow(updateFields(flow, selected.id, fields))}\n          onDelete={() => remove(selected)}\n        />\n      </div>\n\n      <TurnOnDialog\n        stage={stage}\n        open={confirming}\n        onOpenChange={setConfirming}\n        returnFocusRef={switchRef}\n        onConfirm={() => {\n          setState('on');\n          showToast({\n            status: 'success',\n            content: `Workflow on. It runs on the next deal that moves to ${stage}.`,\n          });\n        }}\n      />\n    </>\n  );\n}\n\n/**\n * Workflow builder (Inset direction): an automation in Orbit on the raised page beside the\n * workspace sidebar, with Automations open. The header names the workflow and holds its state,\n * the switch that turns it on and Test run; under it the steps stand on a plain canvas, joined by\n * lines with a \"+\" on each to insert a step, and the selected step's settings fill a 22rem panel\n * beside it. Delete removes the selected step with Undo; the zoom controls sit in a corner.\n */\nexport default function WorkflowBuilder() {\n  const sidebarId = useId();\n  const [collapsed, setCollapsed] = useState(false);\n\n  return (\n    <ToastProvider>\n      <AppShell className=\"ws-block-utility\" direction=\"inset\">\n        <WorkflowSidebar id={sidebarId} collapsed={collapsed} onCollapsedChange={setCollapsed} />\n        <AppShell.Main>\n          <WorkflowEditor\n            sidebarToggle={\n              <IconButton\n                icon={RiSideBarLine}\n                variant=\"secondary\"\n                preset=\"ghost\"\n                size=\"sm\"\n                iconClassName=\"text-ws-static-subtle size-ws-9\"\n                aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n                aria-expanded={!collapsed}\n                aria-controls={sidebarId}\n                onClick={() => setCollapsed(!collapsed)}\n                className=\"-ml-ws-5\"\n              />\n            }\n          />\n        </AppShell.Main>\n      </AppShell>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/insert-menu.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/insert-menu.tsx",
      "content": "'use client';\n\nimport { RiAddLine } from '@remixicon/react';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\n\nimport { INSERTABLE, STEP_TYPES, type StepKind } from './data';\n\n/**\n * The \"+\" on a line between two steps: a short menu of the step types, each with the icon its\n * node will carry. Picking one inserts it at that point of the line.\n */\nexport function InsertMenu({\n  label,\n  onInsert,\n}: {\n  /** Says where the step goes, for screen readers (\"Add a step after Create task\"). */\n  label: string;\n  onInsert: (kind: StepKind) => void;\n}) {\n  return (\n    <DropdownMenu>\n      <DropdownMenu.Trigger asChild>\n        <IconButton\n          icon={RiAddLine}\n          variant=\"secondary\"\n          preset=\"border\"\n          size=\"xs\"\n          aria-label={label}\n          className=\"shrink-0\"\n        />\n      </DropdownMenu.Trigger>\n      <DropdownMenu.Content align=\"center\" className=\"ws-block-utility w-[13rem]\">\n        {INSERTABLE.map((kind) => {\n          const { label: name, icon: Icon } = STEP_TYPES[kind];\n          return (\n            <DropdownMenu.Item key={kind} onSelect={() => onInsert(kind)}>\n              <ListItem.Prefix>\n                <Icon className=\"size-ws-9\" />\n              </ListItem.Prefix>\n              <ListItem.Content>\n                <ListItem.Label>{name}</ListItem.Label>\n              </ListItem.Content>\n            </DropdownMenu.Item>\n          );\n        })}\n      </DropdownMenu.Content>\n    </DropdownMenu>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/people.assets.ts",
      "content": "// Portraits of the sample people as small JPEG data URLs (a block ships only .ts and .tsx).\n// Exported from the Wideset Core Figma file by people.cjs: do not edit by hand.\n\n/** A person’s photo by name. People who are not here show their initials. */\nexport const PHOTOS: Record<string, string | undefined> = {\n  'Maya Okafor':\n    'data:image/jpeg;base64,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',\n};\n"
    },
    {
      "path": "src/blocks/workflow-builder/person-avatar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/person-avatar.tsx",
      "content": "'use client';\n\nimport type { AvatarProps } from '@/components/ui/wideset/avatar/Avatar.types';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\n\nimport { PHOTOS } from './people.assets';\n\ntype PersonAvatarProps = Pick<\n  AvatarProps,\n  'size' | 'shape' | 'status' | 'color' | 'className' | 'title' | 'aria-hidden' | 'aria-label'\n> & {\n  /** The person's full name: the key their photo is filed under. */\n  name: string;\n  initials: string;\n  /** Leave empty beside the person's name; pass the name where the avatar stands alone. */\n  alt?: string;\n};\n\n/**\n * A person's avatar: their photo when the sample people have one, otherwise their initials in\n * their colour. A real product mixes the two, so every place the block draws a person asks here\n * and the choice is made once. The initials stay as the fallback if the image fails to load.\n */\nexport function PersonAvatar({ name, initials, color, alt = '', ...props }: PersonAvatarProps) {\n  const photo = PHOTOS[name];\n  return photo ? (\n    <Avatar src={photo} alt={alt} initials={initials} {...props} />\n  ) : (\n    <Avatar initials={initials} color={color} {...props} />\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/sidebar.tsx",
      "content": "'use client';\n\n// TODO(custom): workspace switcher and account menu are composed by hand.\nimport {\n  RiAddLine,\n  RiArrowDownSLine,\n  RiLogoutBoxRLine,\n  RiSearchLine,\n  RiSettingsLine,\n} from '@remixicon/react';\nimport { Divider } from '@/components/ui/wideset/divider/Divider';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';\nimport { type SidebarProps } from '@/components/ui/wideset/sidebar/Sidebar.types';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport {\n  account,\n  helpLink,\n  mainLinks,\n  type NavLink,\n  product,\n  settingsLinks,\n  workspace,\n} from './data';\nimport { PersonAvatar } from './person-avatar';\n\n/**\n * The workspace sidebar: switcher, search, the app's pages, settings and the signed-in account.\n * Its toggle sits in the page bar, so the screen holds `collapsed` and passes it down; collapsed,\n * it keeps the mark, the page icons and the avatar.\n */\nexport function WorkflowSidebar(\n  props: Pick<SidebarProps, 'id' | 'collapsed' | 'onCollapsedChange'>,\n) {\n  const [active, setActive] = useState('automations');\n\n  const link = ({ id, label, icon, activeIcon }: NavLink) => (\n    <Sidebar.Item\n      key={id}\n      href={`#${id}`}\n      icon={active === id ? (activeIcon ?? icon) : icon}\n      label={label}\n      active={active === id}\n      onClick={() => setActive(id)}\n    />\n  );\n\n  const nav = (\n    <nav aria-label=\"Workspace\" className=\"gap-ws-9 flex flex-col\">\n      <div className=\"flex flex-col\">{mainLinks.map(link)}</div>\n      <Divider weight=\"thin\" />\n      <div role=\"group\" aria-labelledby=\"sidebar-settings\" className=\"gap-ws-2 flex flex-col\">\n        <Sidebar.SectionHeader id=\"sidebar-settings\">Settings</Sidebar.SectionHeader>\n        {settingsLinks.map(link)}\n      </div>\n    </nav>\n  );\n\n  return (\n    <Sidebar {...props}>\n      <Sidebar.Header>\n        <Sidebar.Expanded>\n          <div className=\"gap-ws-9 flex flex-col\">\n            <div className=\"gap-ws-7 pt-ws-3 pb-ws-7 flex items-center\">\n              <BrandMark className=\"size-ws-15\" />\n              <div className=\"flex min-w-0 flex-1 flex-col\">\n                <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n                  {workspace.name}\n                </span>\n                <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                  {product.name}\n                </span>\n              </div>\n              <DropdownMenu>\n                <DropdownMenu.Trigger asChild>\n                  <IconButton\n                    icon={RiArrowDownSLine}\n                    variant=\"secondary\"\n                    preset=\"ghost\"\n                    size=\"xs\"\n                    aria-label=\"Switch workspace\"\n                    className=\"mr-ws-3\"\n                  />\n                </DropdownMenu.Trigger>\n                <DropdownMenu.Content className=\"ws-block-utility\" align=\"end\">\n                  <DropdownMenu.Item data-state=\"checked\">\n                    <ListItem.Content>\n                      <ListItem.Label>{workspace.name}</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                  <DropdownMenu.Separator />\n                  <DropdownMenu.Item>\n                    <ListItem.Prefix>\n                      <RiAddLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>New workspace</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                </DropdownMenu.Content>\n              </DropdownMenu>\n            </div>\n            <TextInput size=\"sm\">\n              <TextInput.Prefix inner>\n                <TextInput.Icon icon={RiSearchLine} />\n              </TextInput.Prefix>\n              <TextInput.Input type=\"search\" placeholder=\"Search\" aria-label=\"Search\" />\n            </TextInput>\n          </div>\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <div className=\"pt-ws-3 pb-ws-7 flex justify-center\">\n            <BrandMark className=\"size-ws-15\" />\n          </div>\n        </Sidebar.Collapsed>\n      </Sidebar.Header>\n\n      {/* A section draws only the slot for the state it is in, so the pages go in both. */}\n      <Sidebar.Section scrollable>{nav}</Sidebar.Section>\n\n      <Sidebar.Footer>\n        <div className=\"gap-ws-9 flex flex-col\">\n          <div className=\"flex flex-col\">{link(helpLink)}</div>\n          {/* On the grey ground the line keeps the nav's inset: run edge to edge, it would stop\n              short of the page and read as broken. */}\n          <div className=\"border-ws-static-base pt-ws-5 border-t\">\n            <Sidebar.Expanded>\n              <DropdownMenu>\n                <DropdownMenu.Trigger asChild>\n                  <button\n                    type=\"button\"\n                    className=\"gap-ws-5 px-ws-5 py-ws-3 rounded-ws-control-lg hover:bg-ws-dynamic-tertiary-alpha-strong-default focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex w-full items-center text-left\"\n                  >\n                    <PersonAvatar name={account.name} initials={account.initials} color=\"orange\" />\n                    <span className=\"flex min-w-0 flex-1 flex-col\">\n                      <span className=\"typography-label-strong-sm text-ws-static-base truncate\">\n                        {account.name}\n                      </span>\n                      <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                        {account.email}\n                      </span>\n                    </span>\n                    <RiArrowDownSLine\n                      aria-hidden=\"true\"\n                      className=\"size-ws-9 text-ws-static-strong\"\n                    />\n                  </button>\n                </DropdownMenu.Trigger>\n                <DropdownMenu.Content side=\"top\" align=\"start\" className=\"ws-block-utility w-[14rem]\">\n                  <DropdownMenu.Item>\n                    <ListItem.Prefix>\n                      <RiSettingsLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>Account settings</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                  <DropdownMenu.Separator />\n                  <DropdownMenu.Item variant=\"danger\">\n                    <ListItem.Prefix>\n                      <RiLogoutBoxRLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>Log out</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                </DropdownMenu.Content>\n              </DropdownMenu>\n            </Sidebar.Expanded>\n            <Sidebar.Collapsed>\n              <div className=\"flex justify-center\">\n                <PersonAvatar\n                  name={account.name}\n                  initials={account.initials}\n                  color=\"orange\"\n                  title={account.name}\n                  alt={account.name}\n                />\n              </div>\n            </Sidebar.Collapsed>\n          </div>\n        </div>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/step-panel.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/step-panel.tsx",
      "content": "'use client';\n\nimport { RiDeleteBinLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { Select } from '@/components/ui/wideset/select/Select';\nimport { Textarea } from '@/components/ui/wideset/textarea/Textarea';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useId } from 'react';\n\nimport { type Field, type Step, STEP_TYPES } from './data';\nimport { isFilled } from './flow';\n\n/** One setting: a select, a line of text or a message, with what it still needs under it. */\nfunction StepField({\n  id,\n  field,\n  value,\n  onChange,\n}: {\n  id: string;\n  field: Field;\n  value: string;\n  onChange: (value: string) => void;\n}) {\n  // The step is saved as it is, so a field it cannot run without says so at once, like its node.\n  const error = isFilled(field, value) ? undefined : field.missing;\n  const variant = error ? 'danger' : 'primary';\n\n  return (\n    <FormField label={field.label} htmlFor={id} helperText={field.helperText} errorText={error}>\n      {field.control === 'select' ? (\n        <Select\n          id={id}\n          size=\"sm\"\n          className=\"w-full\"\n          variant={variant}\n          options={field.options ?? []}\n          placeholder={field.placeholder}\n          value={value}\n          onValueChange={onChange}\n        />\n      ) : field.control === 'textarea' ? (\n        <Textarea\n          id={id}\n          size=\"sm\"\n          rows={4}\n          resize=\"vertical\"\n          variant={variant}\n          placeholder={field.placeholder}\n          value={value}\n          onChange={(event) => onChange(event.target.value)}\n        />\n      ) : (\n        <TextInput\n          id={id}\n          size=\"sm\"\n          variant={variant}\n          placeholder={field.placeholder}\n          value={value}\n          onChange={(event) => onChange(event.target.value)}\n        />\n      )}\n    </FormField>\n  );\n}\n\n/**\n * The selected step's settings, 22rem beside the canvas and split from it by a line: what kind of\n * step it is and what it does, its fields (saved as they change), and Delete step at the foot. The\n * trigger has no Delete: a workflow always starts with one.\n */\nexport function StepPanel({\n  step,\n  onFieldsChange,\n  onDelete,\n}: {\n  step: Step;\n  onFieldsChange: (fields: Record<string, string>) => void;\n  onDelete: () => void;\n}) {\n  const id = useId();\n  const { label, description, icon: Icon, fields } = STEP_TYPES[step.kind];\n\n  return (\n    <aside\n      aria-labelledby={`${id}-title`}\n      className=\"border-ws-static-subtle flex w-[22rem] shrink-0 flex-col border-l\"\n    >\n      <div className=\"gap-ws-7 px-ws-11 pt-ws-11 pb-ws-9 flex items-start\">\n        <span className=\"size-ws-14 rounded-ws-control-lg bg-ws-static-alpha-subtle flex shrink-0 items-center justify-center\">\n          <Icon aria-hidden=\"true\" className=\"size-ws-9 text-ws-static-base\" />\n        </span>\n        <div className=\"gap-ws-2 flex min-w-0 flex-col\">\n          <h2 id={`${id}-title`} className=\"typography-label-strong-md text-ws-static-strong\">\n            {label}\n          </h2>\n          <p className=\"typography-body-sm text-ws-static-subtle\">{description}</p>\n        </div>\n      </div>\n\n      {/* Keyed by step, so a field never shows the last step's value while the panel swaps. */}\n      <div\n        key={step.id}\n        className=\"gap-ws-11 px-ws-11 pb-ws-11 pt-ws-5 ws-scrollbar flex min-h-0 flex-1 flex-col overflow-y-auto\"\n      >\n        {fields.map((field) => (\n          <StepField\n            key={field.name}\n            id={`${id}-${field.name}`}\n            field={field}\n            value={step.fields[field.name] ?? ''}\n            onChange={(value) => onFieldsChange({ ...step.fields, [field.name]: value })}\n          />\n        ))}\n      </div>\n\n      <div className=\"border-ws-static-subtle px-ws-11 py-ws-9 shrink-0 border-t\">\n        {step.kind === 'trigger' ? (\n          <p className=\"typography-body-sm text-ws-static-subtle\">\n            Every workflow starts with a trigger. Change what starts it instead of deleting it.\n          </p>\n        ) : (\n          <Button variant=\"secondary\" preset=\"border\" size=\"sm\" onClick={onDelete}>\n            <Button.Icon icon={RiDeleteBinLine} />\n            Delete step\n          </Button>\n        )}\n      </div>\n    </aside>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/turn-on-dialog.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/turn-on-dialog.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { StatusModal } from '@/components/ui/wideset/status-modal/StatusModal';\nimport type { RefObject } from 'react';\n\n/**\n * Asked once, the first time the workflow is turned on: what will start happening, and that\n * deals already in the stage are left alone. Later the switch applies at once. It opens from the\n * switch, not a trigger, so on close focus goes back to `returnFocusRef`.\n */\nexport function TurnOnDialog({\n  stage,\n  open,\n  onOpenChange,\n  onConfirm,\n  returnFocusRef,\n}: {\n  stage: string;\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  onConfirm: () => void;\n  returnFocusRef: RefObject<HTMLElement | null>;\n}) {\n  return (\n    <StatusModal status=\"information\" open={open} onOpenChange={onOpenChange}>\n      <StatusModal.Content className=\"ws-block-utility\"\n        onCloseAutoFocus={(event) => {\n          event.preventDefault();\n          returnFocusRef.current?.focus();\n        }}\n      >\n        <StatusModal.Title>Turn on this workflow?</StatusModal.Title>\n        <StatusModal.Body>\n          From now on, every deal that moves to {stage} runs its steps: messages and e-mails go out\n          and tasks are created. Deals already in {stage} are left alone.\n        </StatusModal.Body>\n        <StatusModal.Footer>\n          <StatusModal.Close asChild>\n            <Button variant=\"secondary\" preset=\"border\">\n              Cancel\n            </Button>\n          </StatusModal.Close>\n          <Button\n            onClick={() => {\n              onOpenChange(false);\n              onConfirm();\n            }}\n          >\n            Turn on\n          </Button>\n        </StatusModal.Footer>\n      </StatusModal.Content>\n    </StatusModal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/workflow-canvas.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/workflow-canvas.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport type { Step, StepKind } from './data';\nimport type { SequenceKey } from './flow';\nimport { FlowSequence } from './flow-sequence';\nimport { ZoomControls, ZOOMS } from './zoom-controls';\n\n/** The space kept around the flow, in px: `p-ws-14` on its frame. */\nconst ROOM = 32;\n\n/**\n * The canvas: the flow centred at the top of a plain white area that scrolls both ways when the\n * flow outgrows it, and the zoom controls in its lower left corner, away from the panel. No grid\n * or dots: on a white page they were noise around six nodes.\n */\nexport function WorkflowCanvas({\n  flow,\n  selectedId,\n  onSelect,\n  onInsert,\n  onDeleteKey,\n}: {\n  flow: Step[];\n  selectedId: string;\n  onSelect: (id: string) => void;\n  onInsert: (sequence: SequenceKey, index: number, kind: StepKind) => void;\n  onDeleteKey: (id: string) => void;\n}) {\n  const [zoom, setZoom] = useState(ZOOMS.findIndex((step) => step.value === 1));\n  const scrollerRef = useRef<HTMLDivElement>(null);\n  const flowRef = useRef<HTMLDivElement>(null);\n\n  // A step selected off screen (a new one, or the one above a deleted one) scrolls into view;\n  // not on load, where it would scroll a page that shows this screen among others.\n  const loaded = useRef(false);\n  useEffect(() => {\n    if (!loaded.current) {\n      loaded.current = true;\n      return;\n    }\n    const node = document.getElementById(`step-${selectedId}`);\n    if (typeof node?.scrollIntoView === 'function') {\n      node.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n    }\n  }, [selectedId]);\n\n  /** The largest step up to 100% at which the whole flow fits the canvas. */\n  const fit = () => {\n    const scroller = scrollerRef.current;\n    const box = flowRef.current?.getBoundingClientRect();\n    // Nothing is laid out yet (or in a test DOM): leave the zoom as it is.\n    if (!scroller || !box?.width) return;\n    const width = box.width / ZOOMS[zoom].value;\n    const height = box.height / ZOOMS[zoom].value;\n    const roomX = scroller.clientWidth - ROOM * 2;\n    const roomY = scroller.clientHeight - ROOM * 2;\n    const fits = ZOOMS.map(({ value }, index) => ({ value, index })).filter(\n      ({ value }) => value <= 1 && width * value <= roomX && height * value <= roomY,\n    );\n    setZoom(fits.at(-1)?.index ?? 0);\n  };\n\n  return (\n    <div className=\"relative min-h-0 min-w-0 flex-1\">\n      <div ref={scrollerRef} className=\"inset-ws-0 ws-scrollbar absolute overflow-auto\">\n        <div className=\"p-ws-14 flex w-max min-w-full justify-center\">\n          <div ref={flowRef} className={ZOOMS[zoom].className}>\n            <FlowSequence\n              steps={flow}\n              sequence=\"root\"\n              selectedId={selectedId}\n              onSelect={onSelect}\n              onInsert={onInsert}\n              onDeleteKey={onDeleteKey}\n            />\n          </div>\n        </div>\n      </div>\n      <ZoomControls\n        zoom={zoom}\n        onZoomChange={setZoom}\n        onFit={fit}\n        className=\"bottom-ws-9 left-ws-9 absolute\"\n      />\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/workflow-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/workflow-header.tsx",
      "content": "'use client';\n\n// TODO(custom): page header (an editable title with its state, a line of description, the actions on the right); no PageHeader in Wideset.\nimport { RiPlayLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { Switch } from '@/components/ui/wideset/switch/Switch';\nimport { type Ref, useId } from 'react';\n\nimport { WorkflowName } from './workflow-name';\n\nexport type WorkflowState = 'draft' | 'on' | 'off';\n\nconst BADGE = {\n  draft: { label: 'Draft', color: 'neutral' },\n  on: { label: 'On', color: 'positive' },\n  off: { label: 'Off', color: 'notice' },\n} as const;\n\n/**\n * The workflow's header, across the canvas and the panel: its name (edited in place) with its\n * state, what starts it, and on the right the switch that turns it on, the page's one primary\n * control, then Test run. While a step is unfinished the switch is locked and says why beside it.\n */\nexport function WorkflowHeader({\n  name,\n  onNameChange,\n  description,\n  state,\n  unfinished,\n  onSwitch,\n  switchRef,\n  onTestRun,\n}: {\n  name: string;\n  onNameChange: (name: string) => void;\n  /** One line: what starts the workflow. */\n  description: string;\n  state: WorkflowState;\n  /** Steps that cannot run yet. */\n  unfinished: number;\n  onSwitch: (on: boolean) => void;\n  /** The switch, for focus to return to after the confirmation it opens. */\n  switchRef?: Ref<HTMLButtonElement>;\n  onTestRun: () => void;\n}) {\n  const reasonId = useId();\n  const badge = BADGE[state];\n  // A workflow that is on can always be turned off.\n  const locked = unfinished > 0 && state !== 'on';\n\n  return (\n    <header className=\"gap-ws-12 px-ws-11 py-ws-9 border-ws-static-subtle flex shrink-0 flex-wrap items-center justify-between border-b\">\n      <div className=\"gap-ws-2 flex min-w-0 flex-col\">\n        <div className=\"gap-ws-5 flex min-w-0 items-center\">\n          <WorkflowName value={name} onChange={onNameChange} />\n          <StatusBadge size=\"lg\" color={badge.color}>\n            {badge.label}\n          </StatusBadge>\n        </div>\n        <p className=\"typography-body-md text-ws-static-subtle\">{description}</p>\n      </div>\n\n      <div className=\"gap-ws-9 flex items-center\">\n        {unfinished > 0 && (\n          <p id={reasonId} className=\"typography-body-sm text-ws-static-subtle\">\n            {/* Locked, it says what unlocks it; on, what will not run yet. */}\n            {locked\n              ? `Finish ${unfinished === 1 ? '1 step' : `${unfinished} steps`} to turn it on`\n              : `${unfinished === 1 ? '1 step' : `${unfinished} steps`} to finish`}\n          </p>\n        )}\n        <Switch\n          ref={switchRef}\n          label=\"Workflow on\"\n          labelPosition=\"left\"\n          checked={state === 'on'}\n          disabled={locked}\n          aria-describedby={unfinished > 0 ? reasonId : undefined}\n          onCheckedChange={onSwitch}\n        />\n        <Button variant=\"secondary\" preset=\"border\" size=\"sm\" onClick={onTestRun}>\n          <Button.Icon icon={RiPlayLine} />\n          Test run\n        </Button>\n      </div>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/workflow-name.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/workflow-name.tsx",
      "content": "'use client';\n\n// TODO(custom): a page title edited in place; Wideset has no inline-edit or editable heading.\nimport { RiPencilLine } from '@remixicon/react';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { useEffect, useRef, useState } from 'react';\n\n/**\n * The workflow's name as the page title, with a pencil beside it. Editing swaps the title for a\n * field in the same type, so nothing jumps; Enter or leaving the field keeps the name, Escape or\n * an empty name puts the old one back.\n */\nexport function WorkflowName({\n  value,\n  onChange,\n}: {\n  value: string;\n  onChange: (value: string) => void;\n}) {\n  const [draft, setDraft] = useState<string>();\n  // Enter and Escape hand the focus back to the pencil; a click elsewhere keeps it there.\n  const [refocus, setRefocus] = useState(false);\n  const pencilRef = useRef<HTMLButtonElement>(null);\n  // Set once Enter or Escape has closed the field, so the blur of its removal changes nothing.\n  const closedRef = useRef(false);\n\n  useEffect(() => {\n    if (draft !== undefined || !refocus) return;\n    pencilRef.current?.focus();\n    setRefocus(false);\n  }, [draft, refocus]);\n\n  const close = (keep: boolean, fromKeyboard = false) => {\n    if (closedRef.current) return;\n    closedRef.current = true;\n    if (keep && draft?.trim()) onChange(draft.trim());\n    setRefocus(fromKeyboard);\n    setDraft(undefined);\n  };\n\n  if (draft !== undefined) {\n    return (\n      <input\n        // The field appears because the pencil was pressed: the focus belongs in it.\n        // eslint-disable-next-line jsx-a11y/no-autofocus\n        autoFocus\n        aria-label=\"Workflow name\"\n        value={draft}\n        onChange={(event) => setDraft(event.target.value)}\n        onBlur={() => close(true)}\n        onKeyDown={(event) => {\n          if (event.key !== 'Enter' && event.key !== 'Escape') return;\n          // Otherwise the key goes on to the pencil, which takes the focus back, and reopens it.\n          event.preventDefault();\n          close(event.key === 'Enter', true);\n        }}\n        onFocus={(event) => event.target.select()}\n        className=\"typography-title-sm text-ws-static-strong rounded-ws-control-md px-ws-3 -mx-ws-3 bg-ws-static-highlight-base outline-ws-dynamic-primary-default field-sizing-content min-w-[12rem] outline-2\"\n      />\n    );\n  }\n\n  return (\n    <div className=\"gap-ws-3 flex min-w-0 items-center\">\n      <h1 className=\"typography-title-sm text-ws-static-strong truncate\">{value}</h1>\n      <IconButton\n        ref={pencilRef}\n        icon={RiPencilLine}\n        variant=\"secondary\"\n        preset=\"ghost\"\n        size=\"xs\"\n        aria-label=\"Rename workflow\"\n        onClick={() => {\n          closedRef.current = false;\n          setDraft(value);\n        }}\n      />\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/workflow-builder/zoom-controls.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/workflow-builder/zoom-controls.tsx",
      "content": "'use client';\n\n// TODO(custom): canvas zoom controls (out, level, in, fit) in one bordered group; Wideset has no toolbar group or zoom control.\nimport { RiFocus3Line, RiZoomInLine, RiZoomOutLine } from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\n\n/**\n * The zoom steps. CSS `zoom` scales the flow's layout too, so the canvas scrolls by the zoomed\n * size; the classes are written out so Tailwind finds them.\n */\nexport const ZOOMS = [\n  { value: 0.5, className: '[zoom:0.5]' },\n  { value: 0.75, className: '[zoom:0.75]' },\n  { value: 1, className: '[zoom:1]' },\n  { value: 1.25, className: '[zoom:1.25]' },\n  { value: 1.5, className: '[zoom:1.5]' },\n];\n\n/**\n * Zoom out, the level, zoom in, then fit, in one group in the canvas corner. The group is the\n * one frame; its buttons are ghost, so nothing is boxed twice.\n */\nexport function ZoomControls({\n  zoom,\n  onZoomChange,\n  onFit,\n  className,\n}: {\n  /** Index into `ZOOMS`. */\n  zoom: number;\n  onZoomChange: (zoom: number) => void;\n  onFit: () => void;\n  className?: string;\n}) {\n  return (\n    <div\n      role=\"group\"\n      aria-label=\"Zoom\"\n      className={cn(\n        'gap-ws-2 p-ws-2 rounded-ws-control-lg border-ws-static-base bg-ws-static-foreground flex items-center border',\n        className,\n      )}\n    >\n      <IconButton\n        icon={RiZoomOutLine}\n        variant=\"secondary\"\n        preset=\"ghost\"\n        size=\"xs\"\n        aria-label=\"Zoom out\"\n        disabled={zoom === 0}\n        onClick={() => onZoomChange(zoom - 1)}\n      />\n      <output\n        aria-live=\"polite\"\n        className=\"typography-label-sm text-ws-static-base w-ws-17 text-center tabular-nums\"\n      >\n        {ZOOMS[zoom].value * 100}%\n      </output>\n      <IconButton\n        icon={RiZoomInLine}\n        variant=\"secondary\"\n        preset=\"ghost\"\n        size=\"xs\"\n        aria-label=\"Zoom in\"\n        disabled={zoom === ZOOMS.length - 1}\n        onClick={() => onZoomChange(zoom + 1)}\n      />\n      <span aria-hidden=\"true\" className=\"h-ws-9 border-ws-static-subtle mx-ws-2 border-l\" />\n      <IconButton\n        icon={RiFocus3Line}\n        variant=\"secondary\"\n        preset=\"ghost\"\n        size=\"xs\"\n        aria-label=\"Fit to screen\"\n        onClick={onFit}\n      />\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
