@burojs/ui-shadcn 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/{bulk-summary-2HLgz7Il.cjs → bulk-summary-Chc61Pyw.cjs} +9 -7
  2. package/dist/bulk-summary-Chc61Pyw.cjs.map +1 -0
  3. package/dist/{bulk-summary-D6A0ua21.js → bulk-summary-DpSQD2Fq.js} +9 -7
  4. package/dist/bulk-summary-DpSQD2Fq.js.map +1 -0
  5. package/dist/{candidates-relation-picker-QvoY2bOQ.js → candidates-relation-picker-DRsHKe6N.js} +3 -3
  6. package/dist/{candidates-relation-picker-QvoY2bOQ.js.map → candidates-relation-picker-DRsHKe6N.js.map} +1 -1
  7. package/dist/{candidates-relation-picker-pEAWKQEY.cjs → candidates-relation-picker-GIxsp7D_.cjs} +3 -3
  8. package/dist/{candidates-relation-picker-pEAWKQEY.cjs.map → candidates-relation-picker-GIxsp7D_.cjs.map} +1 -1
  9. package/dist/{check-confirm-dialog-W-8WOmGh.cjs → check-confirm-dialog-BMSb7wFv.cjs} +17 -9
  10. package/dist/check-confirm-dialog-BMSb7wFv.cjs.map +1 -0
  11. package/dist/{check-confirm-dialog-B-CbJTln.js → check-confirm-dialog-B_u3YVHS.js} +18 -10
  12. package/dist/{check-confirm-dialog-B-CbJTln.js.map → check-confirm-dialog-B_u3YVHS.js.map} +1 -1
  13. package/dist/{filter-builder-04nas3eq.js → filter-builder-DX-xC3Yd.js} +2 -2
  14. package/dist/{filter-builder-04nas3eq.js.map → filter-builder-DX-xC3Yd.js.map} +1 -1
  15. package/dist/{filter-builder-DQX-TMFh.cjs → filter-builder-Dt5E8PSX.cjs} +2 -2
  16. package/dist/{filter-builder-DQX-TMFh.cjs.map → filter-builder-Dt5E8PSX.cjs.map} +1 -1
  17. package/dist/{flow-runtime-DyNIYfUP.cjs → flow-runtime-CQ4wf8co.cjs} +2 -2
  18. package/dist/{flow-runtime-DyNIYfUP.cjs.map → flow-runtime-CQ4wf8co.cjs.map} +1 -1
  19. package/dist/{flow-runtime-BEIyym7d.js → flow-runtime-Q2vD7R3c.js} +2 -2
  20. package/dist/{flow-runtime-BEIyym7d.js.map → flow-runtime-Q2vD7R3c.js.map} +1 -1
  21. package/dist/{flow-screen-DY1Z9PbG.js → flow-screen-B1y2yizP.js} +18 -18
  22. package/dist/flow-screen-B1y2yizP.js.map +1 -0
  23. package/dist/{flow-screen-FE5Xhb3t.cjs → flow-screen-sw2cP70t.cjs} +18 -18
  24. package/dist/flow-screen-sw2cP70t.cjs.map +1 -0
  25. package/dist/index.cjs +2183 -109
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +76 -8
  28. package/dist/index.d.ts +76 -8
  29. package/dist/index.js +2095 -24
  30. package/dist/index.js.map +1 -1
  31. package/dist/{inline-flow-host-yVLo6-sM.cjs → inline-flow-host-CkhoA69R.cjs} +3 -3
  32. package/dist/{inline-flow-host-yVLo6-sM.cjs.map → inline-flow-host-CkhoA69R.cjs.map} +1 -1
  33. package/dist/{inline-flow-host-D6u-RlsV.js → inline-flow-host-DqbXqcPS.js} +3 -3
  34. package/dist/{inline-flow-host-D6u-RlsV.js.map → inline-flow-host-DqbXqcPS.js.map} +1 -1
  35. package/dist/{lazy-relation-picker-dialog-BaORufxQ.js → lazy-relation-picker-dialog-BaIEWLbF.js} +3 -52
  36. package/dist/lazy-relation-picker-dialog-BaIEWLbF.js.map +1 -0
  37. package/dist/{lazy-relation-picker-dialog-C_VlGlDz.cjs → lazy-relation-picker-dialog-CeRzOAi0.cjs} +3 -52
  38. package/dist/lazy-relation-picker-dialog-CeRzOAi0.cjs.map +1 -0
  39. package/dist/{page-flow-route-CyMzUidK.js → page-flow-route-CP7cS7FY.js} +5 -5
  40. package/dist/page-flow-route-CP7cS7FY.js.map +1 -0
  41. package/dist/{page-flow-route-OFx7h7Ja.cjs → page-flow-route-UDx8qvdM.cjs} +9 -9
  42. package/dist/page-flow-route-UDx8qvdM.cjs.map +1 -0
  43. package/dist/{place-node-BZF5Af6x.cjs → place-node-C5ZmuHaN.cjs} +149 -40
  44. package/dist/place-node-C5ZmuHaN.cjs.map +1 -0
  45. package/dist/{place-node-DRjmJGQ_.js → place-node-DwWAigv0.js} +146 -43
  46. package/dist/place-node-DwWAigv0.js.map +1 -0
  47. package/dist/record-trail-store-Cjo9vtod.cjs +126 -0
  48. package/dist/record-trail-store-Cjo9vtod.cjs.map +1 -0
  49. package/dist/record-trail-store-Dn6bVry4.js +91 -0
  50. package/dist/record-trail-store-Dn6bVry4.js.map +1 -0
  51. package/dist/{related-list-cards-xVvgSlu-.cjs → related-list-cards-BypKfm9t.cjs} +3 -3
  52. package/dist/{related-list-cards-xVvgSlu-.cjs.map → related-list-cards-BypKfm9t.cjs.map} +1 -1
  53. package/dist/{related-list-cards-2hLitVkg.js → related-list-cards-Dcmruy09.js} +3 -3
  54. package/dist/{related-list-cards-2hLitVkg.js.map → related-list-cards-Dcmruy09.js.map} +1 -1
  55. package/dist/{related-list-timeline-Dsf5WewG.cjs → related-list-timeline-D-KClgKb.cjs} +4 -4
  56. package/dist/{related-list-timeline-Dsf5WewG.cjs.map → related-list-timeline-D-KClgKb.cjs.map} +1 -1
  57. package/dist/{related-list-timeline-CxJqe6eK.js → related-list-timeline-DZON_qSc.js} +4 -4
  58. package/dist/{related-list-timeline-CxJqe6eK.js.map → related-list-timeline-DZON_qSc.js.map} +1 -1
  59. package/dist/{related-rows-DDhp9axl.cjs → related-rows-DgF05ssi.cjs} +4 -4
  60. package/dist/{related-rows-DDhp9axl.cjs.map → related-rows-DgF05ssi.cjs.map} +1 -1
  61. package/dist/{related-rows-DL6CWsrj.js → related-rows-ETZl5CB9.js} +4 -4
  62. package/dist/{related-rows-DL6CWsrj.js.map → related-rows-ETZl5CB9.js.map} +1 -1
  63. package/dist/{relation-create-_SFuPQGM.cjs → relation-create-B8zngAcA.cjs} +46 -11
  64. package/dist/relation-create-B8zngAcA.cjs.map +1 -0
  65. package/dist/{relation-create-6WicROWA.js → relation-create-CeCWyxIb.js} +47 -12
  66. package/dist/relation-create-CeCWyxIb.js.map +1 -0
  67. package/dist/{relation-many-picker-mGEQDWo2.js → relation-many-picker-CT7nKfE2.js} +4 -4
  68. package/dist/{relation-many-picker-mGEQDWo2.js.map → relation-many-picker-CT7nKfE2.js.map} +1 -1
  69. package/dist/{relation-many-picker-BBNsmkaX.cjs → relation-many-picker-Cq0EHY5I.cjs} +4 -4
  70. package/dist/{relation-many-picker-BBNsmkaX.cjs.map → relation-many-picker-Cq0EHY5I.cjs.map} +1 -1
  71. package/dist/{relation-picker-BbO41cFV.js → relation-picker-CCyuMeGq.js} +6 -6
  72. package/dist/{relation-picker-BbO41cFV.js.map → relation-picker-CCyuMeGq.js.map} +1 -1
  73. package/dist/{relation-picker-jk9D_uwn.cjs → relation-picker-DmwTzgsd.cjs} +6 -6
  74. package/dist/{relation-picker-jk9D_uwn.cjs.map → relation-picker-DmwTzgsd.cjs.map} +1 -1
  75. package/dist/{relation-picker-dialog-BgSG_8bU.js → relation-picker-dialog-CoWKjNv8.js} +4 -4
  76. package/dist/{relation-picker-dialog-BgSG_8bU.js.map → relation-picker-dialog-CoWKjNv8.js.map} +1 -1
  77. package/dist/{relation-picker-dialog-Duqy2r0n.cjs → relation-picker-dialog-mbwyNK43.cjs} +4 -4
  78. package/dist/{relation-picker-dialog-Duqy2r0n.cjs.map → relation-picker-dialog-mbwyNK43.cjs.map} +1 -1
  79. package/dist/{relation-select-C3aV18kT.cjs → relation-select-CguIo2M5.cjs} +2 -2
  80. package/dist/{relation-select-C3aV18kT.cjs.map → relation-select-CguIo2M5.cjs.map} +1 -1
  81. package/dist/{relation-select-CjQT9LpS.js → relation-select-nAYxhopN.js} +2 -2
  82. package/dist/{relation-select-CjQT9LpS.js.map → relation-select-nAYxhopN.js.map} +1 -1
  83. package/dist/{use-dialog-filter-state-lsTJxrB4.cjs → use-dialog-filter-state-CpWblz3C.cjs} +2 -2
  84. package/dist/{use-dialog-filter-state-lsTJxrB4.cjs.map → use-dialog-filter-state-CpWblz3C.cjs.map} +1 -1
  85. package/dist/{use-dialog-filter-state-CJoeY-1j.js → use-dialog-filter-state-ZYxOp5WO.js} +2 -2
  86. package/dist/{use-dialog-filter-state-CJoeY-1j.js.map → use-dialog-filter-state-ZYxOp5WO.js.map} +1 -1
  87. package/dist/{use-record-subtitle-BJ9rnj6F.cjs → use-record-subtitle-B4lTR7pf.cjs} +2 -2
  88. package/dist/{use-record-subtitle-BJ9rnj6F.cjs.map → use-record-subtitle-B4lTR7pf.cjs.map} +1 -1
  89. package/dist/{use-record-subtitle-w3ZhXNlf.js → use-record-subtitle-pWMBqQx9.js} +2 -2
  90. package/dist/{use-record-subtitle-w3ZhXNlf.js.map → use-record-subtitle-pWMBqQx9.js.map} +1 -1
  91. package/package.json +9 -9
  92. package/dist/bulk-summary-2HLgz7Il.cjs.map +0 -1
  93. package/dist/bulk-summary-D6A0ua21.js.map +0 -1
  94. package/dist/check-confirm-dialog-W-8WOmGh.cjs.map +0 -1
  95. package/dist/flow-screen-DY1Z9PbG.js.map +0 -1
  96. package/dist/flow-screen-FE5Xhb3t.cjs.map +0 -1
  97. package/dist/lazy-relation-picker-dialog-BaORufxQ.js.map +0 -1
  98. package/dist/lazy-relation-picker-dialog-C_VlGlDz.cjs.map +0 -1
  99. package/dist/page-flow-route-CyMzUidK.js.map +0 -1
  100. package/dist/page-flow-route-OFx7h7Ja.cjs.map +0 -1
  101. package/dist/place-node-BZF5Af6x.cjs.map +0 -1
  102. package/dist/place-node-DRjmJGQ_.js.map +0 -1
  103. package/dist/relation-create-6WicROWA.js.map +0 -1
  104. package/dist/relation-create-_SFuPQGM.cjs.map +0 -1
  105. package/dist/resource-page-router-CzaNATSp.js +0 -2010
  106. package/dist/resource-page-router-CzaNATSp.js.map +0 -1
  107. package/dist/resource-page-router-dmVIeu5s.cjs +0 -2231
  108. package/dist/resource-page-router-dmVIeu5s.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-screen-DY1Z9PbG.js","names":[],"sources":["../src/flows/review-diff.tsx","../src/flows/flow-screen.tsx"],"sourcesContent":["'use client';\nimport { fieldSensitivity, humanizeKey, type Row } from '@burojs/core';\nimport { type FormController, useOptionalT } from '@burojs/react';\nimport type { ReactElement } from 'react';\nimport { FieldDisplay } from '../forms/field.js';\n\n/** The built-in review block of a flow (`review: true`, P4 spec 4.4). */\nexport const REVIEW_DIFF_BLOCK = 'buro:review-diff';\n\nexport interface ReviewDiffProps {\n /** The flow's form: its active fields, their definitions and labels. */\n readonly form: FormController;\n /** The values the form opened on (`form.initial`): the baseline of the diff. */\n readonly initial: Row;\n /** The values as they will be submitted. */\n readonly values: Row;\n /** Text and doc keys of the form (`<resource>.actions.<name>`). */\n readonly i18nPrefix: string;\n /** The test id base (the flow's host). */\n readonly testid: string;\n}\n\n/** Whether a field is `sensitive` (a mark or a mask). */\nfunction sensitive(definition: unknown): boolean {\n if (fieldSensitivity(definition) !== undefined) return true;\n if (definition === null || typeof definition !== 'object') return false;\n const opts = (definition as { readonly opts?: unknown }).opts;\n const marked =\n opts !== null && typeof opts === 'object'\n ? (opts as { readonly sensitive?: unknown }).sensitive\n : undefined;\n return marked !== undefined && marked !== false && marked !== null;\n}\n\nconst same = (a: unknown, b: unknown): boolean => {\n if (Object.is(a, b)) return true;\n const empty = (value: unknown) => value === undefined || value === null || value === '';\n if (empty(a) && empty(b)) return true;\n try {\n return JSON.stringify(a) === JSON.stringify(b);\n } catch {\n return false;\n }\n};\n\n/**\n * The review of a flow (`review: true`, 4.4): one row per active form field whose value differs\n * from the one the form opened on — its label, the old display value and the new one. A\n * `sensitive` field says \"changed\" and shows no value, old or new.\n */\nexport function ReviewDiff({\n form,\n initial,\n values,\n i18nPrefix,\n testid,\n}: ReviewDiffProps): ReactElement {\n const t = useOptionalT();\n const changedText = t('review.changed', { defaultValue: 'changed' });\n const rows = form.fields.filter((binding) => !same(initial[binding.name], values[binding.name]));\n return (\n <dl data-testid={`${testid}:review`} data-buro-block={REVIEW_DIFF_BLOCK} className=\"grid gap-2\">\n {rows.map((binding) => {\n const definition = binding.field as unknown as { readonly label?: unknown };\n const label =\n typeof definition.label === 'string' ? definition.label : humanizeKey(binding.name);\n const hidden = sensitive(binding.field);\n return (\n <div\n key={binding.name}\n data-testid={`${testid}:review:${binding.name}`}\n className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] gap-2 text-sm\"\n >\n <dt className=\"font-medium\">{label}</dt>\n <dd className=\"flex flex-wrap items-center gap-2\">\n {hidden ? (\n <span className=\"text-muted-foreground\">{changedText}</span>\n ) : (\n <>\n <span data-buro-review=\"old\" className=\"text-muted-foreground line-through\">\n <FieldDisplay\n i18nPrefix={i18nPrefix}\n name={binding.name}\n field={binding.field as never}\n value={initial[binding.name]}\n fallback={<span>{display(initial[binding.name])}</span>}\n />\n </span>\n <span aria-hidden=\"true\">→</span>\n <span data-buro-review=\"new\">\n <FieldDisplay\n i18nPrefix={i18nPrefix}\n name={binding.name}\n field={binding.field as never}\n value={values[binding.name]}\n fallback={<span>{display(values[binding.name])}</span>}\n />\n </span>\n </>\n )}\n </dd>\n </div>\n );\n })}\n </dl>\n );\n}\n\nconst display = (value: unknown): string =>\n value === undefined || value === null || value === '' ? '—' : String(value);\n","'use client';\nimport {\n type CompiledFlow,\n type FlowResult,\n type FlowRun,\n declaredText,\n flowRecordOf,\n type FlowSnapshot,\n type PropValidation,\n textsValueAt,\n validatePlacementProps,\n} from '@burojs/core';\nimport {\n BulkSelectionScope,\n type ErrorTextCaps,\n REJECTED_KEYS,\n specificErrorText,\n type FlowScreenProps,\n type FlowStart,\n ScreenStateProvider,\n resolveValidationMessage,\n useFlowOpenImplementation,\n useCurrentUserId,\n useDismissHold,\n useDismissPending,\n useFlowFormCatalog,\n useNavigationBlocker,\n useOptionalRouterAdapter,\n useFormController,\n useI18nCaps,\n useChromeT,\n useOptionalT,\n useProjectedTitle,\n useTestIds,\n useUIInstance,\n useUIPresentationRuntime,\n} from '@burojs/react';\nimport { fieldEntriesToMap } from '@burojs/core/internal';\nimport {\n FlowTextsScope,\n useFlowFieldConditions,\n useFlowForm,\n useFlowMetaSources,\n useFlowRun,\n} from '@burojs/react/flows';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { IconLoader2, IconX } from '@tabler/icons-react';\nimport {\n type ReactElement,\n type ReactNode,\n Suspense,\n createContext,\n useContext,\n useMemo,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { DocInfo } from '../doc/doc-info.js';\nimport { useNoticeSink } from '../forms/success-notices.js';\nimport { reasonText } from '../lib/reason-text.js';\nimport { Button } from '../primitives/button.js';\nimport { FormControlProvider, useFormControlOf } from '../resource/form-context.js';\nimport { ScreenTree } from '../screen/screen-tree.js';\nimport { selectImplementation, viewOf } from '../blocks/place-node.js';\nimport { ReviewDiff } from './review-diff.js';\nimport { OwnTitleContext } from '../ui-presentations/shell.js';\nimport { OwnTitleHeading, useFocusOnMount } from './overlay-heading.js';\n\n/**\n * Thrown from the form controller's write: the controller validated (and revealed the first\n * failing field), and the run — not the controller — sends. A write that throws leaves the form\n * dirty and its draft in place (the controller re-baselines only on a write that resolves), and\n * an abort-shaped value is no reportable failure.\n */\nconst HELD = Object.freeze({ name: 'AbortError', message: 'The flow run sends the values.' });\n\n/**\n * How the flow screen leaves its host (P6): an overlay dismisses its presentation instance, a\n * page navigates to the record through the guard, an inline placement shows the next form. The\n * screen asks `close()` for Cancel, ✕ and Back, and `finish()` once a success needs nothing more\n * shown (no `then.open: { block }`).\n * @internal\n */\nexport interface FlowHostBinding {\n readonly kind: 'overlay' | 'page' | 'inline';\n close(): void;\n finish(): void;\n}\n\n/** @internal Provided by the page and inline hosts; an overlay builds its own. */\n/** @internal */\nexport function HostedFlowScreen(\n props: FlowScreenProps & { readonly binding: FlowHostBinding },\n): ReactElement | null {\n const { binding, ...rest } = props;\n return (\n <FlowHostBindingContext.Provider value={binding}>\n <FlowScreen {...rest} />\n </FlowHostBindingContext.Provider>\n );\n}\n\nexport const FlowHostBindingContext = createContext<FlowHostBinding | null>(null);\n\n/** Gives the screen below it the overlay's binding: its presentation instance. */\nfunction OverlayBinding({ children }: { readonly children: ReactNode }): ReactElement {\n const instance = useUIInstance();\n const runtime = useUIPresentationRuntime();\n const binding = useMemo<FlowHostBinding>(\n () => ({\n kind: 'overlay',\n close: () => instance.dismiss(),\n finish: () => runtime.dismiss(instance.id),\n }),\n [instance, runtime],\n );\n return (\n <FlowHostBindingContext.Provider value={binding}>{children}</FlowHostBindingContext.Provider>\n );\n}\n\n/** The screen's binding when a page or inline host provided one, else the overlay's. */\nfunction WithBinding({ children }: { readonly children: ReactNode }): ReactElement {\n const provided = useContext(FlowHostBindingContext);\n return provided !== null ? <>{children}</> : <OverlayBinding>{children}</OverlayBinding>;\n}\n\ntype Translate = ReturnType<typeof useOptionalT>;\n\n/**\n * What the outcome area says, or `null` when the screen has nothing to report. A rejection reads\n * the specific text of its code first (spec 4.15 steps 1 to 4: the flow's `<textPrefix>.validation.<code>`\n * and declared `texts.validation`, the provider's reference, the shared code texts). Only when none\n * resolves does a mapped kind read the flow's own `<textPrefix>.rejected.<kind>`, then its declared\n * `texts.rejected.<kind>` (`flow`), before the framework's neutral `flow.rejected.<kind>`;\n * `textPrefix` is the compiled flow's `textKeys.prefix`.\n */\nfunction outcomeMessage(\n snapshot: FlowSnapshot,\n busy: boolean,\n t: Translate,\n caps: ErrorTextCaps,\n textPrefix: string,\n flow: { readonly texts?: unknown } | undefined,\n reasonOf: (reason: string) => string,\n): string | null {\n if (busy)\n return t('flow.busyElsewhere', { defaultValue: 'This action is running in another tab.' });\n const outcome = snapshot.outcome;\n if (outcome === undefined || outcome.outcome === 'success') {\n // A check that could not decide blocks the flow (4.3): its reason, with Retry.\n if (snapshot.control === 'disabled' && snapshot.reason !== undefined)\n return reasonOf(snapshot.reason);\n return null;\n }\n if (outcome.outcome === 'unknown')\n return [\n outcome.applied === 'partial'\n ? t('flow.unknownPartial', {\n defaultValue: 'Part of this may have been applied. Nothing was resent.',\n })\n : t('flow.unknown', {\n defaultValue: 'It may have been applied. Nothing was resent.',\n }),\n ...(snapshot.reason === undefined ? [] : [reasonOf(snapshot.reason)]),\n ].join(' ');\n if (outcome.outcome === 'rejected') {\n if (snapshot.reason !== undefined) return reasonOf(snapshot.reason);\n const kind = 'kind' in outcome ? outcome.kind : undefined;\n const code = 'code' in outcome ? outcome.code : undefined;\n if (code !== undefined) {\n const specific = specificErrorText(\n {\n code,\n ...('message' in outcome && outcome.message !== undefined\n ? { message: outcome.message }\n : {}),\n },\n caps,\n { action: { prefix: textPrefix, texts: flow?.texts } },\n );\n if (specific !== undefined) return specific;\n }\n const key = kind === undefined ? undefined : REJECTED_KEYS[kind];\n if (key !== undefined)\n return t(`${textPrefix}.rejected.${key}`, {\n defaultValue:\n textsValueAt(flow?.texts, ['rejected', key]) ??\n t(`flow.rejected.${key}`, { defaultValue: 'Nothing was saved.' }),\n });\n return t('flow.rejected.precondition', {\n defaultValue: 'The record changed. Nothing was sent.',\n });\n }\n if (outcome.outcome === 'failed') {\n if (snapshot.reason !== undefined) return reasonOf(snapshot.reason);\n // The code's own text first (spec 4.15), as the bulk summary and the record frame read it.\n const code = 'code' in outcome ? outcome.code : undefined;\n const specific =\n code === undefined\n ? undefined\n : specificErrorText(\n {\n code,\n ...('message' in outcome && outcome.message !== undefined\n ? { message: outcome.message }\n : {}),\n },\n caps,\n { action: { prefix: textPrefix, texts: flow?.texts } },\n );\n return (\n specific ??\n t('flow.failed', { defaultValue: 'The request could not be sent. Nothing was saved.' })\n );\n }\n return null;\n}\n\n/**\n * The UI kit's flow host screen (`presentationHosts.screens.flow`, presented under `buro:flow`;\n * P4 spec 4.15, 4.19): the action's label and the record's title with its «i» and ✕; the form\n * (a `steps` body is a wizard), the final screen's warnings and `confirm`, and the outcome\n * screens; a footer of Back, Cancel and the submit button, labelled with the action's label and\n * its pending text while the write runs.\n *\n * The presentation is a dismiss scope (P3-30): Escape, an outside click, ✕ and Cancel close\n * through it, so a dirty form asks first; Back between steps stays in the host and asks nothing.\n * From the send to the outcome the screen holds the scope's pending lock — nothing closes it,\n * and the run holds every route change. `success` closes the host without asking; `rejected`\n * and `failed` return to the dirty form; `unknown` closes without asking and keeps the attempt.\n */\nexport function FlowScreen(props: FlowScreenProps): ReactElement | null {\n if (props.run !== undefined && props.compiled !== undefined)\n return <HeldFlowScreen {...props} run={props.run} compiled={props.compiled} />;\n if (props.start !== undefined) return <OwnedFlowScreen {...props} start={props.start} />;\n return null;\n}\n\ntype HeldProps = FlowScreenProps & { readonly run: FlowRun; readonly compiled: CompiledFlow };\n\n/**\n * A bulk run's record frame (read-scope spec 4, rule 1): the form's `'context'` reads take the\n * value every selected row agrees on, else the session's. A run without a selection adds nothing.\n */\nfunction SelectionScope(props: {\n readonly selection: FlowScreenProps['selection'];\n readonly resource: string | null;\n readonly children: ReactNode;\n}): ReactElement {\n if (props.selection === undefined || props.resource === null) return <>{props.children}</>;\n return (\n <BulkSelectionScope resource={props.resource} ids={props.selection.ids}>\n {props.children}\n </BulkSelectionScope>\n );\n}\n\n/** The screen over a run it is given. */\nfunction HeldFlowScreen(props: HeldProps): ReactElement {\n // \"I've checked — start over\" (4.8) opens a fresh form: the body mounts again, so the form\n // takes the run's fresh values as its baseline and offers the stored draft.\n const [generation, setGeneration] = useState(0);\n // An app flow's form reads its texts in its `common.appActions.<name>` entry.\n return (\n <FlowTextsScope compiled={props.compiled}>\n <WithBinding>\n <ScreenStateProvider key={generation}>\n <SelectionScope selection={props.selection} resource={props.compiled.resource}>\n <FlowScreenBody {...props} onFreshForm={() => setGeneration((value) => value + 1)} />\n </SelectionScope>\n </ScreenStateProvider>\n </WithBinding>\n </FlowTextsScope>\n );\n}\n\n/**\n * The host owning its run (P4-C review I1): the run lives as long as the host, not as long as\n * the control that opened it — a row that left the page, a menu item that closed — so a dirty\n * form still asks before it closes and a pending write still holds its lock. `then` waits until\n * the host has gone (its form and its blocker with it), then runs through the opener's\n * dispatcher scope; each outcome is reported to the opener.\n */\nfunction OwnedFlowScreen(props: FlowScreenProps & { readonly start: FlowStart }): ReactElement {\n const { start, effects, onSettle } = props;\n const flow = useFlowRun(start.target, {\n ...(start.record === undefined ? {} : { record: start.record }),\n ...(start.args === undefined ? {} : { args: start.args }),\n ...(start.selection === undefined ? {} : { selection: start.selection }),\n surface: 'host',\n ...(effects === undefined ? {} : { thenEffects: effects }),\n });\n // `then` is the host's to run, after it closed.\n flow.holdThen(true);\n const latest = useRef(flow);\n latest.current = flow;\n useEffect(\n () => () => {\n // After the commit that removed the host: its form's blocker is gone.\n setTimeout(() => {\n latest.current.holdThen(false);\n latest.current.runThen();\n }, 0);\n },\n [],\n );\n const { run, snapshot, compiled } = flow;\n const outcome = snapshot.outcome;\n useEffect(() => {\n if (outcome !== undefined) onSettle?.(outcome);\n }, [outcome, onSettle]);\n const instance = useUIInstance();\n const t = useOptionalT();\n const caps = useI18nCaps(compiled?.resource ?? undefined);\n const tid = useTestIds();\n const opened =\n run !== null &&\n compiled !== null &&\n (snapshot.history.includes('open') || snapshot.step === 'outcome');\n if (opened) return <HeldFlowScreen {...props} run={run} compiled={compiled} />;\n // Not opened yet: its gate, its sources and a stored attempt decide first. A run that\n // decided against opening says why.\n const refused = snapshot.control === 'disabled' || snapshot.control === 'absent';\n return (\n <div\n data-testid={compiled === null ? undefined : `${tid.flowHost(compiled.flowId)}:opening`}\n data-buro-host={props.host}\n data-buro-flow-step={refused ? 'refused' : 'opening'}\n aria-busy={refused ? undefined : 'true'}\n className=\"flex min-h-0 flex-1 flex-col gap-4\"\n >\n <OwnTitleHeading label={props.label} />\n {refused ? (\n <p role=\"alert\" className=\"text-sm\">\n {snapshot.reason === undefined\n ? t('flow.unavailable', { defaultValue: 'Not allowed.' })\n : reasonText(caps, snapshot.reason, compiled?.resource ?? undefined)}\n </p>\n ) : (\n <IconLoader2 className=\"h-5 w-5 animate-spin self-center\" aria-hidden=\"true\" />\n )}\n <div className=\"flex justify-end\">\n <Button type=\"button\" variant=\"ghost\" onClick={() => instance.dismiss()}>\n {t('flow.close', { defaultValue: 'Close' })}\n </Button>\n </div>\n </div>\n );\n}\n\nfunction FlowScreenBody({\n run,\n host,\n label,\n title: givenTitle,\n compiled,\n record: givenRecord,\n args,\n selection,\n onFreshForm,\n}: HeldProps & { readonly onFreshForm: () => void }): ReactElement {\n // A collection-level flow has no record, whoever passed one (spec 5.1): its title, its form and\n // its review read none.\n const record = flowRecordOf(compiled, givenRecord);\n const snapshot = useSyncSnapshot(run);\n const binding = useContext(FlowHostBindingContext) as FlowHostBinding;\n const tid = useTestIds();\n const t = useOptionalT();\n const chromeT = useChromeT();\n const resource = compiled.resource ?? undefined;\n const caps = useI18nCaps(resource);\n const ownTitle = useContext(OwnTitleContext);\n const flowId = compiled.flowId;\n const recordId = record?.[compiled.idField] ?? record?.id;\n const recordTitle = useProjectedTitle(resource, recordId, record);\n const title =\n givenTitle ?? (record === undefined || recordTitle === '' ? undefined : recordTitle);\n const form = useFlowForm(run, compiled, snapshot, {\n ...(record === undefined ? {} : { record }),\n ...(args === undefined ? {} : { args }),\n ...(selection === undefined ? {} : { selection: selection.ids }),\n });\n const formControl = useFormControlOf(form);\n const hasForm = compiled.flow.form !== undefined;\n const [busy, setBusy] = useState(false);\n // The values the form opened on: the review's baseline (4.4). The host opens on an opened run,\n // before anything was typed.\n const [initial] = useState(() => run.getSnapshot().values);\n // Form-level messages: a server's validation refusal on a key no field holds (M14), a\n // resource-level validator's.\n const formErrors = form.errors.filter((issue) => issue.field === '_form');\n\n // The pending lock (4.19): from the re-read to the persisted outcome nothing closes the host.\n const locked = snapshot.control === 'running';\n\n const outcome = snapshot.outcome?.outcome;\n const unknown = outcome === 'unknown';\n const succeeded = outcome === 'success';\n const finalStep = snapshot.step === 'review' || snapshot.step === 'accept';\n\n // `success` closes the host, unasked: nothing unsaved remains (4.19). The run settled the\n // mutation's effects before it answered (4.13).\n // `then.open: { block, props }` keeps the host and draws the block instead (4.13): its close is\n // the block's own button and ✕, and `result` goes with the host.\n const openBlock = succeeded ? blockOpen(snapshot.effects?.open) : null;\n useDismissPending(locked);\n // `dismiss: 'explicit'` (L3 9.14): while the block shows, the overlay drops its own Escape,\n // outside click and every guarded dismiss aimed at it (the block's own included); the header ✕\n // is not drawn and the host's Done button closes it. Everything from outside the window asks\n // through the navigation guard, as a dirty form does: a route change, Back, a reload, and\n // closing an enclosing overlay (an inline host's sheet, a quick sheet the flow was opened\n // from). A change of the signed-in user releases the guard: sign-out is never held.\n const held = openBlock?.dismiss === 'explicit';\n const userId = useCurrentUserId();\n // The user the held window was shown to: captured when it is first held (not at mount, when the\n // id may still be loading), forgotten when it is released. An idempotent write per render.\n const heldBy = useRef<{ readonly id: string | null } | null>(null);\n if (!held) heldBy.current = null;\n else if (heldBy.current === null) heldBy.current = { id: userId };\n const guarding = held && userId === heldBy.current?.id;\n const leaveGuard = useNavigationBlocker(guarding);\n const hold = useDismissHold(guarding && binding.kind === 'overlay');\n // A confirmed route change leaves the page the window was opened over: close it with it, even\n // when its opener stays mounted (an app-level button).\n const pathname = useOptionalRouterAdapter()?.pathname;\n const heldAt = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!held || binding.kind !== 'overlay') {\n heldAt.current = undefined;\n return;\n }\n if (heldAt.current === undefined) heldAt.current = pathname;\n else if (heldAt.current !== pathname) {\n hold.close();\n binding.finish();\n }\n }, [held, pathname, binding, hold]);\n // The write's own notices (spec 4.7), once per success, before the host closes.\n const showNotices = useNoticeSink(resource);\n const shownNotices = useRef<unknown>(null);\n useEffect(() => {\n if (!succeeded || snapshot.notices.length === 0 || shownNotices.current === snapshot.notices)\n return;\n shownNotices.current = snapshot.notices;\n showNotices(snapshot.notices);\n }, [succeeded, snapshot.notices, showNotices]);\n useEffect(() => {\n if (succeeded && !locked && openBlock === null) binding.finish();\n }, [succeeded, locked, openBlock, binding]);\n\n const prefix =\n compiled.resource === null\n ? `appActions.${compiled.name}`\n : `${compiled.resource}.actions.${compiled.name}`;\n\n const settle = (result: FlowResult) => {\n setBusy(result.outcome === 'failed' && 'reason' in result && result.reason === 'busy');\n };\n const submit = async () => {\n if (locked) return;\n setBusy(false);\n if (finalStep) {\n settle(await run.accept());\n return;\n }\n if (unknown && editingNew) {\n // Send as new: the form as filled now, validated, then the confirmation (P4-C review C2).\n let valid = false;\n await form.handleSubmit(() => {\n valid = true;\n throw HELD;\n })();\n if (valid) setConfirmingNew(true);\n return;\n }\n if (unknown) return;\n if (hasForm) {\n // The controller validates the active fields and reveals the first failing one (its step\n // included); the run sends.\n let validated = false;\n await form.handleSubmit(() => {\n validated = true;\n throw HELD;\n })();\n if (!validated) return;\n }\n settle(await run.submit());\n };\n\n const pendingKey =\n compiled.resource === null\n ? `appActions.${compiled.name}.pending`\n : `resources.${compiled.resource}.actions.${compiled.name}.pending`;\n const pendingLabel = caps.has(pendingKey) ? caps.t(pendingKey) : `${label}…`;\n const message = outcomeMessage(\n snapshot,\n busy,\n t,\n caps,\n compiled.textKeys.prefix,\n compiled.flow,\n (reason) => reasonText(caps, reason, resource),\n );\n // The form-level issues, resolved here so a language switch re-renders them; one that says\n // what the outcome heading already says is not shown twice.\n const formErrorTexts = formErrors\n .map((issue) =>\n resolveValidationMessage(\n {\n code: issue.code ?? '',\n message: issue.message,\n ...(issue.check === undefined ? {} : { check: issue.check }),\n },\n { has: caps.has, t: caps.t },\n ),\n )\n .filter((text) => text !== message);\n // The flow's own word for its cancel buttons (`<prefix>.dismiss`, then its declared\n // `texts.dismiss`), else the kit's.\n const dismissKey = `${compiled.textKeys.prefix}.dismiss`;\n const cancelWord =\n (caps.has(dismissKey) ? caps.t(dismissKey) : undefined) ??\n declaredText('flow', compiled.flow, 'dismiss') ??\n chromeT('actions.cancel', { defaultValue: 'Cancel' });\n // The run flags a check that could not decide; its reason is a translation, never compared.\n const couldNotCheck = snapshot.control === 'disabled' && snapshot.unverified === true;\n const steps = form.steps;\n const lastStep =\n steps === null || steps.ids.length === 0 || steps.current === steps.ids[steps.ids.length - 1];\n const showSubmit = !unknown && !succeeded && (!hasForm || finalStep || lastStep);\n // The unknown screen's exits (4.8).\n const [confirmingNew, setConfirmingNew] = useState(false);\n // Send as new sends the form as it is now (4.8): the user fills it again and it is validated\n // first — after a reload it holds only its initial values (P4-C review C2).\n const [editingNew, setEditingNew] = useState(false);\n const checkable = compiled.flow.submit.onUnknown !== undefined;\n const unhandled = unknown && !checkable && !snapshot.canResend;\n const exit = (action: () => Promise<FlowResult>) => () => {\n if (!locked) void action().then(settle);\n };\n // An overlay's Cancel keeps the draft so it survives the close (4.19); an inline Reset means\n // \"start over\", so the next form must not offer the input it just threw away (REF-51). An\n // unknown outcome's Close keeps it, like every unresolved attempt (4.11).\n const close = () => {\n if (binding.kind === 'inline' && hasForm && !unknown) form.draft.discard();\n binding.close();\n };\n\n const headingRef = useRef<HTMLHeadingElement>(null);\n useFocusOnMount(headingRef);\n // When a `then.open` block replaces the form, focus goes to its Done button (the heading where\n // no Done is drawn): the hidden form took the focused submit button with it.\n const doneRef = useRef<HTMLButtonElement>(null);\n const blockShown = openBlock !== null;\n useEffect(() => {\n if (blockShown) (doneRef.current ?? headingRef.current)?.focus();\n }, [blockShown]);\n const heading = (\n <h2\n ref={headingRef}\n tabIndex={-1}\n data-buro-overlay-heading=\"\"\n className=\"min-w-0 flex-1 break-words text-lg font-semibold tracking-tight focus-visible:outline-hidden\"\n >\n {label}\n {title === undefined ? null : (\n <span className=\"font-normal text-muted-foreground\">\n {/* Text, not margin: the dialog's accessible name is its text, which would glue the two. */}\n {' — '}\n {title}\n </span>\n )}\n </h2>\n );\n\n return (\n <div\n data-testid={tid.flowHost(flowId)}\n data-buro-host={host}\n data-buro-flow-step={snapshot.step}\n aria-busy={locked ? 'true' : undefined}\n className=\"flex min-h-0 flex-1 flex-col gap-4\"\n >\n {binding.kind === 'inline' ? null : (\n <div data-buro-region=\"flow-header\" className=\"flex items-center gap-2 pr-1\">\n {ownTitle ? <DialogPrimitive.Title asChild>{heading}</DialogPrimitive.Title> : heading}\n {compiled.resource === null ? null : (\n <DocInfo\n address={`${compiled.resource}/actions/${compiled.name}`}\n name={label}\n testId={`${tid.flowHost(flowId)}:info`}\n />\n )}\n {binding.kind === 'overlay' && !held ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-8 w-8 shrink-0\"\n data-testid={tid.flowClose(flowId)}\n aria-label={t('flow.close', { defaultValue: 'Close' })}\n onClick={close}\n >\n <IconX className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n ) : null}\n </div>\n )}\n {openBlock !== null ? (\n <FlowOpenBlock open={openBlock} prefix={prefix} testid={tid.flowHost(flowId)} />\n ) : null}\n {openBlock !== null && (binding.kind !== 'overlay' || held) ? (\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n variant=\"outline\"\n ref={doneRef}\n data-testid={tid.flowClose(flowId)}\n onClick={() => {\n // Done is the window's own way out: its guard lets it go first (a page host's\n // close is a guarded navigation to the record).\n leaveGuard.release();\n if (held && binding.kind === 'overlay') {\n // Unconditionally, with every overlay the block opened above it (M4).\n hold.close();\n binding.finish();\n } else close();\n }}\n >\n {t('flow.done', { defaultValue: 'Done' })}\n </Button>\n </div>\n ) : null}\n <form\n hidden={openBlock !== null}\n noValidate\n className={openBlock === null ? 'flex min-h-0 flex-1 flex-col gap-4' : 'hidden'}\n onSubmit={(event) => {\n event.preventDefault();\n void submit();\n }}\n >\n <div className=\"-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-1\">\n {message === null ? null : (\n <div\n role={unknown || outcome === 'rejected' || outcome === 'failed' ? 'alert' : 'status'}\n data-testid={tid.flowOutcome(flowId)}\n data-buro-flow-outcome={busy ? 'busy' : (outcome ?? snapshot.control)}\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n <span>{message}</span>\n {couldNotCheck ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n onClick={() => run.retryChecks()}\n >\n {chromeT('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n ) : null}\n </div>\n )}\n {hasForm && form.draft.pending !== null && (!unknown || editingNew) ? (\n <div\n data-testid={tid.flowDraft(flowId)}\n role=\"status\"\n aria-live=\"polite\"\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm\"\n >\n <span className=\"font-medium\">\n {t('draft.restorePrompt', { defaultValue: 'Restore draft?' })}\n </span>\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n data-testid={`${tid.flowDraft(flowId)}:restore`}\n onClick={form.draft.restore}\n >\n {t('draft.restore', { defaultValue: 'Restore' })}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n data-testid={`${tid.flowDraft(flowId)}:discard`}\n onClick={form.draft.discard}\n >\n {t('draft.discard', { defaultValue: 'Discard' })}\n </Button>\n </div>\n </div>\n ) : null}\n {formErrorTexts.length > 0 ? (\n <div\n role=\"alert\"\n data-testid={`${tid.flowHost(flowId)}:form-errors`}\n className=\"flex flex-col gap-1 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n {formErrorTexts.map((text, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: one failed write's fixed list\n <p key={index}>{text}</p>\n ))}\n </div>\n ) : null}\n {finalStep && compiled.flow.review === true ? (\n <ReviewDiff\n form={form}\n initial={initial}\n values={snapshot.values}\n i18nPrefix={prefix}\n testid={tid.flowHost(flowId)}\n />\n ) : finalStep && Array.isArray(compiled.flow.review) ? (\n <ReviewTree\n compiled={compiled}\n tree={compiled.flow.review}\n values={snapshot.values}\n prefix={prefix}\n run={run}\n {...(record === undefined ? {} : { record })}\n {...(args === undefined ? {} : { args })}\n />\n ) : hasForm ? (\n <FormControlProvider value={formControl}>\n <ScreenTree\n region=\"form-body\"\n resource={prefix}\n mode=\"create\"\n compiled={form.screen}\n controller={form}\n // The record scheme: the leaves carry `form-field-input:<prefix>:create:<name>`\n // test ids, and their texts key as `resources.<prefix>.fields.<name>.…` (4.4).\n leafIds=\"record\"\n disabled={locked || (unknown && !editingNew) || finalStep || succeeded}\n />\n </FormControlProvider>\n ) : null}\n {finalStep && snapshot.warnings.length > 0 ? (\n <ul\n role=\"status\"\n data-buro-region=\"flow-warnings\"\n className=\"flex flex-col gap-1 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm text-warning-emphasis\"\n >\n {snapshot.warnings.map((warning) => (\n <li key={warning.id} data-testid={`${tid.flowHost(flowId)}:warning:${warning.id}`}>\n {warning.message}\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n {unhandled ? (\n <p data-testid={`${tid.flowOutcome(flowId)}:unhandled`} className=\"text-sm\">\n {t('flow.unknownUnhandled', { defaultValue: 'Check the record before trying again.' })}\n </p>\n ) : null}\n {unknown && confirmingNew ? (\n <div\n role=\"alertdialog\"\n aria-label={t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n data-testid={`${tid.flowSendAsNew(flowId)}:confirm`}\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm\"\n >\n <span>\n {t('flow.sendAsNewConfirm', {\n defaultValue: 'This may apply the change twice. Send it as a new request?',\n })}\n </span>\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n data-testid={`${tid.flowSendAsNew(flowId)}:cancel`}\n onClick={() => setConfirmingNew(false)}\n >\n {cancelWord}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n data-testid={`${tid.flowSendAsNew(flowId)}:ok`}\n onClick={() => {\n setConfirmingNew(false);\n exit(() => run.sendAsNew({ confirmed: true }))();\n }}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n </div>\n </div>\n ) : null}\n {unknown ? (\n <div data-buro-region=\"flow-unknown-exits\" className=\"flex flex-wrap gap-2\">\n {checkable ? (\n <Button\n type=\"button\"\n variant=\"default\"\n data-testid={tid.flowCheckAgain(flowId)}\n disabled={locked}\n onClick={exit(() => run.checkAgain())}\n >\n {t('flow.checkAgain', { defaultValue: 'Check again' })}\n </Button>\n ) : null}\n {snapshot.canResend ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowResend(flowId)}\n disabled={locked}\n onClick={exit(() => run.resend())}\n >\n {t('flow.resend', { defaultValue: 'Resend' })}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowSendAsNew(flowId)}\n disabled={locked || confirmingNew || editingNew}\n onClick={() => {\n if (hasForm) setEditingNew(true);\n else setConfirmingNew(true);\n }}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowStartOver(flowId)}\n disabled={locked}\n onClick={() => {\n run.startOver();\n onFreshForm();\n }}\n >\n {t('flow.startOver', { defaultValue: \"I've checked — start over\" })}\n </Button>\n </div>\n ) : null}\n <div data-buro-region=\"flow-footer\" className=\"flex flex-wrap items-center gap-2\">\n {finalStep && hasForm && !locked ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowBack(flowId)}\n onClick={() => run.back()}\n >\n {t('flow.back', { defaultValue: 'Back' })}\n </Button>\n ) : null}\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n data-testid={tid.flowCancel(flowId)}\n disabled={locked}\n onClick={close}\n >\n {unknown\n ? t('flow.close', { defaultValue: 'Close' })\n : binding.kind === 'inline'\n ? t('flow.reset', { defaultValue: 'Reset' })\n : cancelWord}\n </Button>\n {unknown && editingNew ? (\n <Button\n type=\"submit\"\n variant=\"destructive\"\n data-testid={`${tid.flowSendAsNew(flowId)}:submit`}\n disabled={locked || confirmingNew}\n onMouseDown={(event) => event.preventDefault()}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n ) : null}\n {showSubmit ? (\n <Button\n type=\"submit\"\n variant={compiled.flow.variant === 'destructive' ? 'destructive' : 'default'}\n data-testid={tid.flowSubmit(flowId)}\n disabled={locked || couldNotCheck}\n aria-busy={locked ? 'true' : undefined}\n // Without this, focusing out of a field a blur error just inserted moves the\n // button, and the click that lands on its old position is swallowed.\n onMouseDown={(event) => event.preventDefault()}\n >\n {locked ? (\n <IconLoader2 className=\"h-4 w-4 animate-spin\" aria-hidden=\"true\" />\n ) : null}\n {locked ? pendingLabel : label}\n </Button>\n ) : null}\n </div>\n </div>\n </form>\n </div>\n );\n}\n\n/** The run's snapshot, re-rendering on each change. */\nfunction useSyncSnapshot(run: FlowRun): FlowSnapshot {\n return useSyncExternalStore(run.subscribe, run.getSnapshot, run.getSnapshot);\n}\n\nconst NO_FIELDS = Object.freeze({});\n\n/**\n * `review: (l) => [...]` (4.4): a show tree over the flow's values — displays and placements\n * only, no inputs — drawn by a show-mode form over the flow's fields.\n */\nfunction ReviewTree({\n compiled,\n tree,\n values,\n prefix,\n run,\n record,\n args,\n}: {\n readonly compiled: CompiledFlow;\n readonly tree: readonly unknown[];\n readonly values: Readonly<Record<string, unknown>>;\n readonly prefix: string;\n readonly run: FlowRun;\n readonly record?: Row;\n readonly args?: Row;\n}): ReactElement {\n const fields = compiled.flow.form?.fields;\n // A review places what it shows: a field the tree does not place leaves the show mode (its\n // `in`), so a review of blocks alone (spec 3.6) is not refused for the fields it leaves out.\n const map = useState(() => {\n if (fields === undefined) return NO_FIELDS;\n const placed = placedLeaves(tree);\n return fieldEntriesToMap(\n (fields as readonly Readonly<Record<string, unknown>>[]).map((field) =>\n placed.has(String(field.name)) ? field : { ...field, in: ['create'] },\n ) as never,\n );\n })[0];\n const body = useState(() => () => tree as never)[0];\n // The app's blocks: a review tree places them (P4-D, spec 3.6's `l.place(offeringReview)`).\n const blocks = useFlowFormCatalog();\n // The run's record and args, like the form step reads them (G35): the controller honours meta\n // sources only under the run's claim, so the review carries the run and its form id. Compiled\n // as a review, the tree's `values` stay the form's values while `record` is the run's.\n const metaSources = useFlowMetaSources(record, args, compiled.resource);\n // The form's `fieldConditions` (REF-132 §4.8): the review plans its fields as the form did, so a\n // field a callback removed from the form is not shown here either.\n const fieldConditions = useFlowFieldConditions(compiled);\n const review = useFormController({\n blocks,\n flowRun: run,\n formId: compiled.formId,\n metaSources,\n ...(fieldConditions === undefined ? {} : { flowFieldConditions: fieldConditions }),\n review: true,\n fields: map as never,\n body,\n mode: 'show',\n i18nPrefix: prefix,\n value: values as never,\n });\n return (\n <ScreenTree\n region=\"form-body\"\n resource={prefix}\n mode=\"show\"\n compiled={review.screen}\n controller={review}\n leafIds=\"record\"\n />\n );\n}\n\n/** The field names a tree places as leaves (a string child of any node). */\nfunction placedLeaves(tree: readonly unknown[]): ReadonlySet<string> {\n const out = new Set<string>();\n const walk = (node: unknown): void => {\n if (typeof node === 'string') {\n out.add(node);\n return;\n }\n if (node === null || typeof node !== 'object') return;\n const children = (node as { readonly children?: unknown }).children;\n if (Array.isArray(children)) for (const child of children) walk(child);\n };\n for (const node of tree) walk(node);\n return out;\n}\n\n/**\n * A `then.open` block target, once resolved (`{ block, props, dismiss? }`); `null` for anything\n * else.\n */\nfunction blockOpen(open: unknown): BlockOpen | null {\n if (open === null || typeof open !== 'object' || !Object.hasOwn(open, 'block')) return null;\n const { block, props, dismiss } = open as {\n readonly block?: unknown;\n readonly props?: unknown;\n readonly dismiss?: unknown;\n };\n const ref =\n block !== null && typeof block === 'object' && 'ref' in block\n ? (block as { readonly ref: unknown }).ref\n : block;\n if (\n ref === null ||\n typeof ref !== 'object' ||\n typeof (ref as EntityRefLike).namespace !== 'string' ||\n typeof (ref as EntityRefLike).id !== 'string'\n )\n return null;\n return {\n block: ref as EntityRefLike,\n props: props !== null && typeof props === 'object' ? (props as Row) : {},\n ...(dismiss === 'explicit' ? { dismiss } : {}),\n };\n}\n\ninterface BlockOpen {\n readonly block: EntityRefLike;\n readonly props: Row;\n /** `'explicit'`: only the host's Done button closes the window (L3 9.14). */\n readonly dismiss?: 'explicit';\n}\n\ninterface EntityRefLike {\n readonly namespace: string;\n readonly id: string;\n}\ntype Row = Readonly<Record<string, unknown>>;\n\n/**\n * The block `then.open` names, drawn in the host after success (4.13): its implementation from\n * the mounted catalog (an app's over the kit's), its props validated against the block's schemas\n * at mount (P1b+P1c decision 35); a failed validation, or a block nothing implements, says so.\n */\nfunction FlowOpenBlock({\n open,\n testid,\n}: {\n readonly open: { readonly block: EntityRefLike; readonly props: Row };\n readonly prefix: string;\n readonly testid: string;\n}): ReactElement {\n const t = useOptionalT();\n const id = `${open.block.namespace}:${open.block.id}`;\n const implementation = selectImplementation(id, useFlowOpenImplementation(id) as never);\n const [validation, setValidation] = useState<PropValidation | null>(() =>\n implementation === undefined\n ? null\n : validatePlacementProps(implementation.definition as never, open.props),\n );\n useEffect(() => {\n if (validation?.status !== 'pending') return;\n let live = true;\n void validation.settled.then((settled) => {\n if (live) setValidation(settled);\n });\n return () => {\n live = false;\n };\n }, [validation]);\n const failed = implementation === undefined || validation?.status === 'failed';\n const View = implementation === undefined ? null : viewOf(implementation);\n return (\n <div\n data-testid={`${testid}:open`}\n data-buro-block={id}\n className=\"min-h-0 flex-1 overflow-y-auto\"\n >\n {failed ? (\n <p role=\"alert\" className=\"text-sm text-muted-foreground\">\n {t('block.notImplemented', { defaultValue: 'This section is not available.' })}\n </p>\n ) : View === null || validation?.status !== 'ready' ? null : (\n <Suspense fallback={null}>\n <View\n props={validation.props as never}\n data={NO_FIELDS as never}\n t={(key, options) =>\n t(`blocks.${id}.${key}`, {\n ...(options?.params === undefined ? {} : { params: options.params }),\n ...(options?.count === undefined ? {} : { count: options.count }),\n })\n }\n />\n </Suspense>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;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AM;IACjE,CAAC;GAEJ,CAAA;EACO,CAAA;CAET,CAAA;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-screen-FE5Xhb3t.cjs","names":["fieldSensitivity","useOptionalT","humanizeKey","FieldDisplay","createContext","useUIInstance","useUIPresentationRuntime","useMemo","useContext","specificErrorText","REJECTED_KEYS","textsValueAt","BulkSelectionScope","useState","FlowTextsScope","ScreenStateProvider","useFlowRun","useRef","useOptionalT","useI18nCaps","useTestIds","OwnTitleHeading","reasonText","IconLoader2","Button","flowRecordOf","useChromeT","OwnTitleContext","useProjectedTitle","useFlowForm","useFormControlOf","useCurrentUserId","useNavigationBlocker","useDismissHold","useOptionalRouterAdapter","useNoticeSink","resolveValidationMessage","declaredText","DialogPrimitive","DocInfo","IconX","FormControlProvider","ScreenTree","useSyncExternalStore","fieldEntriesToMap","useFlowFormCatalog","useFlowMetaSources","useFlowFieldConditions","useFormController","selectImplementation","useFlowOpenImplementation","validatePlacementProps","viewOf","Suspense"],"sources":["../src/flows/review-diff.tsx","../src/flows/flow-screen.tsx"],"sourcesContent":["'use client';\nimport { fieldSensitivity, humanizeKey, type Row } from '@burojs/core';\nimport { type FormController, useOptionalT } from '@burojs/react';\nimport type { ReactElement } from 'react';\nimport { FieldDisplay } from '../forms/field.js';\n\n/** The built-in review block of a flow (`review: true`, P4 spec 4.4). */\nexport const REVIEW_DIFF_BLOCK = 'buro:review-diff';\n\nexport interface ReviewDiffProps {\n /** The flow's form: its active fields, their definitions and labels. */\n readonly form: FormController;\n /** The values the form opened on (`form.initial`): the baseline of the diff. */\n readonly initial: Row;\n /** The values as they will be submitted. */\n readonly values: Row;\n /** Text and doc keys of the form (`<resource>.actions.<name>`). */\n readonly i18nPrefix: string;\n /** The test id base (the flow's host). */\n readonly testid: string;\n}\n\n/** Whether a field is `sensitive` (a mark or a mask). */\nfunction sensitive(definition: unknown): boolean {\n if (fieldSensitivity(definition) !== undefined) return true;\n if (definition === null || typeof definition !== 'object') return false;\n const opts = (definition as { readonly opts?: unknown }).opts;\n const marked =\n opts !== null && typeof opts === 'object'\n ? (opts as { readonly sensitive?: unknown }).sensitive\n : undefined;\n return marked !== undefined && marked !== false && marked !== null;\n}\n\nconst same = (a: unknown, b: unknown): boolean => {\n if (Object.is(a, b)) return true;\n const empty = (value: unknown) => value === undefined || value === null || value === '';\n if (empty(a) && empty(b)) return true;\n try {\n return JSON.stringify(a) === JSON.stringify(b);\n } catch {\n return false;\n }\n};\n\n/**\n * The review of a flow (`review: true`, 4.4): one row per active form field whose value differs\n * from the one the form opened on — its label, the old display value and the new one. A\n * `sensitive` field says \"changed\" and shows no value, old or new.\n */\nexport function ReviewDiff({\n form,\n initial,\n values,\n i18nPrefix,\n testid,\n}: ReviewDiffProps): ReactElement {\n const t = useOptionalT();\n const changedText = t('review.changed', { defaultValue: 'changed' });\n const rows = form.fields.filter((binding) => !same(initial[binding.name], values[binding.name]));\n return (\n <dl data-testid={`${testid}:review`} data-buro-block={REVIEW_DIFF_BLOCK} className=\"grid gap-2\">\n {rows.map((binding) => {\n const definition = binding.field as unknown as { readonly label?: unknown };\n const label =\n typeof definition.label === 'string' ? definition.label : humanizeKey(binding.name);\n const hidden = sensitive(binding.field);\n return (\n <div\n key={binding.name}\n data-testid={`${testid}:review:${binding.name}`}\n className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] gap-2 text-sm\"\n >\n <dt className=\"font-medium\">{label}</dt>\n <dd className=\"flex flex-wrap items-center gap-2\">\n {hidden ? (\n <span className=\"text-muted-foreground\">{changedText}</span>\n ) : (\n <>\n <span data-buro-review=\"old\" className=\"text-muted-foreground line-through\">\n <FieldDisplay\n i18nPrefix={i18nPrefix}\n name={binding.name}\n field={binding.field as never}\n value={initial[binding.name]}\n fallback={<span>{display(initial[binding.name])}</span>}\n />\n </span>\n <span aria-hidden=\"true\">→</span>\n <span data-buro-review=\"new\">\n <FieldDisplay\n i18nPrefix={i18nPrefix}\n name={binding.name}\n field={binding.field as never}\n value={values[binding.name]}\n fallback={<span>{display(values[binding.name])}</span>}\n />\n </span>\n </>\n )}\n </dd>\n </div>\n );\n })}\n </dl>\n );\n}\n\nconst display = (value: unknown): string =>\n value === undefined || value === null || value === '' ? '—' : String(value);\n","'use client';\nimport {\n type CompiledFlow,\n type FlowResult,\n type FlowRun,\n declaredText,\n flowRecordOf,\n type FlowSnapshot,\n type PropValidation,\n textsValueAt,\n validatePlacementProps,\n} from '@burojs/core';\nimport {\n BulkSelectionScope,\n type ErrorTextCaps,\n REJECTED_KEYS,\n specificErrorText,\n type FlowScreenProps,\n type FlowStart,\n ScreenStateProvider,\n resolveValidationMessage,\n useFlowOpenImplementation,\n useCurrentUserId,\n useDismissHold,\n useDismissPending,\n useFlowFormCatalog,\n useNavigationBlocker,\n useOptionalRouterAdapter,\n useFormController,\n useI18nCaps,\n useChromeT,\n useOptionalT,\n useProjectedTitle,\n useTestIds,\n useUIInstance,\n useUIPresentationRuntime,\n} from '@burojs/react';\nimport { fieldEntriesToMap } from '@burojs/core/internal';\nimport {\n FlowTextsScope,\n useFlowFieldConditions,\n useFlowForm,\n useFlowMetaSources,\n useFlowRun,\n} from '@burojs/react/flows';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { IconLoader2, IconX } from '@tabler/icons-react';\nimport {\n type ReactElement,\n type ReactNode,\n Suspense,\n createContext,\n useContext,\n useMemo,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { DocInfo } from '../doc/doc-info.js';\nimport { useNoticeSink } from '../forms/success-notices.js';\nimport { reasonText } from '../lib/reason-text.js';\nimport { Button } from '../primitives/button.js';\nimport { FormControlProvider, useFormControlOf } from '../resource/form-context.js';\nimport { ScreenTree } from '../screen/screen-tree.js';\nimport { selectImplementation, viewOf } from '../blocks/place-node.js';\nimport { ReviewDiff } from './review-diff.js';\nimport { OwnTitleContext } from '../ui-presentations/shell.js';\nimport { OwnTitleHeading, useFocusOnMount } from './overlay-heading.js';\n\n/**\n * Thrown from the form controller's write: the controller validated (and revealed the first\n * failing field), and the run — not the controller — sends. A write that throws leaves the form\n * dirty and its draft in place (the controller re-baselines only on a write that resolves), and\n * an abort-shaped value is no reportable failure.\n */\nconst HELD = Object.freeze({ name: 'AbortError', message: 'The flow run sends the values.' });\n\n/**\n * How the flow screen leaves its host (P6): an overlay dismisses its presentation instance, a\n * page navigates to the record through the guard, an inline placement shows the next form. The\n * screen asks `close()` for Cancel, ✕ and Back, and `finish()` once a success needs nothing more\n * shown (no `then.open: { block }`).\n * @internal\n */\nexport interface FlowHostBinding {\n readonly kind: 'overlay' | 'page' | 'inline';\n close(): void;\n finish(): void;\n}\n\n/** @internal Provided by the page and inline hosts; an overlay builds its own. */\n/** @internal */\nexport function HostedFlowScreen(\n props: FlowScreenProps & { readonly binding: FlowHostBinding },\n): ReactElement | null {\n const { binding, ...rest } = props;\n return (\n <FlowHostBindingContext.Provider value={binding}>\n <FlowScreen {...rest} />\n </FlowHostBindingContext.Provider>\n );\n}\n\nexport const FlowHostBindingContext = createContext<FlowHostBinding | null>(null);\n\n/** Gives the screen below it the overlay's binding: its presentation instance. */\nfunction OverlayBinding({ children }: { readonly children: ReactNode }): ReactElement {\n const instance = useUIInstance();\n const runtime = useUIPresentationRuntime();\n const binding = useMemo<FlowHostBinding>(\n () => ({\n kind: 'overlay',\n close: () => instance.dismiss(),\n finish: () => runtime.dismiss(instance.id),\n }),\n [instance, runtime],\n );\n return (\n <FlowHostBindingContext.Provider value={binding}>{children}</FlowHostBindingContext.Provider>\n );\n}\n\n/** The screen's binding when a page or inline host provided one, else the overlay's. */\nfunction WithBinding({ children }: { readonly children: ReactNode }): ReactElement {\n const provided = useContext(FlowHostBindingContext);\n return provided !== null ? <>{children}</> : <OverlayBinding>{children}</OverlayBinding>;\n}\n\ntype Translate = ReturnType<typeof useOptionalT>;\n\n/**\n * What the outcome area says, or `null` when the screen has nothing to report. A rejection reads\n * the specific text of its code first (spec 4.15 steps 1 to 4: the flow's `<textPrefix>.validation.<code>`\n * and declared `texts.validation`, the provider's reference, the shared code texts). Only when none\n * resolves does a mapped kind read the flow's own `<textPrefix>.rejected.<kind>`, then its declared\n * `texts.rejected.<kind>` (`flow`), before the framework's neutral `flow.rejected.<kind>`;\n * `textPrefix` is the compiled flow's `textKeys.prefix`.\n */\nfunction outcomeMessage(\n snapshot: FlowSnapshot,\n busy: boolean,\n t: Translate,\n caps: ErrorTextCaps,\n textPrefix: string,\n flow: { readonly texts?: unknown } | undefined,\n reasonOf: (reason: string) => string,\n): string | null {\n if (busy)\n return t('flow.busyElsewhere', { defaultValue: 'This action is running in another tab.' });\n const outcome = snapshot.outcome;\n if (outcome === undefined || outcome.outcome === 'success') {\n // A check that could not decide blocks the flow (4.3): its reason, with Retry.\n if (snapshot.control === 'disabled' && snapshot.reason !== undefined)\n return reasonOf(snapshot.reason);\n return null;\n }\n if (outcome.outcome === 'unknown')\n return [\n outcome.applied === 'partial'\n ? t('flow.unknownPartial', {\n defaultValue: 'Part of this may have been applied. Nothing was resent.',\n })\n : t('flow.unknown', {\n defaultValue: 'It may have been applied. Nothing was resent.',\n }),\n ...(snapshot.reason === undefined ? [] : [reasonOf(snapshot.reason)]),\n ].join(' ');\n if (outcome.outcome === 'rejected') {\n if (snapshot.reason !== undefined) return reasonOf(snapshot.reason);\n const kind = 'kind' in outcome ? outcome.kind : undefined;\n const code = 'code' in outcome ? outcome.code : undefined;\n if (code !== undefined) {\n const specific = specificErrorText(\n {\n code,\n ...('message' in outcome && outcome.message !== undefined\n ? { message: outcome.message }\n : {}),\n },\n caps,\n { action: { prefix: textPrefix, texts: flow?.texts } },\n );\n if (specific !== undefined) return specific;\n }\n const key = kind === undefined ? undefined : REJECTED_KEYS[kind];\n if (key !== undefined)\n return t(`${textPrefix}.rejected.${key}`, {\n defaultValue:\n textsValueAt(flow?.texts, ['rejected', key]) ??\n t(`flow.rejected.${key}`, { defaultValue: 'Nothing was saved.' }),\n });\n return t('flow.rejected.precondition', {\n defaultValue: 'The record changed. Nothing was sent.',\n });\n }\n if (outcome.outcome === 'failed') {\n if (snapshot.reason !== undefined) return reasonOf(snapshot.reason);\n // The code's own text first (spec 4.15), as the bulk summary and the record frame read it.\n const code = 'code' in outcome ? outcome.code : undefined;\n const specific =\n code === undefined\n ? undefined\n : specificErrorText(\n {\n code,\n ...('message' in outcome && outcome.message !== undefined\n ? { message: outcome.message }\n : {}),\n },\n caps,\n { action: { prefix: textPrefix, texts: flow?.texts } },\n );\n return (\n specific ??\n t('flow.failed', { defaultValue: 'The request could not be sent. Nothing was saved.' })\n );\n }\n return null;\n}\n\n/**\n * The UI kit's flow host screen (`presentationHosts.screens.flow`, presented under `buro:flow`;\n * P4 spec 4.15, 4.19): the action's label and the record's title with its «i» and ✕; the form\n * (a `steps` body is a wizard), the final screen's warnings and `confirm`, and the outcome\n * screens; a footer of Back, Cancel and the submit button, labelled with the action's label and\n * its pending text while the write runs.\n *\n * The presentation is a dismiss scope (P3-30): Escape, an outside click, ✕ and Cancel close\n * through it, so a dirty form asks first; Back between steps stays in the host and asks nothing.\n * From the send to the outcome the screen holds the scope's pending lock — nothing closes it,\n * and the run holds every route change. `success` closes the host without asking; `rejected`\n * and `failed` return to the dirty form; `unknown` closes without asking and keeps the attempt.\n */\nexport function FlowScreen(props: FlowScreenProps): ReactElement | null {\n if (props.run !== undefined && props.compiled !== undefined)\n return <HeldFlowScreen {...props} run={props.run} compiled={props.compiled} />;\n if (props.start !== undefined) return <OwnedFlowScreen {...props} start={props.start} />;\n return null;\n}\n\ntype HeldProps = FlowScreenProps & { readonly run: FlowRun; readonly compiled: CompiledFlow };\n\n/**\n * A bulk run's record frame (read-scope spec 4, rule 1): the form's `'context'` reads take the\n * value every selected row agrees on, else the session's. A run without a selection adds nothing.\n */\nfunction SelectionScope(props: {\n readonly selection: FlowScreenProps['selection'];\n readonly resource: string | null;\n readonly children: ReactNode;\n}): ReactElement {\n if (props.selection === undefined || props.resource === null) return <>{props.children}</>;\n return (\n <BulkSelectionScope resource={props.resource} ids={props.selection.ids}>\n {props.children}\n </BulkSelectionScope>\n );\n}\n\n/** The screen over a run it is given. */\nfunction HeldFlowScreen(props: HeldProps): ReactElement {\n // \"I've checked — start over\" (4.8) opens a fresh form: the body mounts again, so the form\n // takes the run's fresh values as its baseline and offers the stored draft.\n const [generation, setGeneration] = useState(0);\n // An app flow's form reads its texts in its `common.appActions.<name>` entry.\n return (\n <FlowTextsScope compiled={props.compiled}>\n <WithBinding>\n <ScreenStateProvider key={generation}>\n <SelectionScope selection={props.selection} resource={props.compiled.resource}>\n <FlowScreenBody {...props} onFreshForm={() => setGeneration((value) => value + 1)} />\n </SelectionScope>\n </ScreenStateProvider>\n </WithBinding>\n </FlowTextsScope>\n );\n}\n\n/**\n * The host owning its run (P4-C review I1): the run lives as long as the host, not as long as\n * the control that opened it — a row that left the page, a menu item that closed — so a dirty\n * form still asks before it closes and a pending write still holds its lock. `then` waits until\n * the host has gone (its form and its blocker with it), then runs through the opener's\n * dispatcher scope; each outcome is reported to the opener.\n */\nfunction OwnedFlowScreen(props: FlowScreenProps & { readonly start: FlowStart }): ReactElement {\n const { start, effects, onSettle } = props;\n const flow = useFlowRun(start.target, {\n ...(start.record === undefined ? {} : { record: start.record }),\n ...(start.args === undefined ? {} : { args: start.args }),\n ...(start.selection === undefined ? {} : { selection: start.selection }),\n surface: 'host',\n ...(effects === undefined ? {} : { thenEffects: effects }),\n });\n // `then` is the host's to run, after it closed.\n flow.holdThen(true);\n const latest = useRef(flow);\n latest.current = flow;\n useEffect(\n () => () => {\n // After the commit that removed the host: its form's blocker is gone.\n setTimeout(() => {\n latest.current.holdThen(false);\n latest.current.runThen();\n }, 0);\n },\n [],\n );\n const { run, snapshot, compiled } = flow;\n const outcome = snapshot.outcome;\n useEffect(() => {\n if (outcome !== undefined) onSettle?.(outcome);\n }, [outcome, onSettle]);\n const instance = useUIInstance();\n const t = useOptionalT();\n const caps = useI18nCaps(compiled?.resource ?? undefined);\n const tid = useTestIds();\n const opened =\n run !== null &&\n compiled !== null &&\n (snapshot.history.includes('open') || snapshot.step === 'outcome');\n if (opened) return <HeldFlowScreen {...props} run={run} compiled={compiled} />;\n // Not opened yet: its gate, its sources and a stored attempt decide first. A run that\n // decided against opening says why.\n const refused = snapshot.control === 'disabled' || snapshot.control === 'absent';\n return (\n <div\n data-testid={compiled === null ? undefined : `${tid.flowHost(compiled.flowId)}:opening`}\n data-buro-host={props.host}\n data-buro-flow-step={refused ? 'refused' : 'opening'}\n aria-busy={refused ? undefined : 'true'}\n className=\"flex min-h-0 flex-1 flex-col gap-4\"\n >\n <OwnTitleHeading label={props.label} />\n {refused ? (\n <p role=\"alert\" className=\"text-sm\">\n {snapshot.reason === undefined\n ? t('flow.unavailable', { defaultValue: 'Not allowed.' })\n : reasonText(caps, snapshot.reason, compiled?.resource ?? undefined)}\n </p>\n ) : (\n <IconLoader2 className=\"h-5 w-5 animate-spin self-center\" aria-hidden=\"true\" />\n )}\n <div className=\"flex justify-end\">\n <Button type=\"button\" variant=\"ghost\" onClick={() => instance.dismiss()}>\n {t('flow.close', { defaultValue: 'Close' })}\n </Button>\n </div>\n </div>\n );\n}\n\nfunction FlowScreenBody({\n run,\n host,\n label,\n title: givenTitle,\n compiled,\n record: givenRecord,\n args,\n selection,\n onFreshForm,\n}: HeldProps & { readonly onFreshForm: () => void }): ReactElement {\n // A collection-level flow has no record, whoever passed one (spec 5.1): its title, its form and\n // its review read none.\n const record = flowRecordOf(compiled, givenRecord);\n const snapshot = useSyncSnapshot(run);\n const binding = useContext(FlowHostBindingContext) as FlowHostBinding;\n const tid = useTestIds();\n const t = useOptionalT();\n const chromeT = useChromeT();\n const resource = compiled.resource ?? undefined;\n const caps = useI18nCaps(resource);\n const ownTitle = useContext(OwnTitleContext);\n const flowId = compiled.flowId;\n const recordId = record?.[compiled.idField] ?? record?.id;\n const recordTitle = useProjectedTitle(resource, recordId, record);\n const title =\n givenTitle ?? (record === undefined || recordTitle === '' ? undefined : recordTitle);\n const form = useFlowForm(run, compiled, snapshot, {\n ...(record === undefined ? {} : { record }),\n ...(args === undefined ? {} : { args }),\n ...(selection === undefined ? {} : { selection: selection.ids }),\n });\n const formControl = useFormControlOf(form);\n const hasForm = compiled.flow.form !== undefined;\n const [busy, setBusy] = useState(false);\n // The values the form opened on: the review's baseline (4.4). The host opens on an opened run,\n // before anything was typed.\n const [initial] = useState(() => run.getSnapshot().values);\n // Form-level messages: a server's validation refusal on a key no field holds (M14), a\n // resource-level validator's.\n const formErrors = form.errors.filter((issue) => issue.field === '_form');\n\n // The pending lock (4.19): from the re-read to the persisted outcome nothing closes the host.\n const locked = snapshot.control === 'running';\n\n const outcome = snapshot.outcome?.outcome;\n const unknown = outcome === 'unknown';\n const succeeded = outcome === 'success';\n const finalStep = snapshot.step === 'review' || snapshot.step === 'accept';\n\n // `success` closes the host, unasked: nothing unsaved remains (4.19). The run settled the\n // mutation's effects before it answered (4.13).\n // `then.open: { block, props }` keeps the host and draws the block instead (4.13): its close is\n // the block's own button and ✕, and `result` goes with the host.\n const openBlock = succeeded ? blockOpen(snapshot.effects?.open) : null;\n useDismissPending(locked);\n // `dismiss: 'explicit'` (L3 9.14): while the block shows, the overlay drops its own Escape,\n // outside click and every guarded dismiss aimed at it (the block's own included); the header ✕\n // is not drawn and the host's Done button closes it. Everything from outside the window asks\n // through the navigation guard, as a dirty form does: a route change, Back, a reload, and\n // closing an enclosing overlay (an inline host's sheet, a quick sheet the flow was opened\n // from). A change of the signed-in user releases the guard: sign-out is never held.\n const held = openBlock?.dismiss === 'explicit';\n const userId = useCurrentUserId();\n // The user the held window was shown to: captured when it is first held (not at mount, when the\n // id may still be loading), forgotten when it is released. An idempotent write per render.\n const heldBy = useRef<{ readonly id: string | null } | null>(null);\n if (!held) heldBy.current = null;\n else if (heldBy.current === null) heldBy.current = { id: userId };\n const guarding = held && userId === heldBy.current?.id;\n const leaveGuard = useNavigationBlocker(guarding);\n const hold = useDismissHold(guarding && binding.kind === 'overlay');\n // A confirmed route change leaves the page the window was opened over: close it with it, even\n // when its opener stays mounted (an app-level button).\n const pathname = useOptionalRouterAdapter()?.pathname;\n const heldAt = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!held || binding.kind !== 'overlay') {\n heldAt.current = undefined;\n return;\n }\n if (heldAt.current === undefined) heldAt.current = pathname;\n else if (heldAt.current !== pathname) {\n hold.close();\n binding.finish();\n }\n }, [held, pathname, binding, hold]);\n // The write's own notices (spec 4.7), once per success, before the host closes.\n const showNotices = useNoticeSink(resource);\n const shownNotices = useRef<unknown>(null);\n useEffect(() => {\n if (!succeeded || snapshot.notices.length === 0 || shownNotices.current === snapshot.notices)\n return;\n shownNotices.current = snapshot.notices;\n showNotices(snapshot.notices);\n }, [succeeded, snapshot.notices, showNotices]);\n useEffect(() => {\n if (succeeded && !locked && openBlock === null) binding.finish();\n }, [succeeded, locked, openBlock, binding]);\n\n const prefix =\n compiled.resource === null\n ? `appActions.${compiled.name}`\n : `${compiled.resource}.actions.${compiled.name}`;\n\n const settle = (result: FlowResult) => {\n setBusy(result.outcome === 'failed' && 'reason' in result && result.reason === 'busy');\n };\n const submit = async () => {\n if (locked) return;\n setBusy(false);\n if (finalStep) {\n settle(await run.accept());\n return;\n }\n if (unknown && editingNew) {\n // Send as new: the form as filled now, validated, then the confirmation (P4-C review C2).\n let valid = false;\n await form.handleSubmit(() => {\n valid = true;\n throw HELD;\n })();\n if (valid) setConfirmingNew(true);\n return;\n }\n if (unknown) return;\n if (hasForm) {\n // The controller validates the active fields and reveals the first failing one (its step\n // included); the run sends.\n let validated = false;\n await form.handleSubmit(() => {\n validated = true;\n throw HELD;\n })();\n if (!validated) return;\n }\n settle(await run.submit());\n };\n\n const pendingKey =\n compiled.resource === null\n ? `appActions.${compiled.name}.pending`\n : `resources.${compiled.resource}.actions.${compiled.name}.pending`;\n const pendingLabel = caps.has(pendingKey) ? caps.t(pendingKey) : `${label}…`;\n const message = outcomeMessage(\n snapshot,\n busy,\n t,\n caps,\n compiled.textKeys.prefix,\n compiled.flow,\n (reason) => reasonText(caps, reason, resource),\n );\n // The form-level issues, resolved here so a language switch re-renders them; one that says\n // what the outcome heading already says is not shown twice.\n const formErrorTexts = formErrors\n .map((issue) =>\n resolveValidationMessage(\n {\n code: issue.code ?? '',\n message: issue.message,\n ...(issue.check === undefined ? {} : { check: issue.check }),\n },\n { has: caps.has, t: caps.t },\n ),\n )\n .filter((text) => text !== message);\n // The flow's own word for its cancel buttons (`<prefix>.dismiss`, then its declared\n // `texts.dismiss`), else the kit's.\n const dismissKey = `${compiled.textKeys.prefix}.dismiss`;\n const cancelWord =\n (caps.has(dismissKey) ? caps.t(dismissKey) : undefined) ??\n declaredText('flow', compiled.flow, 'dismiss') ??\n chromeT('actions.cancel', { defaultValue: 'Cancel' });\n // The run flags a check that could not decide; its reason is a translation, never compared.\n const couldNotCheck = snapshot.control === 'disabled' && snapshot.unverified === true;\n const steps = form.steps;\n const lastStep =\n steps === null || steps.ids.length === 0 || steps.current === steps.ids[steps.ids.length - 1];\n const showSubmit = !unknown && !succeeded && (!hasForm || finalStep || lastStep);\n // The unknown screen's exits (4.8).\n const [confirmingNew, setConfirmingNew] = useState(false);\n // Send as new sends the form as it is now (4.8): the user fills it again and it is validated\n // first — after a reload it holds only its initial values (P4-C review C2).\n const [editingNew, setEditingNew] = useState(false);\n const checkable = compiled.flow.submit.onUnknown !== undefined;\n const unhandled = unknown && !checkable && !snapshot.canResend;\n const exit = (action: () => Promise<FlowResult>) => () => {\n if (!locked) void action().then(settle);\n };\n // An overlay's Cancel keeps the draft so it survives the close (4.19); an inline Reset means\n // \"start over\", so the next form must not offer the input it just threw away (REF-51). An\n // unknown outcome's Close keeps it, like every unresolved attempt (4.11).\n const close = () => {\n if (binding.kind === 'inline' && hasForm && !unknown) form.draft.discard();\n binding.close();\n };\n\n const headingRef = useRef<HTMLHeadingElement>(null);\n useFocusOnMount(headingRef);\n // When a `then.open` block replaces the form, focus goes to its Done button (the heading where\n // no Done is drawn): the hidden form took the focused submit button with it.\n const doneRef = useRef<HTMLButtonElement>(null);\n const blockShown = openBlock !== null;\n useEffect(() => {\n if (blockShown) (doneRef.current ?? headingRef.current)?.focus();\n }, [blockShown]);\n const heading = (\n <h2\n ref={headingRef}\n tabIndex={-1}\n data-buro-overlay-heading=\"\"\n className=\"min-w-0 flex-1 break-words text-lg font-semibold tracking-tight focus-visible:outline-hidden\"\n >\n {label}\n {title === undefined ? null : (\n <span className=\"font-normal text-muted-foreground\">\n {/* Text, not margin: the dialog's accessible name is its text, which would glue the two. */}\n {' — '}\n {title}\n </span>\n )}\n </h2>\n );\n\n return (\n <div\n data-testid={tid.flowHost(flowId)}\n data-buro-host={host}\n data-buro-flow-step={snapshot.step}\n aria-busy={locked ? 'true' : undefined}\n className=\"flex min-h-0 flex-1 flex-col gap-4\"\n >\n {binding.kind === 'inline' ? null : (\n <div data-buro-region=\"flow-header\" className=\"flex items-center gap-2 pr-1\">\n {ownTitle ? <DialogPrimitive.Title asChild>{heading}</DialogPrimitive.Title> : heading}\n {compiled.resource === null ? null : (\n <DocInfo\n address={`${compiled.resource}/actions/${compiled.name}`}\n name={label}\n testId={`${tid.flowHost(flowId)}:info`}\n />\n )}\n {binding.kind === 'overlay' && !held ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-8 w-8 shrink-0\"\n data-testid={tid.flowClose(flowId)}\n aria-label={t('flow.close', { defaultValue: 'Close' })}\n onClick={close}\n >\n <IconX className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n ) : null}\n </div>\n )}\n {openBlock !== null ? (\n <FlowOpenBlock open={openBlock} prefix={prefix} testid={tid.flowHost(flowId)} />\n ) : null}\n {openBlock !== null && (binding.kind !== 'overlay' || held) ? (\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n variant=\"outline\"\n ref={doneRef}\n data-testid={tid.flowClose(flowId)}\n onClick={() => {\n // Done is the window's own way out: its guard lets it go first (a page host's\n // close is a guarded navigation to the record).\n leaveGuard.release();\n if (held && binding.kind === 'overlay') {\n // Unconditionally, with every overlay the block opened above it (M4).\n hold.close();\n binding.finish();\n } else close();\n }}\n >\n {t('flow.done', { defaultValue: 'Done' })}\n </Button>\n </div>\n ) : null}\n <form\n hidden={openBlock !== null}\n noValidate\n className={openBlock === null ? 'flex min-h-0 flex-1 flex-col gap-4' : 'hidden'}\n onSubmit={(event) => {\n event.preventDefault();\n void submit();\n }}\n >\n <div className=\"-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-1\">\n {message === null ? null : (\n <div\n role={unknown || outcome === 'rejected' || outcome === 'failed' ? 'alert' : 'status'}\n data-testid={tid.flowOutcome(flowId)}\n data-buro-flow-outcome={busy ? 'busy' : (outcome ?? snapshot.control)}\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n <span>{message}</span>\n {couldNotCheck ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n onClick={() => run.retryChecks()}\n >\n {chromeT('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n ) : null}\n </div>\n )}\n {hasForm && form.draft.pending !== null && (!unknown || editingNew) ? (\n <div\n data-testid={tid.flowDraft(flowId)}\n role=\"status\"\n aria-live=\"polite\"\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm\"\n >\n <span className=\"font-medium\">\n {t('draft.restorePrompt', { defaultValue: 'Restore draft?' })}\n </span>\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n data-testid={`${tid.flowDraft(flowId)}:restore`}\n onClick={form.draft.restore}\n >\n {t('draft.restore', { defaultValue: 'Restore' })}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n data-testid={`${tid.flowDraft(flowId)}:discard`}\n onClick={form.draft.discard}\n >\n {t('draft.discard', { defaultValue: 'Discard' })}\n </Button>\n </div>\n </div>\n ) : null}\n {formErrorTexts.length > 0 ? (\n <div\n role=\"alert\"\n data-testid={`${tid.flowHost(flowId)}:form-errors`}\n className=\"flex flex-col gap-1 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n {formErrorTexts.map((text, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: one failed write's fixed list\n <p key={index}>{text}</p>\n ))}\n </div>\n ) : null}\n {finalStep && compiled.flow.review === true ? (\n <ReviewDiff\n form={form}\n initial={initial}\n values={snapshot.values}\n i18nPrefix={prefix}\n testid={tid.flowHost(flowId)}\n />\n ) : finalStep && Array.isArray(compiled.flow.review) ? (\n <ReviewTree\n compiled={compiled}\n tree={compiled.flow.review}\n values={snapshot.values}\n prefix={prefix}\n run={run}\n {...(record === undefined ? {} : { record })}\n {...(args === undefined ? {} : { args })}\n />\n ) : hasForm ? (\n <FormControlProvider value={formControl}>\n <ScreenTree\n region=\"form-body\"\n resource={prefix}\n mode=\"create\"\n compiled={form.screen}\n controller={form}\n // The record scheme: the leaves carry `form-field-input:<prefix>:create:<name>`\n // test ids, and their texts key as `resources.<prefix>.fields.<name>.…` (4.4).\n leafIds=\"record\"\n disabled={locked || (unknown && !editingNew) || finalStep || succeeded}\n />\n </FormControlProvider>\n ) : null}\n {finalStep && snapshot.warnings.length > 0 ? (\n <ul\n role=\"status\"\n data-buro-region=\"flow-warnings\"\n className=\"flex flex-col gap-1 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm text-warning-emphasis\"\n >\n {snapshot.warnings.map((warning) => (\n <li key={warning.id} data-testid={`${tid.flowHost(flowId)}:warning:${warning.id}`}>\n {warning.message}\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n {unhandled ? (\n <p data-testid={`${tid.flowOutcome(flowId)}:unhandled`} className=\"text-sm\">\n {t('flow.unknownUnhandled', { defaultValue: 'Check the record before trying again.' })}\n </p>\n ) : null}\n {unknown && confirmingNew ? (\n <div\n role=\"alertdialog\"\n aria-label={t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n data-testid={`${tid.flowSendAsNew(flowId)}:confirm`}\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm\"\n >\n <span>\n {t('flow.sendAsNewConfirm', {\n defaultValue: 'This may apply the change twice. Send it as a new request?',\n })}\n </span>\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n data-testid={`${tid.flowSendAsNew(flowId)}:cancel`}\n onClick={() => setConfirmingNew(false)}\n >\n {cancelWord}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n data-testid={`${tid.flowSendAsNew(flowId)}:ok`}\n onClick={() => {\n setConfirmingNew(false);\n exit(() => run.sendAsNew({ confirmed: true }))();\n }}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n </div>\n </div>\n ) : null}\n {unknown ? (\n <div data-buro-region=\"flow-unknown-exits\" className=\"flex flex-wrap gap-2\">\n {checkable ? (\n <Button\n type=\"button\"\n variant=\"default\"\n data-testid={tid.flowCheckAgain(flowId)}\n disabled={locked}\n onClick={exit(() => run.checkAgain())}\n >\n {t('flow.checkAgain', { defaultValue: 'Check again' })}\n </Button>\n ) : null}\n {snapshot.canResend ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowResend(flowId)}\n disabled={locked}\n onClick={exit(() => run.resend())}\n >\n {t('flow.resend', { defaultValue: 'Resend' })}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowSendAsNew(flowId)}\n disabled={locked || confirmingNew || editingNew}\n onClick={() => {\n if (hasForm) setEditingNew(true);\n else setConfirmingNew(true);\n }}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowStartOver(flowId)}\n disabled={locked}\n onClick={() => {\n run.startOver();\n onFreshForm();\n }}\n >\n {t('flow.startOver', { defaultValue: \"I've checked — start over\" })}\n </Button>\n </div>\n ) : null}\n <div data-buro-region=\"flow-footer\" className=\"flex flex-wrap items-center gap-2\">\n {finalStep && hasForm && !locked ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={tid.flowBack(flowId)}\n onClick={() => run.back()}\n >\n {t('flow.back', { defaultValue: 'Back' })}\n </Button>\n ) : null}\n <div className=\"ml-auto flex gap-2\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n data-testid={tid.flowCancel(flowId)}\n disabled={locked}\n onClick={close}\n >\n {unknown\n ? t('flow.close', { defaultValue: 'Close' })\n : binding.kind === 'inline'\n ? t('flow.reset', { defaultValue: 'Reset' })\n : cancelWord}\n </Button>\n {unknown && editingNew ? (\n <Button\n type=\"submit\"\n variant=\"destructive\"\n data-testid={`${tid.flowSendAsNew(flowId)}:submit`}\n disabled={locked || confirmingNew}\n onMouseDown={(event) => event.preventDefault()}\n >\n {t('flow.sendAsNew', { defaultValue: 'Send as new' })}\n </Button>\n ) : null}\n {showSubmit ? (\n <Button\n type=\"submit\"\n variant={compiled.flow.variant === 'destructive' ? 'destructive' : 'default'}\n data-testid={tid.flowSubmit(flowId)}\n disabled={locked || couldNotCheck}\n aria-busy={locked ? 'true' : undefined}\n // Without this, focusing out of a field a blur error just inserted moves the\n // button, and the click that lands on its old position is swallowed.\n onMouseDown={(event) => event.preventDefault()}\n >\n {locked ? (\n <IconLoader2 className=\"h-4 w-4 animate-spin\" aria-hidden=\"true\" />\n ) : null}\n {locked ? pendingLabel : label}\n </Button>\n ) : null}\n </div>\n </div>\n </form>\n </div>\n );\n}\n\n/** The run's snapshot, re-rendering on each change. */\nfunction useSyncSnapshot(run: FlowRun): FlowSnapshot {\n return useSyncExternalStore(run.subscribe, run.getSnapshot, run.getSnapshot);\n}\n\nconst NO_FIELDS = Object.freeze({});\n\n/**\n * `review: (l) => [...]` (4.4): a show tree over the flow's values — displays and placements\n * only, no inputs — drawn by a show-mode form over the flow's fields.\n */\nfunction ReviewTree({\n compiled,\n tree,\n values,\n prefix,\n run,\n record,\n args,\n}: {\n readonly compiled: CompiledFlow;\n readonly tree: readonly unknown[];\n readonly values: Readonly<Record<string, unknown>>;\n readonly prefix: string;\n readonly run: FlowRun;\n readonly record?: Row;\n readonly args?: Row;\n}): ReactElement {\n const fields = compiled.flow.form?.fields;\n // A review places what it shows: a field the tree does not place leaves the show mode (its\n // `in`), so a review of blocks alone (spec 3.6) is not refused for the fields it leaves out.\n const map = useState(() => {\n if (fields === undefined) return NO_FIELDS;\n const placed = placedLeaves(tree);\n return fieldEntriesToMap(\n (fields as readonly Readonly<Record<string, unknown>>[]).map((field) =>\n placed.has(String(field.name)) ? field : { ...field, in: ['create'] },\n ) as never,\n );\n })[0];\n const body = useState(() => () => tree as never)[0];\n // The app's blocks: a review tree places them (P4-D, spec 3.6's `l.place(offeringReview)`).\n const blocks = useFlowFormCatalog();\n // The run's record and args, like the form step reads them (G35): the controller honours meta\n // sources only under the run's claim, so the review carries the run and its form id. Compiled\n // as a review, the tree's `values` stay the form's values while `record` is the run's.\n const metaSources = useFlowMetaSources(record, args, compiled.resource);\n // The form's `fieldConditions` (REF-132 §4.8): the review plans its fields as the form did, so a\n // field a callback removed from the form is not shown here either.\n const fieldConditions = useFlowFieldConditions(compiled);\n const review = useFormController({\n blocks,\n flowRun: run,\n formId: compiled.formId,\n metaSources,\n ...(fieldConditions === undefined ? {} : { flowFieldConditions: fieldConditions }),\n review: true,\n fields: map as never,\n body,\n mode: 'show',\n i18nPrefix: prefix,\n value: values as never,\n });\n return (\n <ScreenTree\n region=\"form-body\"\n resource={prefix}\n mode=\"show\"\n compiled={review.screen}\n controller={review}\n leafIds=\"record\"\n />\n );\n}\n\n/** The field names a tree places as leaves (a string child of any node). */\nfunction placedLeaves(tree: readonly unknown[]): ReadonlySet<string> {\n const out = new Set<string>();\n const walk = (node: unknown): void => {\n if (typeof node === 'string') {\n out.add(node);\n return;\n }\n if (node === null || typeof node !== 'object') return;\n const children = (node as { readonly children?: unknown }).children;\n if (Array.isArray(children)) for (const child of children) walk(child);\n };\n for (const node of tree) walk(node);\n return out;\n}\n\n/**\n * A `then.open` block target, once resolved (`{ block, props, dismiss? }`); `null` for anything\n * else.\n */\nfunction blockOpen(open: unknown): BlockOpen | null {\n if (open === null || typeof open !== 'object' || !Object.hasOwn(open, 'block')) return null;\n const { block, props, dismiss } = open as {\n readonly block?: unknown;\n readonly props?: unknown;\n readonly dismiss?: unknown;\n };\n const ref =\n block !== null && typeof block === 'object' && 'ref' in block\n ? (block as { readonly ref: unknown }).ref\n : block;\n if (\n ref === null ||\n typeof ref !== 'object' ||\n typeof (ref as EntityRefLike).namespace !== 'string' ||\n typeof (ref as EntityRefLike).id !== 'string'\n )\n return null;\n return {\n block: ref as EntityRefLike,\n props: props !== null && typeof props === 'object' ? (props as Row) : {},\n ...(dismiss === 'explicit' ? { dismiss } : {}),\n };\n}\n\ninterface BlockOpen {\n readonly block: EntityRefLike;\n readonly props: Row;\n /** `'explicit'`: only the host's Done button closes the window (L3 9.14). */\n readonly dismiss?: 'explicit';\n}\n\ninterface EntityRefLike {\n readonly namespace: string;\n readonly id: string;\n}\ntype Row = Readonly<Record<string, unknown>>;\n\n/**\n * The block `then.open` names, drawn in the host after success (4.13): its implementation from\n * the mounted catalog (an app's over the kit's), its props validated against the block's schemas\n * at mount (P1b+P1c decision 35); a failed validation, or a block nothing implements, says so.\n */\nfunction FlowOpenBlock({\n open,\n testid,\n}: {\n readonly open: { readonly block: EntityRefLike; readonly props: Row };\n readonly prefix: string;\n readonly testid: string;\n}): ReactElement {\n const t = useOptionalT();\n const id = `${open.block.namespace}:${open.block.id}`;\n const implementation = selectImplementation(id, useFlowOpenImplementation(id) as never);\n const [validation, setValidation] = useState<PropValidation | null>(() =>\n implementation === undefined\n ? null\n : validatePlacementProps(implementation.definition as never, open.props),\n );\n useEffect(() => {\n if (validation?.status !== 'pending') return;\n let live = true;\n void validation.settled.then((settled) => {\n if (live) setValidation(settled);\n });\n return () => {\n live = false;\n };\n }, [validation]);\n const failed = implementation === undefined || validation?.status === 'failed';\n const View = implementation === undefined ? null : viewOf(implementation);\n return (\n <div\n data-testid={`${testid}:open`}\n data-buro-block={id}\n className=\"min-h-0 flex-1 overflow-y-auto\"\n >\n {failed ? (\n <p role=\"alert\" className=\"text-sm text-muted-foreground\">\n {t('block.notImplemented', { defaultValue: 'This section is not available.' })}\n </p>\n ) : View === null || validation?.status !== 'ready' ? null : (\n <Suspense fallback={null}>\n <View\n props={validation.props as never}\n data={NO_FIELDS as never}\n t={(key, options) =>\n t(`blocks.${id}.${key}`, {\n ...(options?.params === undefined ? {} : { params: options.params }),\n ...(options?.count === undefined ? {} : { count: options.count }),\n })\n }\n />\n </Suspense>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,MAAa,oBAAoB;AAgBjC,SAAS,UAAU,YAA8B;CAC/C,KAAA,GAAIA,aAAAA,iBAAAA,CAAiB,UAAU,MAAM,KAAA,GAAW,OAAO;CACvD,IAAI,eAAe,QAAQ,OAAO,eAAe,UAAU,OAAO;CAClE,MAAM,OAAQ,WAA2C;CACzD,MAAM,SACJ,SAAS,QAAQ,OAAO,SAAS,WAC5B,KAA0C,YAC3C,KAAA;CACN,OAAO,WAAW,KAAA,KAAa,WAAW,SAAS,WAAW;AAChE;AAEA,MAAM,QAAQ,GAAY,MAAwB;CAChD,IAAI,OAAO,GAAG,GAAG,CAAC,GAAG,OAAO;CAC5B,MAAM,SAAS,UAAmB,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;CACrF,IAAI,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,OAAO;CACjC,IAAI;EACF,OAAO,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;CAC/C,QAAQ;EACN,OAAO;CACT;AACF;AAOA,SAAgB,WAAW,EACzB,MACA,SACA,QACA,YACA,UACgC;C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;IACE,OAAO,WAAW;IAClB,MAAM;IACN,IAAI,KAAK,YACP,EAAE,UAAU,GAAG,GAAG,OAAO;KACvB,GAAI,SAAS,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;KAClE,GAAI,SAAS,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;IACjE,CAAC;GAEJ,CAAA;EACO,CAAA;CAET,CAAA;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-relation-picker-dialog-BaORufxQ.js","names":[],"sources":["../src/fields/candidates-match.ts","../src/fields/candidates-gate.ts","../src/fields/lazy-relation-picker-dialog.tsx"],"sourcesContent":["import type { FixedFilterInput } from '@burojs/core';\n\ntype Entry = { readonly field?: unknown; readonly op?: unknown; readonly value?: unknown };\n\n/**\n * Whether `row` meets every candidate filter (P7 3.4): `true`, `false`, or `undefined` when the\n * row does not carry a field a filter names (a narrower projection), so nothing can be said.\n * Only the flat `{ field, op, value }` entries candidates resolve to are evaluated; this is what\n * \"does not match the current filter\" is decided on, never what is sent.\n */\nexport function rowMatches(\n row: Readonly<Record<string, unknown>>,\n filters: readonly FixedFilterInput[],\n): boolean | undefined {\n let unknown = false;\n for (const filter of filters) {\n const group = filter as { readonly and?: unknown; readonly or?: unknown };\n if (Array.isArray(group.and) || Array.isArray(group.or)) {\n const parts = (\n Array.isArray(group.and) ? group.and : group.or\n ) as readonly FixedFilterInput[];\n const answers = parts.map((part) => rowMatches(row, [part]));\n const all = Array.isArray(group.and);\n const decided = answers.filter((answer) => answer !== undefined);\n if (all ? decided.includes(false) : decided.length > 0 && !decided.includes(true))\n return false;\n if (decided.length < answers.length && !(all ? false : decided.includes(true)))\n unknown = true;\n continue;\n }\n const { field, op, value } = filter as Entry;\n if (typeof field !== 'string' || typeof op !== 'string') continue;\n if (!Object.hasOwn(row, field)) {\n unknown = true;\n continue;\n }\n const held = holds(row[field], op, value);\n if (held === false) return false;\n if (held === undefined) unknown = true;\n }\n return unknown ? undefined : true;\n}\n\nfunction holds(actual: unknown, op: string, expected: unknown): boolean | undefined {\n const list = Array.isArray(expected) ? (expected as readonly unknown[]) : undefined;\n const text = (value: unknown) => String(value ?? '').toLowerCase();\n switch (op) {\n case 'eq':\n return Object.is(actual, expected) || String(actual) === String(expected);\n case 'neq':\n return !(Object.is(actual, expected) || String(actual) === String(expected));\n case 'in':\n return list === undefined\n ? undefined\n : list.some((entry) => String(entry) === String(actual));\n case 'notIn':\n return list === undefined\n ? undefined\n : !list.some((entry) => String(entry) === String(actual));\n case 'gt':\n return compare(actual, expected, (a, b) => a > b);\n case 'gte':\n return compare(actual, expected, (a, b) => a >= b);\n case 'lt':\n return compare(actual, expected, (a, b) => a < b);\n case 'lte':\n return compare(actual, expected, (a, b) => a <= b);\n case 'contains':\n return text(actual).includes(text(expected));\n case 'startsWith':\n return text(actual).startsWith(text(expected));\n case 'endsWith':\n return text(actual).endsWith(text(expected));\n case 'isNull':\n return actual === null || actual === undefined;\n case 'isNotNull':\n return actual !== null && actual !== undefined;\n default:\n return undefined;\n }\n}\n\nfunction compare(\n actual: unknown,\n expected: unknown,\n test: (a: number | string, b: number | string) => boolean,\n): boolean | undefined {\n const both =\n (typeof actual === 'number' && typeof expected === 'number') ||\n (typeof actual === 'string' && typeof expected === 'string');\n return both ? test(actual as number | string, expected as number | string) : undefined;\n}\n","import {\n type FixedFilterInput,\n type RelationCandidate,\n type ScreenSources,\n resolveCandidates,\n resolveFieldLabel,\n declaredText,\n} from '@burojs/core';\nimport { useApp, useCandidatesAccess, useI18nCaps, useOptionalT, useTestIds } from '@burojs/react';\nimport * as React from 'react';\nimport { rowMatches } from './candidates-match.js';\n\n/** A select that must not read its target now (P7 3.4): why, and what it tells the user. */\nexport type CandidatesGate =\n | { readonly kind: 'pending' }\n | { readonly kind: 'empty'; readonly message: string; readonly testId: string }\n | { readonly kind: 'forbidden'; readonly message: string; readonly testId: string };\n\nconst NO_SOURCES: ScreenSources = Object.freeze({});\nconst NO_FILTERS: readonly FixedFilterInput[] = Object.freeze([]);\n\n/**\n * A relation field's `candidates` as the select applies them (P7 3.4): the filters to send and,\n * when they say the target must not be read yet, the gate that tells the user why. The refs are\n * read from the owner's projected sources, so a field P5 hides reads `null` (the select asks for\n * it first, and sends nothing); a candidate on a target field the user may not view forbids the\n * read; an undecided source or permission map keeps the select disabled.\n */\nexport function useCandidatesGate(input: {\n readonly to: string | undefined;\n readonly candidates: readonly RelationCandidate[] | undefined;\n readonly sources: ScreenSources | undefined;\n readonly resource: string;\n readonly fieldName: string;\n}): { readonly filters: readonly FixedFilterInput[]; readonly gate?: CandidatesGate } {\n const { to, candidates, sources, resource, fieldName } = input;\n const t = useOptionalT();\n const app = useApp();\n const tid = useTestIds();\n const ownerCaps = useI18nCaps(resource);\n const targetCaps = useI18nCaps(to ?? resource);\n const access = useCandidatesAccess(to ?? '', candidates);\n const resolution = React.useMemo(\n () => resolveCandidates(candidates, sources ?? NO_SOURCES),\n [candidates, sources],\n );\n if (candidates === undefined || candidates.length === 0) return { filters: NO_FILTERS };\n const testId = tid.relationCandidatesHint(resource, fieldName);\n if (access.status === 'pending') return { filters: NO_FILTERS, gate: { kind: 'pending' } };\n if (access.status === 'forbidden') {\n const declared = declaredText(\n 'field',\n (app.registry.get(to ?? '')?.fields as Record<string, unknown> | undefined)?.[access.field],\n 'label',\n );\n const label = resolveFieldLabel(targetCaps, access.field, declared);\n return {\n filters: NO_FILTERS,\n gate: {\n kind: 'forbidden',\n testId,\n message: t('relationPicker.cannotSearchBy', {\n params: { label },\n defaultValue: `You cannot search by ${label}`,\n }),\n },\n };\n }\n if (resolution.status === 'pending') return { filters: NO_FILTERS, gate: { kind: 'pending' } };\n if (resolution.status === 'empty') {\n const { source, path } = resolution.hint;\n const head = path[0];\n // The field a `values` / `record` ref reads is labelled as the owner labels it; any other\n // source (`scope`, `user`) names the key it reads, humanised.\n const own = source === 'values' || source === 'record';\n const declared =\n own && head !== undefined\n ? declaredText(\n 'field',\n (app.registry.get(resource)?.fields as Record<string, unknown> | undefined)?.[head],\n 'label',\n )\n : undefined;\n const label = resolveFieldLabel(ownerCaps, head ?? source, declared);\n return {\n filters: NO_FILTERS,\n gate: {\n kind: 'empty',\n testId,\n message: t('relationPicker.chooseFirst', {\n params: { label },\n defaultValue: `Choose ${label} first`,\n }),\n },\n };\n }\n return { filters: resolution.filters };\n}\n\n/**\n * A select's declared candidates as the shared select wiring applies them (`CandidatesRelationPicker`\n * and `useRelationPicker`): the gate, the resolved candidate filters prepended to the caller's\n * `fixedFilters`, and whether a loaded row fits them (`undefined` when no candidate filter applies).\n */\nexport function useCandidateSelection(input: {\n readonly to: string | undefined;\n readonly candidates: readonly RelationCandidate[] | undefined;\n readonly sources: ScreenSources | undefined;\n readonly resource: string;\n readonly fieldName: string;\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n}): {\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n readonly gate?: CandidatesGate;\n readonly rowFits?: (row: Record<string, unknown>) => boolean | undefined;\n} {\n const { fixedFilters } = input;\n const gate = useCandidatesGate(input);\n const filters = gate.filters;\n const combined = React.useMemo(\n () => (filters.length === 0 ? fixedFilters : [...filters, ...(fixedFilters ?? [])]),\n [filters, fixedFilters],\n );\n const rowFits = React.useMemo(\n () =>\n filters.length === 0 ? undefined : (row: Record<string, unknown>) => rowMatches(row, filters),\n [filters],\n );\n return {\n fixedFilters: combined,\n ...(gate.gate === undefined ? {} : { gate: gate.gate }),\n ...(rowFits === undefined ? {} : { rowFits }),\n };\n}\n","import { type ReactElement, Suspense, lazy } from 'react';\nimport type { RelationPickerDialogProps } from './relation-picker-dialog.js';\n\nconst Dialog = lazy(() =>\n import('./relation-picker-dialog.js').then((module) => ({\n default: module.RelationPickerDialog,\n })),\n);\n\n/** The \"Advanced search\" dialog, loaded on the first open: nothing is drawn until it arrives. */\nexport function LazyRelationPickerDialog<const N extends string = string>(\n props: RelationPickerDialogProps<N>,\n): ReactElement {\n return (\n <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,MAAM;IACJ,MAAM;IACN;IACA,SAAS,EAAE,8BAA8B;KACvC,QAAQ,EAAE,MAAM;KAChB,cAAc,UAAU,MAAM;IAChC,CAAC;GACH;EACF;CACF;CACA,OAAO,EAAE,SAAS,WAAW,QAAQ;AACvC;AAOA,SAAgB,sBAAsB,OAWpC;CACA,MAAM,EAAE,iBAAiB;CACzB,MAAM,OAAO,kBAAkB,KAAK;CACpC,MAAM,UAAU,KAAK;CACrB,MAAM,WAAW,MAAM,cACd,QAAQ,WAAW,IAAI,eAAe,CAAC,GAAG,SAAS,GAAI,gBAAgB,CAAC,CAAE,GACjF,CAAC,SAAS,YAAY,CACxB;CACA,MAAM,UAAU,MAAM,cAElB,QAAQ,WAAW,IAAI,KAAA,KAAa,QAAiC,WAAW,KAAK,OAAO,GAC9F,CAAC,OAAO,CACV;CACA,OAAO;EACL,cAAc;EACd,GAAI,KAAK,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK;EACrD,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;CAC7C;AACF;;;AClIA,MAAM,SAAS,WACb,OAAO,uCAA8B,CAAC,MAAM,YAAY,EACtD,SAAS,OAAO,qBAClB,EAAE,CACJ;AAGA,SAAgB,yBACd,OACc;CACd,OACE,IAAC,UAAD;EAAU,UAAU;EAClB,UAAA,IAAC,QAAD,EAAQ,GAAI,MAAQ,CAAA;CACZ,CAAA;AAEd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-relation-picker-dialog-C_VlGlDz.cjs","names":["useOptionalT","useApp","useTestIds","useI18nCaps","useCandidatesAccess","React","resolveCandidates","declaredText","resolveFieldLabel","lazy","Suspense"],"sources":["../src/fields/candidates-match.ts","../src/fields/candidates-gate.ts","../src/fields/lazy-relation-picker-dialog.tsx"],"sourcesContent":["import type { FixedFilterInput } from '@burojs/core';\n\ntype Entry = { readonly field?: unknown; readonly op?: unknown; readonly value?: unknown };\n\n/**\n * Whether `row` meets every candidate filter (P7 3.4): `true`, `false`, or `undefined` when the\n * row does not carry a field a filter names (a narrower projection), so nothing can be said.\n * Only the flat `{ field, op, value }` entries candidates resolve to are evaluated; this is what\n * \"does not match the current filter\" is decided on, never what is sent.\n */\nexport function rowMatches(\n row: Readonly<Record<string, unknown>>,\n filters: readonly FixedFilterInput[],\n): boolean | undefined {\n let unknown = false;\n for (const filter of filters) {\n const group = filter as { readonly and?: unknown; readonly or?: unknown };\n if (Array.isArray(group.and) || Array.isArray(group.or)) {\n const parts = (\n Array.isArray(group.and) ? group.and : group.or\n ) as readonly FixedFilterInput[];\n const answers = parts.map((part) => rowMatches(row, [part]));\n const all = Array.isArray(group.and);\n const decided = answers.filter((answer) => answer !== undefined);\n if (all ? decided.includes(false) : decided.length > 0 && !decided.includes(true))\n return false;\n if (decided.length < answers.length && !(all ? false : decided.includes(true)))\n unknown = true;\n continue;\n }\n const { field, op, value } = filter as Entry;\n if (typeof field !== 'string' || typeof op !== 'string') continue;\n if (!Object.hasOwn(row, field)) {\n unknown = true;\n continue;\n }\n const held = holds(row[field], op, value);\n if (held === false) return false;\n if (held === undefined) unknown = true;\n }\n return unknown ? undefined : true;\n}\n\nfunction holds(actual: unknown, op: string, expected: unknown): boolean | undefined {\n const list = Array.isArray(expected) ? (expected as readonly unknown[]) : undefined;\n const text = (value: unknown) => String(value ?? '').toLowerCase();\n switch (op) {\n case 'eq':\n return Object.is(actual, expected) || String(actual) === String(expected);\n case 'neq':\n return !(Object.is(actual, expected) || String(actual) === String(expected));\n case 'in':\n return list === undefined\n ? undefined\n : list.some((entry) => String(entry) === String(actual));\n case 'notIn':\n return list === undefined\n ? undefined\n : !list.some((entry) => String(entry) === String(actual));\n case 'gt':\n return compare(actual, expected, (a, b) => a > b);\n case 'gte':\n return compare(actual, expected, (a, b) => a >= b);\n case 'lt':\n return compare(actual, expected, (a, b) => a < b);\n case 'lte':\n return compare(actual, expected, (a, b) => a <= b);\n case 'contains':\n return text(actual).includes(text(expected));\n case 'startsWith':\n return text(actual).startsWith(text(expected));\n case 'endsWith':\n return text(actual).endsWith(text(expected));\n case 'isNull':\n return actual === null || actual === undefined;\n case 'isNotNull':\n return actual !== null && actual !== undefined;\n default:\n return undefined;\n }\n}\n\nfunction compare(\n actual: unknown,\n expected: unknown,\n test: (a: number | string, b: number | string) => boolean,\n): boolean | undefined {\n const both =\n (typeof actual === 'number' && typeof expected === 'number') ||\n (typeof actual === 'string' && typeof expected === 'string');\n return both ? test(actual as number | string, expected as number | string) : undefined;\n}\n","import {\n type FixedFilterInput,\n type RelationCandidate,\n type ScreenSources,\n resolveCandidates,\n resolveFieldLabel,\n declaredText,\n} from '@burojs/core';\nimport { useApp, useCandidatesAccess, useI18nCaps, useOptionalT, useTestIds } from '@burojs/react';\nimport * as React from 'react';\nimport { rowMatches } from './candidates-match.js';\n\n/** A select that must not read its target now (P7 3.4): why, and what it tells the user. */\nexport type CandidatesGate =\n | { readonly kind: 'pending' }\n | { readonly kind: 'empty'; readonly message: string; readonly testId: string }\n | { readonly kind: 'forbidden'; readonly message: string; readonly testId: string };\n\nconst NO_SOURCES: ScreenSources = Object.freeze({});\nconst NO_FILTERS: readonly FixedFilterInput[] = Object.freeze([]);\n\n/**\n * A relation field's `candidates` as the select applies them (P7 3.4): the filters to send and,\n * when they say the target must not be read yet, the gate that tells the user why. The refs are\n * read from the owner's projected sources, so a field P5 hides reads `null` (the select asks for\n * it first, and sends nothing); a candidate on a target field the user may not view forbids the\n * read; an undecided source or permission map keeps the select disabled.\n */\nexport function useCandidatesGate(input: {\n readonly to: string | undefined;\n readonly candidates: readonly RelationCandidate[] | undefined;\n readonly sources: ScreenSources | undefined;\n readonly resource: string;\n readonly fieldName: string;\n}): { readonly filters: readonly FixedFilterInput[]; readonly gate?: CandidatesGate } {\n const { to, candidates, sources, resource, fieldName } = input;\n const t = useOptionalT();\n const app = useApp();\n const tid = useTestIds();\n const ownerCaps = useI18nCaps(resource);\n const targetCaps = useI18nCaps(to ?? resource);\n const access = useCandidatesAccess(to ?? '', candidates);\n const resolution = React.useMemo(\n () => resolveCandidates(candidates, sources ?? NO_SOURCES),\n [candidates, sources],\n );\n if (candidates === undefined || candidates.length === 0) return { filters: NO_FILTERS };\n const testId = tid.relationCandidatesHint(resource, fieldName);\n if (access.status === 'pending') return { filters: NO_FILTERS, gate: { kind: 'pending' } };\n if (access.status === 'forbidden') {\n const declared = declaredText(\n 'field',\n (app.registry.get(to ?? '')?.fields as Record<string, unknown> | undefined)?.[access.field],\n 'label',\n );\n const label = resolveFieldLabel(targetCaps, access.field, declared);\n return {\n filters: NO_FILTERS,\n gate: {\n kind: 'forbidden',\n testId,\n message: t('relationPicker.cannotSearchBy', {\n params: { label },\n defaultValue: `You cannot search by ${label}`,\n }),\n },\n };\n }\n if (resolution.status === 'pending') return { filters: NO_FILTERS, gate: { kind: 'pending' } };\n if (resolution.status === 'empty') {\n const { source, path } = resolution.hint;\n const head = path[0];\n // The field a `values` / `record` ref reads is labelled as the owner labels it; any other\n // source (`scope`, `user`) names the key it reads, humanised.\n const own = source === 'values' || source === 'record';\n const declared =\n own && head !== undefined\n ? declaredText(\n 'field',\n (app.registry.get(resource)?.fields as Record<string, unknown> | undefined)?.[head],\n 'label',\n )\n : undefined;\n const label = resolveFieldLabel(ownerCaps, head ?? source, declared);\n return {\n filters: NO_FILTERS,\n gate: {\n kind: 'empty',\n testId,\n message: t('relationPicker.chooseFirst', {\n params: { label },\n defaultValue: `Choose ${label} first`,\n }),\n },\n };\n }\n return { filters: resolution.filters };\n}\n\n/**\n * A select's declared candidates as the shared select wiring applies them (`CandidatesRelationPicker`\n * and `useRelationPicker`): the gate, the resolved candidate filters prepended to the caller's\n * `fixedFilters`, and whether a loaded row fits them (`undefined` when no candidate filter applies).\n */\nexport function useCandidateSelection(input: {\n readonly to: string | undefined;\n readonly candidates: readonly RelationCandidate[] | undefined;\n readonly sources: ScreenSources | undefined;\n readonly resource: string;\n readonly fieldName: string;\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n}): {\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n readonly gate?: CandidatesGate;\n readonly rowFits?: (row: Record<string, unknown>) => boolean | undefined;\n} {\n const { fixedFilters } = input;\n const gate = useCandidatesGate(input);\n const filters = gate.filters;\n const combined = React.useMemo(\n () => (filters.length === 0 ? fixedFilters : [...filters, ...(fixedFilters ?? [])]),\n [filters, fixedFilters],\n );\n const rowFits = React.useMemo(\n () =>\n filters.length === 0 ? undefined : (row: Record<string, unknown>) => rowMatches(row, filters),\n [filters],\n );\n return {\n fixedFilters: combined,\n ...(gate.gate === undefined ? {} : { gate: gate.gate }),\n ...(rowFits === undefined ? {} : { rowFits }),\n };\n}\n","import { type ReactElement, Suspense, lazy } from 'react';\nimport type { RelationPickerDialogProps } from './relation-picker-dialog.js';\n\nconst Dialog = lazy(() =>\n import('./relation-picker-dialog.js').then((module) => ({\n default: module.RelationPickerDialog,\n })),\n);\n\n/** The \"Advanced search\" dialog, loaded on the first open: nothing is drawn until it arrives. */\nexport function LazyRelationPickerDialog<const N extends string = string>(\n props: RelationPickerDialogProps<N>,\n): ReactElement {\n return (\n <Suspense fallback={null}>\n <Dialog {...props} />\n </Suspense>\n );\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,WACd,KACA,SACqB;CACrB,IAAI,UAAU;CACd,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ;EACd,IAAI,MAAM,QAAQ,MAAM,GAAG,KAAK,MAAM,QAAQ,MAAM,EAAE,GAAG;GAIvD,MAAM,WAFJ,MAAM,QAAQ,MAAM,GAAG,IAAI,MAAM,MAAM,MAAM,GAAA,CAEzB,KAAK,SAAS,WAAW,KAAK,CAAC,IAAI,CAAC,CAAC;GAC3D,MAAM,MAAM,MAAM,QAAQ,MAAM,GAAG;GACnC,MAAM,UAAU,QAAQ,QAAQ,WAAW,WAAW,KAAA,CAAS;GAC/D,IAAI,MAAM,QAAQ,SAAS,KAAK,IAAI,QAAQ,SAAS,KAAK,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WH,MAAM,cACd,QAAQ,WAAW,IAAI,eAAe,CAAC,GAAG,SAAS,GAAI,gBAAgB,CAAC,CAAE,GACjF,CAAC,SAAS,YAAY,CACxB;CACA,MAAM,UAAUA,MAAM,cAElB,QAAQ,WAAW,IAAI,KAAA,KAAa,QAAiC,WAAW,KAAK,OAAO,GAC9F,CAAC,OAAO,CACV;CACA,OAAO;EACL,cAAc;EACd,GAAI,KAAK,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK;EACrD,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;CAC7C;AACF;;;AClIA,MAAM,UAAA,GAASI,MAAAA,KAAAA,OAAAA,QAAAA,QAAAA,CAAAA,CAAAA,WAAAA,QACb,uCAAA,CAAA,CAAA,CAAsC,MAAM,YAAY,EACtD,SAAS,OAAO,qBAClB,EAAE,CACJ;AAGA,SAAgB,yBACd,OACc;CACd,QACE,GAAA,kBAAA,IAAA,CAACC,MAAAA,UAAD;EAAU,UAAU;EAClB,WAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAQ,GAAI,MAAQ,CAAA;CACZ,CAAA;AAEd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-flow-route-CyMzUidK.js","names":[],"sources":["../src/flows/page-flow-route.tsx"],"sourcesContent":["'use client';\n/**\n * A page-hosted flow's route (P6 3.11): `<record route>/<flow name>`. It owns the whole gate in\n * order, so a user who may not run the flow never sees a trace of it:\n *\n * 1. the permission map is decided, else the record route's loading state and nothing is read;\n * 2. static: the resource has a record page, the flow is an item flow and, in the published\n * snapshot, its `host` is `page`; else the record route's not-found;\n * 3. the record is read by id with the record DTO;\n * 4. the flow's gate over that row (`requires`, the mutation's `requires`, `action/run` rules):\n * hidden, absent, or a missing or forbidden row is the same not-found as `/articles/missing`;\n * a false `when` or a blocking pre-click check is \"not available\" and the way back;\n * 5. only then the run (`useFlowRun`) and its sources.\n */\nimport {\n type RecordId,\n type RouteMatch,\n compileFlow,\n dtoFields,\n effectiveFlow,\n hrefFor,\n permissionsUndecided,\n} from '@burojs/core';\nimport {\n recordRouteAvailable,\n retryRecordRead,\n useApp,\n useApplicationSnapshot,\n useDispatcherEffects,\n useFlowRowResolver,\n useI18nCaps,\n useOne,\n useOptionalT,\n usePermissions,\n useProjectedTitle,\n useRouteNavigate,\n useRouteRecordId,\n useTestIds,\n} from '@burojs/react';\nimport { useFlowRun } from '@burojs/react/flows';\nimport { IconLoader2 } from '@tabler/icons-react';\nimport { type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { reasonText } from '../lib/reason-text.js';\nimport { InvalidRouteId, LoadError } from '../load-error/load-error-view.js';\nimport { recordTrailKey, usePublishRecordTrail } from '../layout/record-trail-store.js';\nimport { RecordState } from '../record/record-state.js';\nimport { NavAreaNotFound } from '../layout/resource-page-router.js';\nimport { canonicalNavKey } from '../resource-key.js';\nimport { Button } from '../primitives/button.js';\nimport { useFlowChrome } from './chrome.js';\nimport { type FlowHostBinding, FlowHostBindingContext, FlowScreen } from './flow-screen.js';\n\ntype Row = { id: string } & Record<string, unknown>;\n\ninterface PageFlowProps {\n readonly resource: string;\n readonly id: string;\n readonly name: string;\n}\n\nexport interface PageFlowRouteProps {\n readonly match: RouteMatch;\n}\n\n/** The route: the static gate, then the record, then the flow's own gate. */\nexport function PageFlowRoute({ match }: PageFlowRouteProps): ReactElement {\n const app = useApp();\n const snapshot = useApplicationSnapshot();\n const permissions = usePermissions();\n const resource = canonicalNavKey(match as never);\n const id = match.id ?? '';\n const name = match.flow ?? '';\n // (1) Decided before anything is read.\n if (permissionsUndecided(permissions)) return <RecordState state=\"loading\" />;\n // (2) Static: a record page to hang the route on, and an item flow whose effective host is page.\n const flow = effectiveFlow(snapshot, match.ref, name);\n const hasRecordPage =\n recordRouteAvailable(app.registry, resource, 'show') ||\n recordRouteAvailable(app.registry, resource, 'edit');\n // A name no item flow answers to is no route at all (`/orders/x/segments`): the framework 404,\n // as for any unmatched URL. A flow that exists but is not page-hosted, or a record page that is\n // missing, keeps the record route's not-found, so a denied flow reads like a missing record.\n if (flow === undefined) return <NavAreaNotFound />;\n if (!hasRecordPage || flow.host !== 'page' || id === '') return <RecordState state=\"not-found\" />;\n return <PageFlowRecord key={`${resource}:${id}:${name}`} {...{ resource, id, name }} />;\n}\n\n/** (3) The record by id, with the record DTO: the same read the record route makes. */\nfunction PageFlowRecord(props: PageFlowProps): ReactElement {\n const { resource, id } = props;\n // The URL's id as the id field types it (spec 4.19); an invalid one names no record.\n const recordId = useRouteRecordId(resource, id);\n if (recordId === undefined) return <InvalidRouteId resource={resource} />;\n return <PageFlowRead {...props} recordId={recordId} />;\n}\n\n/** The record by its typed id. */\nfunction PageFlowRead(props: PageFlowProps & { readonly recordId: RecordId }): ReactElement {\n const { resource, recordId } = props;\n const app = useApp();\n const def = app.registry.get(resource);\n const projection = useMemo(\n () => (def === undefined ? undefined : dtoFields(def, 'record')),\n [def],\n );\n const query = useOne(resource, {\n id: recordId,\n retry: retryRecordRead,\n ...(projection === undefined ? {} : { projection }),\n });\n const result = query.data as { readonly data?: unknown } | undefined;\n if (result !== undefined) {\n const record = result.data;\n if (record === null || typeof record !== 'object') return <RecordState state=\"not-found\" />;\n return (\n <PageFlowGate resource={resource} id={props.id} name={props.name} record={record as Row} />\n );\n }\n if (query.error != null) {\n return (\n <LoadError\n surface=\"record\"\n resource={resource}\n error={query.error}\n retry={() => void query.refetch()}\n />\n );\n }\n return <RecordState state=\"loading\" />;\n}\n\n/** (4) The flow's gate over the row, as its button decides it: no second rule here. */\nfunction PageFlowGate(props: PageFlowProps & { readonly record: Row }): ReactElement {\n const { resource, name, record } = props;\n const resolve = useFlowRowResolver(resource);\n const control = resolve(name, record);\n // Someone else's change can take the flow away under a form that holds input: the page keeps\n // the form, read-only, with the \"no longer applies\" notice and Discard (3.12), instead of\n // unmounting it silently. `useRef` here, `PageFlowRun` mounted from the first available render.\n const dirty = useRef(false);\n const running = useRef(false);\n const goneNow =\n (control.state === 'absent' && control.cause === 'when') || control.state === 'disabled';\n const keep = goneNow && running.current && dirty.current;\n const track = (value: boolean) => {\n dirty.current = value;\n };\n if (keep)\n return (\n <PageFlowRun {...props} stale onDirty={track} onMounted={(on) => (running.current = on)} />\n );\n switch (control.state) {\n case 'undecided':\n case 'pending':\n return <RecordState state=\"loading\" />;\n case 'absent':\n return control.cause === 'when' ? (\n <PageFlowUnavailable {...props} />\n ) : (\n <RecordState state=\"not-found\" />\n );\n case 'disabled':\n return (\n <PageFlowUnavailable\n {...props}\n {...(control.reason === undefined ? {} : { reason: control.reason })}\n />\n );\n default:\n return (\n <PageFlowRun\n {...props}\n record={(control.record ?? record) as Row}\n onDirty={track}\n onMounted={(on) => (running.current = on)}\n />\n );\n }\n}\n\n/**\n * The flow's name, the record's title and the record's way back, shared by every state of the\n * page that shows the record. It also tells the header's trail (`<HeaderBreadcrumbs>`) the\n * record's title and the flow's label, which the trail ends with: only these states do, so a\n * loading or not-found flow route never names its flow.\n */\nfunction usePageFlowFrame(props: PageFlowProps & { readonly record: Row }) {\n const { resource, id, name, record } = props;\n const app = useApp();\n const chrome = useFlowChrome(resource, name);\n const title = useProjectedTitle(resource, id, record);\n const showable = recordRouteAvailable(app.registry, resource, 'show');\n const recordHref = hrefFor(app.registry, resource, {\n action: showable ? 'show' : 'edit',\n id,\n });\n usePublishRecordTrail({\n key: recordTrailKey(resource, id, `flow:${name}`),\n title,\n flowLabel: chrome.labelText,\n });\n return { chrome, title, recordHref };\n}\n\n/** `when` false, or a blocking check: the reason and the way back, no form. */\nfunction PageFlowUnavailable(\n props: PageFlowProps & { readonly record: Row; readonly reason?: string },\n): ReactElement {\n const t = useOptionalT();\n const caps = useI18nCaps(props.resource);\n const tid = useTestIds();\n const { recordHref } = usePageFlowFrame(props);\n const Link = useLinkComponent();\n const flowId = usePageFlowId(props.resource, props.name);\n return (\n <div>\n <div\n role=\"status\"\n data-testid={`${tid.pageFlow(flowId)}:unavailable`}\n className=\"flex flex-col gap-2 px-1 py-6 text-sm\"\n >\n <p className=\"font-medium\">\n {t('flow.notAvailable', { defaultValue: 'This action is not available' })}\n </p>\n {props.reason === undefined ? null : (\n <p className=\"text-muted-foreground\">{reasonText(caps, props.reason, props.resource)}</p>\n )}\n <Link href={recordHref} className=\"underline\">\n {t('flow.back', { defaultValue: 'Back' })}\n </Link>\n </div>\n </div>\n );\n}\n\n/** The flow's identity (`default:articles/actions/rename`), for test ids; stable when compiled. */\nfunction usePageFlowId(resource: string, name: string): string {\n const app = useApp();\n const def = app.registry.get(resource);\n return useMemo(() => {\n try {\n return def === undefined\n ? `${resource}/actions/${name}`\n : compileFlow(def as never, name).flowId;\n } catch {\n return `${resource}/actions/${name}`;\n }\n }, [def, resource, name]);\n}\n\n/** (5) The run and its host. */\nfunction PageFlowRun(\n props: PageFlowProps & {\n readonly record: Row;\n /** The flow no longer applies: the form stays, read-only, with a notice and Discard. */\n readonly stale?: boolean;\n readonly onDirty?: (dirty: boolean) => void;\n readonly onMounted?: (mounted: boolean) => void;\n },\n): ReactElement {\n const { resource, name, stale = false, onDirty, onMounted } = props;\n // The run belongs to the record as it was opened: the refetch after the write must not build\n // a new run (and lose the outcome `then` is about to run on). Display reads the fresh one.\n const [record] = useState(props.record);\n const t = useOptionalT();\n const caps = useI18nCaps(resource);\n const tid = useTestIds();\n const navigate = useRouteNavigate();\n const Link = useLinkComponent();\n const scopeEffects = useDispatcherEffects();\n const { chrome, title, recordHref } = usePageFlowFrame(props);\n const navigateRef = useRef(navigate);\n navigateRef.current = navigate;\n // `redirect` replaces the page: Back cannot reach a form that has been submitted.\n const thenEffects = useCallback(\n () => ({\n ...scopeEffects(),\n redirect: (to: Parameters<typeof navigate>[0]) => navigateRef.current(to, { replace: true }),\n }),\n [scopeEffects],\n );\n const target = useMemo(() => ({ resource, action: name }), [resource, name]);\n const flow = useFlowRun(target, { record, surface: 'page', thenEffects });\n // `then` is the page's to run, once it left the form (4.13).\n flow.holdThen(true);\n const { run, snapshot, compiled } = flow;\n const flowRef = useRef(flow);\n flowRef.current = flow;\n\n // The page leaves the form behind: after the form below it reset (a clean form asks the guard\n // nothing), replace the page by the destination, then run `then` over it.\n const [finished, setFinished] = useState(false);\n useEffect(() => {\n if (!finished) return;\n const current = flowRef.current;\n if (current.compiled?.flow.then?.redirect === undefined)\n navigateRef.current(recordHref, { replace: true });\n // After the route committed: an overlay opened by `then` belongs to the destination, and a\n // route change in flight would close it again.\n setTimeout(() => current.runThen(), 0);\n }, [finished, recordHref]);\n const binding = useMemo<FlowHostBinding>(\n () => ({\n kind: 'page',\n close: () => navigateRef.current(recordHref),\n finish: () => setFinished(true),\n }),\n [recordHref],\n );\n\n useEffect(() => {\n onMounted?.(true);\n return () => onMounted?.(false);\n }, [onMounted]);\n // Unsaved input or an unresolved attempt: what the gate must not unmount silently.\n useEffect(() => {\n if (run === null) return;\n let initial: string | undefined;\n const sync = () => {\n const now = run.getSnapshot();\n if (initial === undefined && now.history.includes('open'))\n initial = JSON.stringify(now.values);\n onDirty?.(\n now.outcome?.outcome !== 'success' &&\n (now.outcome?.outcome === 'unknown' ||\n (initial !== undefined && JSON.stringify(now.values) !== initial)),\n );\n };\n sync();\n return run.subscribe(sync);\n }, [run, onDirty]);\n // Discard: the input is dropped first, so the guard has nothing to ask, then the page leaves.\n const [discarded, setDiscarded] = useState(false);\n useEffect(() => {\n if (discarded) navigateRef.current(recordHref, { replace: true });\n }, [discarded, recordHref]);\n\n const documentTitle = `${chrome.labelText}${title === '' ? '' : ` · ${title}`}`;\n useEffect(() => {\n const previous = document.title;\n document.title = documentTitle;\n return () => {\n document.title = previous;\n };\n }, [documentTitle]);\n\n const opened =\n run !== null &&\n compiled !== null &&\n (snapshot.history.includes('open') || snapshot.step === 'outcome');\n const refused = snapshot.control === 'disabled' || snapshot.control === 'absent';\n return (\n <div\n data-testid={compiled === null ? undefined : tid.pageFlow(compiled.flowId)}\n className=\"flex min-h-0 flex-col gap-4\"\n >\n <div className=\"flex flex-wrap items-center gap-2\">\n <Link\n href={recordHref}\n className=\"ml-auto text-sm underline\"\n data-testid={`${tid.pageFlow(compiled?.flowId ?? name)}:back`}\n >\n {t('flow.back', { defaultValue: 'Back' })}\n </Link>\n </div>\n {stale ? (\n <div\n role=\"status\"\n data-buro-flow-state=\"stale\"\n className=\"flex flex-wrap items-center gap-2 text-sm text-muted-foreground\"\n >\n <span>\n {t('flow.noLongerApplies', { defaultValue: 'This action no longer applies' })}\n </span>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => {\n flow.reset();\n setDiscarded(true);\n }}\n >\n {t('flow.discard', { defaultValue: 'Discard' })}\n </Button>\n </div>\n ) : null}\n {opened ? (\n <FlowHostBindingContext.Provider value={binding}>\n <fieldset disabled={stale} className=\"m-0 min-w-0 border-0 p-0\">\n <FlowScreen\n host=\"page\"\n run={run}\n compiled={compiled}\n label={chrome.labelText}\n {...(title === '' ? {} : { title })}\n record={record}\n />\n </fieldset>\n </FlowHostBindingContext.Provider>\n ) : refused ? (\n <p role=\"alert\" className=\"text-sm\">\n {snapshot.reason === undefined\n ? t('flow.unavailable', { defaultValue: 'Not allowed.' })\n : reasonText(caps, snapshot.reason, resource)}\n </p>\n ) : (\n <IconLoader2 className=\"h-5 w-5 animate-spin self-center\" aria-hidden=\"true\" />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkEA,SAAgB,cAAc,EAAE,SAA2C;CACzE,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,uBAAuB;CACxC,MAAM,cAAc,eAAe;CACnC,MAAM,WAAW,gBAAgB,KAAc;CAC/C,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,OAAO,MAAM,QAAQ;CAE3B,IAAI,qBAAqB,WAAW,GAAG,OAAO,IAAC,aAAD,EAAa,OAAM,UAAW,CAAA;CAE5E,MAAM,OAAO,cAAc,UAAU,MAAM,KAAK,IAAI;CACpD,MAAM,gBACJ,qBA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L,wBAAqB;IACrB,WAAU;IAHZ,UAAA,CAKE,IAAC,QAAD,EAAA,UACG,EAAE,wBAAwB,EAAE,cAAc,gCAAgC,CAAC,EACxE,CAAA,GACN,IAAC,QAAD;KACE,MAAK;KACL,MAAK;KACL,SAAQ;KACR,eAAe;MACb,KAAK,MAAM;MACX,aAAa,IAAI;KACnB;KAEC,UAAA,EAAE,gBAAgB,EAAE,cAAc,UAAU,CAAC;IACxC,CAAA,CACL;GACH,CAAA,IAAA;GACH,SACC,IAAC,uBAAuB,UAAxB;IAAiC,OAAO;IACtC,UAAA,IAAC,YAAD;KAAU,UAAU;KAAO,WAAU;KACnC,UAAA,IAAC,YAAD;MACE,MAAK;MACA;MACK;MACV,OAAO,OAAO;MACd,GAAK,UAAU,KAAK,CAAC,IAAI,EAAE,MAAM;MACzB;KACT,CAAA;IACO,CAAA;GACqB,CAAA,IAC/B,UACF,IAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;IACvB,UAAA,SAAS,WAAW,KAAA,IACjB,EAAE,oBAAoB,EAAE,cAAc,eAAe,CAAC,IACtD,WAAW,MAAM,SAAS,QAAQ,QAAQ;GAC7C,CAAA,IAEH,IAAC,aAAD;IAAa,WAAU;IAAmC,eAAY;GAAQ,CAAA;EAE7E;;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-flow-route-OFx7h7Ja.cjs","names":["useApp","useApplicationSnapshot","usePermissions","canonicalNavKey","permissionsUndecided","RecordState","effectiveFlow","recordRouteAvailable","NavAreaNotFound","useRouteRecordId","InvalidRouteId","useMemo","dtoFields","useOne","retryRecordRead","LoadError","useFlowRowResolver","useRef","useFlowChrome","useProjectedTitle","hrefFor","recordTrailKey","useOptionalT","useI18nCaps","useTestIds","useLinkComponent","reasonText","compileFlow","useState","useRouteNavigate","useDispatcherEffects","useCallback","useFlowRun","Button","FlowHostBindingContext","FlowScreen","IconLoader2"],"sources":["../src/flows/page-flow-route.tsx"],"sourcesContent":["'use client';\n/**\n * A page-hosted flow's route (P6 3.11): `<record route>/<flow name>`. It owns the whole gate in\n * order, so a user who may not run the flow never sees a trace of it:\n *\n * 1. the permission map is decided, else the record route's loading state and nothing is read;\n * 2. static: the resource has a record page, the flow is an item flow and, in the published\n * snapshot, its `host` is `page`; else the record route's not-found;\n * 3. the record is read by id with the record DTO;\n * 4. the flow's gate over that row (`requires`, the mutation's `requires`, `action/run` rules):\n * hidden, absent, or a missing or forbidden row is the same not-found as `/articles/missing`;\n * a false `when` or a blocking pre-click check is \"not available\" and the way back;\n * 5. only then the run (`useFlowRun`) and its sources.\n */\nimport {\n type RecordId,\n type RouteMatch,\n compileFlow,\n dtoFields,\n effectiveFlow,\n hrefFor,\n permissionsUndecided,\n} from '@burojs/core';\nimport {\n recordRouteAvailable,\n retryRecordRead,\n useApp,\n useApplicationSnapshot,\n useDispatcherEffects,\n useFlowRowResolver,\n useI18nCaps,\n useOne,\n useOptionalT,\n usePermissions,\n useProjectedTitle,\n useRouteNavigate,\n useRouteRecordId,\n useTestIds,\n} from '@burojs/react';\nimport { useFlowRun } from '@burojs/react/flows';\nimport { IconLoader2 } from '@tabler/icons-react';\nimport { type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { reasonText } from '../lib/reason-text.js';\nimport { InvalidRouteId, LoadError } from '../load-error/load-error-view.js';\nimport { recordTrailKey, usePublishRecordTrail } from '../layout/record-trail-store.js';\nimport { RecordState } from '../record/record-state.js';\nimport { NavAreaNotFound } from '../layout/resource-page-router.js';\nimport { canonicalNavKey } from '../resource-key.js';\nimport { Button } from '../primitives/button.js';\nimport { useFlowChrome } from './chrome.js';\nimport { type FlowHostBinding, FlowHostBindingContext, FlowScreen } from './flow-screen.js';\n\ntype Row = { id: string } & Record<string, unknown>;\n\ninterface PageFlowProps {\n readonly resource: string;\n readonly id: string;\n readonly name: string;\n}\n\nexport interface PageFlowRouteProps {\n readonly match: RouteMatch;\n}\n\n/** The route: the static gate, then the record, then the flow's own gate. */\nexport function PageFlowRoute({ match }: PageFlowRouteProps): ReactElement {\n const app = useApp();\n const snapshot = useApplicationSnapshot();\n const permissions = usePermissions();\n const resource = canonicalNavKey(match as never);\n const id = match.id ?? '';\n const name = match.flow ?? '';\n // (1) Decided before anything is read.\n if (permissionsUndecided(permissions)) return <RecordState state=\"loading\" />;\n // (2) Static: a record page to hang the route on, and an item flow whose effective host is page.\n const flow = effectiveFlow(snapshot, match.ref, name);\n const hasRecordPage =\n recordRouteAvailable(app.registry, resource, 'show') ||\n recordRouteAvailable(app.registry, resource, 'edit');\n // A name no item flow answers to is no route at all (`/orders/x/segments`): the framework 404,\n // as for any unmatched URL. A flow that exists but is not page-hosted, or a record page that is\n // missing, keeps the record route's not-found, so a denied flow reads like a missing record.\n if (flow === undefined) return <NavAreaNotFound />;\n if (!hasRecordPage || flow.host !== 'page' || id === '') return <RecordState state=\"not-found\" />;\n return <PageFlowRecord key={`${resource}:${id}:${name}`} {...{ resource, id, name }} />;\n}\n\n/** (3) The record by id, with the record DTO: the same read the record route makes. */\nfunction PageFlowRecord(props: PageFlowProps): ReactElement {\n const { resource, id } = props;\n // The URL's id as the id field types it (spec 4.19); an invalid one names no record.\n const recordId = useRouteRecordId(resource, id);\n if (recordId === undefined) return <InvalidRouteId resource={resource} />;\n return <PageFlowRead {...props} recordId={recordId} />;\n}\n\n/** The record by its typed id. */\nfunction PageFlowRead(props: PageFlowProps & { readonly recordId: RecordId }): ReactElement {\n const { resource, recordId } = props;\n const app = useApp();\n const def = app.registry.get(resource);\n const projection = useMemo(\n () => (def === undefined ? undefined : dtoFields(def, 'record')),\n [def],\n );\n const query = useOne(resource, {\n id: recordId,\n retry: retryRecordRead,\n ...(projection === undefined ? {} : { projection }),\n });\n const result = query.data as { readonly data?: unknown } | undefined;\n if (result !== undefined) {\n const record = result.data;\n if (record === null || typeof record !== 'object') return <RecordState state=\"not-found\" />;\n return (\n <PageFlowGate resource={resource} id={props.id} name={props.name} record={record as Row} />\n );\n }\n if (query.error != null) {\n return (\n <LoadError\n surface=\"record\"\n resource={resource}\n error={query.error}\n retry={() => void query.refetch()}\n />\n );\n }\n return <RecordState state=\"loading\" />;\n}\n\n/** (4) The flow's gate over the row, as its button decides it: no second rule here. */\nfunction PageFlowGate(props: PageFlowProps & { readonly record: Row }): ReactElement {\n const { resource, name, record } = props;\n const resolve = useFlowRowResolver(resource);\n const control = resolve(name, record);\n // Someone else's change can take the flow away under a form that holds input: the page keeps\n // the form, read-only, with the \"no longer applies\" notice and Discard (3.12), instead of\n // unmounting it silently. `useRef` here, `PageFlowRun` mounted from the first available render.\n const dirty = useRef(false);\n const running = useRef(false);\n const goneNow =\n (control.state === 'absent' && control.cause === 'when') || control.state === 'disabled';\n const keep = goneNow && running.current && dirty.current;\n const track = (value: boolean) => {\n dirty.current = value;\n };\n if (keep)\n return (\n <PageFlowRun {...props} stale onDirty={track} onMounted={(on) => (running.current = on)} />\n );\n switch (control.state) {\n case 'undecided':\n case 'pending':\n return <RecordState state=\"loading\" />;\n case 'absent':\n return control.cause === 'when' ? (\n <PageFlowUnavailable {...props} />\n ) : (\n <RecordState state=\"not-found\" />\n );\n case 'disabled':\n return (\n <PageFlowUnavailable\n {...props}\n {...(control.reason === undefined ? {} : { reason: control.reason })}\n />\n );\n default:\n return (\n <PageFlowRun\n {...props}\n record={(control.record ?? record) as Row}\n onDirty={track}\n onMounted={(on) => (running.current = on)}\n />\n );\n }\n}\n\n/**\n * The flow's name, the record's title and the record's way back, shared by every state of the\n * page that shows the record. It also tells the header's trail (`<HeaderBreadcrumbs>`) the\n * record's title and the flow's label, which the trail ends with: only these states do, so a\n * loading or not-found flow route never names its flow.\n */\nfunction usePageFlowFrame(props: PageFlowProps & { readonly record: Row }) {\n const { resource, id, name, record } = props;\n const app = useApp();\n const chrome = useFlowChrome(resource, name);\n const title = useProjectedTitle(resource, id, record);\n const showable = recordRouteAvailable(app.registry, resource, 'show');\n const recordHref = hrefFor(app.registry, resource, {\n action: showable ? 'show' : 'edit',\n id,\n });\n usePublishRecordTrail({\n key: recordTrailKey(resource, id, `flow:${name}`),\n title,\n flowLabel: chrome.labelText,\n });\n return { chrome, title, recordHref };\n}\n\n/** `when` false, or a blocking check: the reason and the way back, no form. */\nfunction PageFlowUnavailable(\n props: PageFlowProps & { readonly record: Row; readonly reason?: string },\n): ReactElement {\n const t = useOptionalT();\n const caps = useI18nCaps(props.resource);\n const tid = useTestIds();\n const { recordHref } = usePageFlowFrame(props);\n const Link = useLinkComponent();\n const flowId = usePageFlowId(props.resource, props.name);\n return (\n <div>\n <div\n role=\"status\"\n data-testid={`${tid.pageFlow(flowId)}:unavailable`}\n className=\"flex flex-col gap-2 px-1 py-6 text-sm\"\n >\n <p className=\"font-medium\">\n {t('flow.notAvailable', { defaultValue: 'This action is not available' })}\n </p>\n {props.reason === undefined ? null : (\n <p className=\"text-muted-foreground\">{reasonText(caps, props.reason, props.resource)}</p>\n )}\n <Link href={recordHref} className=\"underline\">\n {t('flow.back', { defaultValue: 'Back' })}\n </Link>\n </div>\n </div>\n );\n}\n\n/** The flow's identity (`default:articles/actions/rename`), for test ids; stable when compiled. */\nfunction usePageFlowId(resource: string, name: string): string {\n const app = useApp();\n const def = app.registry.get(resource);\n return useMemo(() => {\n try {\n return def === undefined\n ? `${resource}/actions/${name}`\n : compileFlow(def as never, name).flowId;\n } catch {\n return `${resource}/actions/${name}`;\n }\n }, [def, resource, name]);\n}\n\n/** (5) The run and its host. */\nfunction PageFlowRun(\n props: PageFlowProps & {\n readonly record: Row;\n /** The flow no longer applies: the form stays, read-only, with a notice and Discard. */\n readonly stale?: boolean;\n readonly onDirty?: (dirty: boolean) => void;\n readonly onMounted?: (mounted: boolean) => void;\n },\n): ReactElement {\n const { resource, name, stale = false, onDirty, onMounted } = props;\n // The run belongs to the record as it was opened: the refetch after the write must not build\n // a new run (and lose the outcome `then` is about to run on). Display reads the fresh one.\n const [record] = useState(props.record);\n const t = useOptionalT();\n const caps = useI18nCaps(resource);\n const tid = useTestIds();\n const navigate = useRouteNavigate();\n const Link = useLinkComponent();\n const scopeEffects = useDispatcherEffects();\n const { chrome, title, recordHref } = usePageFlowFrame(props);\n const navigateRef = useRef(navigate);\n navigateRef.current = navigate;\n // `redirect` replaces the page: Back cannot reach a form that has been submitted.\n const thenEffects = useCallback(\n () => ({\n ...scopeEffects(),\n redirect: (to: Parameters<typeof navigate>[0]) => navigateRef.current(to, { replace: true }),\n }),\n [scopeEffects],\n );\n const target = useMemo(() => ({ resource, action: name }), [resource, name]);\n const flow = useFlowRun(target, { record, surface: 'page', thenEffects });\n // `then` is the page's to run, once it left the form (4.13).\n flow.holdThen(true);\n const { run, snapshot, compiled } = flow;\n const flowRef = useRef(flow);\n flowRef.current = flow;\n\n // The page leaves the form behind: after the form below it reset (a clean form asks the guard\n // nothing), replace the page by the destination, then run `then` over it.\n const [finished, setFinished] = useState(false);\n useEffect(() => {\n if (!finished) return;\n const current = flowRef.current;\n if (current.compiled?.flow.then?.redirect === undefined)\n navigateRef.current(recordHref, { replace: true });\n // After the route committed: an overlay opened by `then` belongs to the destination, and a\n // route change in flight would close it again.\n setTimeout(() => current.runThen(), 0);\n }, [finished, recordHref]);\n const binding = useMemo<FlowHostBinding>(\n () => ({\n kind: 'page',\n close: () => navigateRef.current(recordHref),\n finish: () => setFinished(true),\n }),\n [recordHref],\n );\n\n useEffect(() => {\n onMounted?.(true);\n return () => onMounted?.(false);\n }, [onMounted]);\n // Unsaved input or an unresolved attempt: what the gate must not unmount silently.\n useEffect(() => {\n if (run === null) return;\n let initial: string | undefined;\n const sync = () => {\n const now = run.getSnapshot();\n if (initial === undefined && now.history.includes('open'))\n initial = JSON.stringify(now.values);\n onDirty?.(\n now.outcome?.outcome !== 'success' &&\n (now.outcome?.outcome === 'unknown' ||\n (initial !== undefined && JSON.stringify(now.values) !== initial)),\n );\n };\n sync();\n return run.subscribe(sync);\n }, [run, onDirty]);\n // Discard: the input is dropped first, so the guard has nothing to ask, then the page leaves.\n const [discarded, setDiscarded] = useState(false);\n useEffect(() => {\n if (discarded) navigateRef.current(recordHref, { replace: true });\n }, [discarded, recordHref]);\n\n const documentTitle = `${chrome.labelText}${title === '' ? '' : ` · ${title}`}`;\n useEffect(() => {\n const previous = document.title;\n document.title = documentTitle;\n return () => {\n document.title = previous;\n };\n }, [documentTitle]);\n\n const opened =\n run !== null &&\n compiled !== null &&\n (snapshot.history.includes('open') || snapshot.step === 'outcome');\n const refused = snapshot.control === 'disabled' || snapshot.control === 'absent';\n return (\n <div\n data-testid={compiled === null ? undefined : tid.pageFlow(compiled.flowId)}\n className=\"flex min-h-0 flex-col gap-4\"\n >\n <div className=\"flex flex-wrap items-center gap-2\">\n <Link\n href={recordHref}\n className=\"ml-auto text-sm underline\"\n data-testid={`${tid.pageFlow(compiled?.flowId ?? name)}:back`}\n >\n {t('flow.back', { defaultValue: 'Back' })}\n </Link>\n </div>\n {stale ? (\n <div\n role=\"status\"\n data-buro-flow-state=\"stale\"\n className=\"flex flex-wrap items-center gap-2 text-sm text-muted-foreground\"\n >\n <span>\n {t('flow.noLongerApplies', { defaultValue: 'This action no longer applies' })}\n </span>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => {\n flow.reset();\n setDiscarded(true);\n }}\n >\n {t('flow.discard', { defaultValue: 'Discard' })}\n </Button>\n </div>\n ) : null}\n {opened ? (\n <FlowHostBindingContext.Provider value={binding}>\n <fieldset disabled={stale} className=\"m-0 min-w-0 border-0 p-0\">\n <FlowScreen\n host=\"page\"\n run={run}\n compiled={compiled}\n label={chrome.labelText}\n {...(title === '' ? {} : { title })}\n record={record}\n />\n </fieldset>\n </FlowHostBindingContext.Provider>\n ) : refused ? (\n <p role=\"alert\" className=\"text-sm\">\n {snapshot.reason === undefined\n ? t('flow.unavailable', { defaultValue: 'Not allowed.' })\n : reasonText(caps, snapshot.reason, resource)}\n </p>\n ) : (\n <IconLoader2 className=\"h-5 w-5 animate-spin self-center\" aria-hidden=\"true\" />\n )}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