@serene-pub/core-catalog 0.6.0-pr-7 → 0.6.0-pr-9

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 (276) hide show
  1. package/README.md +1 -1
  2. package/components/genres/story/authors-note/AuthorsNote.svelte +2 -1
  3. package/components/genres/story/authors-note/AuthorsNoteWidget.svelte +177 -58
  4. package/components/shared/WidgetBoundary.svelte +37 -0
  5. package/components/shared/actions/Actions.svelte +2 -1
  6. package/components/shared/actions/ActionsWidget.svelte +31 -38
  7. package/components/shared/album/Album.svelte +2 -1
  8. package/components/shared/album/AlbumWidget.svelte +1 -7
  9. package/components/shared/annex/Annex.svelte +2 -1
  10. package/components/shared/annex/AnnexWidget.svelte +1 -1
  11. package/components/shared/attendance/Attendance.svelte +2 -1
  12. package/components/shared/attendance/AttendanceWidget.svelte +5 -8
  13. package/components/shared/backdrop/Backdrop.svelte +2 -1
  14. package/components/shared/backdrop/BackdropWidget.svelte +28 -22
  15. package/components/shared/chronicle/Chronicle.svelte +2 -1
  16. package/components/shared/chronicle/ChronicleWidget.svelte +211 -99
  17. package/components/shared/composer/Composer.svelte +25 -0
  18. package/components/shared/composer/ComposerWidget.svelte +146 -0
  19. package/components/shared/composer/composer.ts +10 -0
  20. package/components/shared/composer/settings.ts +59 -0
  21. package/components/shared/composer/target.ts +79 -0
  22. package/components/shared/dialogue-box/DialogueBoxMount.svelte +25 -0
  23. package/components/shared/dialogue-box/DialogueBoxWidget.svelte +207 -0
  24. package/components/shared/dialogue-box/dialogue-box.ts +10 -0
  25. package/components/shared/dialogue-box/settings.ts +25 -0
  26. package/components/shared/lore-entries/LoreEntries.svelte +2 -1
  27. package/components/shared/lore-entries/LoreEntriesWidget.svelte +44 -41
  28. package/components/shared/messages/MessageBlocksView.svelte +1 -1
  29. package/components/shared/messages/MessageControls.svelte +23 -5
  30. package/components/shared/messages/Messages.svelte +2 -1
  31. package/components/shared/messages/MessagesWidget.svelte +82 -191
  32. package/components/shared/messages/NextCharacterBlock.svelte +35 -20
  33. package/components/shared/messages/SceneDivider.svelte +40 -14
  34. package/components/shared/messages/SessionComposer.svelte +178 -123
  35. package/components/shared/messages/SessionContainer.svelte +89 -38
  36. package/components/shared/messages/SessionMessage.svelte +157 -54
  37. package/components/shared/messages/SpokenLine.svelte +57 -16
  38. package/components/shared/messages/StateProposalList.svelte +30 -20
  39. package/components/shared/messages/TurnLine.svelte +258 -66
  40. package/components/shared/messages/conversation.svelte.ts +83 -5
  41. package/components/shared/messages/readingPace.ts +101 -0
  42. package/components/shared/messages/rowFacts.ts +44 -0
  43. package/components/shared/messages/sceneMarks.ts +54 -0
  44. package/components/shared/messages/spokenLine.ts +63 -14
  45. package/components/shared/places/Places.svelte +2 -1
  46. package/components/shared/places/PlacesWidget.svelte +42 -33
  47. package/components/shared/routine-log/RoutineLog.svelte +2 -1
  48. package/components/shared/routine-log/RoutineLogWidget.svelte +0 -4
  49. package/components/shared/routine-log/routineLog.ts +5 -21
  50. package/components/shared/scene-portraits/ScenePortraits.svelte +2 -1
  51. package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +54 -32
  52. package/components/shared/session-runs/SessionRuns.svelte +26 -0
  53. package/components/shared/session-runs/SessionRunsWidget.svelte +270 -0
  54. package/components/shared/session-runs/session-runs.ts +11 -0
  55. package/components/shared/state/PieceCard.svelte +36 -25
  56. package/components/shared/state/SlotControl.svelte +18 -5
  57. package/components/shared/stats/Stats.svelte +2 -1
  58. package/components/shared/stats/StatsWidget.svelte +104 -72
  59. package/components/shared/turn-line/TurnLineMount.svelte +25 -0
  60. package/components/shared/turn-line/TurnLineWidget.svelte +25 -0
  61. package/components/shared/turn-line/settings.ts +31 -0
  62. package/components/shared/turn-line/turn-line.ts +10 -0
  63. package/components/shared/turn-order/TurnOrder.svelte +2 -1
  64. package/components/shared/turn-order/TurnOrderWidget.svelte +1 -6
  65. package/dist/components/actions.js +71 -88
  66. package/dist/components/actions.source.json +1 -1
  67. package/dist/components/album.js +39 -44
  68. package/dist/components/album.source.json +1 -1
  69. package/dist/components/annex.js +17 -8
  70. package/dist/components/annex.source.json +1 -1
  71. package/dist/components/attendance.js +39 -48
  72. package/dist/components/attendance.source.json +1 -1
  73. package/dist/components/authors-note.js +329 -162
  74. package/dist/components/authors-note.source.json +1 -1
  75. package/dist/components/backdrop.js +52 -55
  76. package/dist/components/backdrop.source.json +1 -1
  77. package/dist/components/chronicle.js +798 -559
  78. package/dist/components/chronicle.source.json +1 -1
  79. package/dist/components/composer.js +1639 -0
  80. package/dist/components/composer.source.json +1 -0
  81. package/dist/components/core-ui.json +1 -1
  82. package/dist/components/dialogue-box.js +373 -0
  83. package/dist/components/dialogue-box.source.json +1 -0
  84. package/dist/components/lore-entries.js +134 -122
  85. package/dist/components/lore-entries.source.json +1 -1
  86. package/dist/components/messages.js +1517 -8930
  87. package/dist/components/messages.source.json +1 -1
  88. package/dist/components/places.js +267 -244
  89. package/dist/components/places.source.json +1 -1
  90. package/dist/components/routine-log.js +35 -51
  91. package/dist/components/routine-log.source.json +1 -1
  92. package/dist/components/scene-portraits.js +118 -59
  93. package/dist/components/scene-portraits.source.json +1 -1
  94. package/dist/components/session-runs.js +488 -0
  95. package/dist/components/session-runs.source.json +1 -0
  96. package/dist/components/{shared-7VDIXYAL.js → shared-47J4TNSF.js} +1 -1
  97. package/dist/components/{shared-W3XS5FEL.js → shared-5E4RQYRX.js} +3 -2
  98. package/dist/components/{shared-YDS7HYL6.js → shared-EFMMT76D.js} +57 -4
  99. package/dist/components/{shared-BIWKZFUU.js → shared-FOVKPMSK.js} +3 -3
  100. package/dist/components/{shared-JPG5DQO7.js → shared-HEAKNNZB.js} +92 -17
  101. package/dist/components/shared-JXP6SHKF.js +159 -0
  102. package/dist/components/{shared-XBDUENRA.js → shared-JXYPKSTQ.js} +1 -1
  103. package/dist/components/shared-KJIOSSE3.js +257 -0
  104. package/dist/components/{shared-WV3QTKZT.js → shared-KLURQFWI.js} +13 -9
  105. package/dist/components/shared-MHCNUDUT.js +1680 -0
  106. package/dist/components/{shared-QXF5CJVN.js → shared-NICRJ4Z2.js} +1 -1
  107. package/dist/components/{shared-BBF64YGL.js → shared-W2BBJCNE.js} +22 -16
  108. package/dist/components/shared-YYYXFDZU.js +4354 -0
  109. package/dist/components/stats.js +828 -678
  110. package/dist/components/stats.source.json +1 -1
  111. package/dist/components/turn-line.js +856 -0
  112. package/dist/components/turn-line.source.json +1 -0
  113. package/dist/components/turn-order.js +62 -67
  114. package/dist/components/turn-order.source.json +1 -1
  115. package/dist/factories/answerForm.d.ts +6 -0
  116. package/dist/factories/answerForm.js +104 -96
  117. package/dist/factories/turnOrder.d.ts +98 -105
  118. package/dist/factories/turnOrder.js +120 -136
  119. package/dist/functions/pieces.js +1 -0
  120. package/dist/functions/time.js +2 -0
  121. package/dist/genres/chat/create.js +2 -0
  122. package/dist/genres/chat/memory.js +64 -43
  123. package/dist/genres/chat/respond.d.ts +7 -6
  124. package/dist/genres/chat/respond.js +13 -4
  125. package/dist/genres/chat/turnOrder.d.ts +2 -2
  126. package/dist/genres/chat/turnOrder.js +28 -12
  127. package/dist/genres/defaults.d.ts +28 -6
  128. package/dist/genres/defaults.js +84 -26
  129. package/dist/genres/dungeon-crawler/calls.d.ts +3 -1
  130. package/dist/genres/dungeon-crawler/calls.js +5 -0
  131. package/dist/genres/dungeon-crawler/create.d.ts +9 -6
  132. package/dist/genres/dungeon-crawler/create.js +18 -8
  133. package/dist/genres/dungeon-crawler/death.d.ts +13 -6
  134. package/dist/genres/dungeon-crawler/death.js +26 -12
  135. package/dist/genres/dungeon-crawler/index.d.ts +1 -0
  136. package/dist/genres/dungeon-crawler/index.js +1 -0
  137. package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
  138. package/dist/genres/dungeon-crawler/journal.js +1 -1
  139. package/dist/genres/dungeon-crawler/lore.d.ts +13 -12
  140. package/dist/genres/dungeon-crawler/lore.js +16 -25
  141. package/dist/genres/dungeon-crawler/names.d.ts +10 -3
  142. package/dist/genres/dungeon-crawler/names.js +10 -3
  143. package/dist/genres/dungeon-crawler/preamble.d.ts +5 -4
  144. package/dist/genres/dungeon-crawler/preamble.js +75 -33
  145. package/dist/genres/dungeon-crawler/respond.js +4 -2
  146. package/dist/genres/dungeon-crawler/rest.d.ts +8 -7
  147. package/dist/genres/dungeon-crawler/rest.js +39 -15
  148. package/dist/genres/dungeon-crawler/reveal.js +2 -2
  149. package/dist/genres/dungeon-crawler/roundScript.d.ts +2 -1
  150. package/dist/genres/dungeon-crawler/roundScript.js +23 -5
  151. package/dist/genres/dungeon-crawler/scripts.js +4 -5
  152. package/dist/genres/dungeon-crawler/shape.d.ts +16 -0
  153. package/dist/genres/dungeon-crawler/shape.js +5 -1
  154. package/dist/genres/dungeon-crawler/sheet.d.ts +20 -20
  155. package/dist/genres/dungeon-crawler/story.d.ts +27 -16
  156. package/dist/genres/dungeon-crawler/story.js +175 -46
  157. package/dist/genres/dungeon-crawler/storyScripts.d.ts +2 -2
  158. package/dist/genres/dungeon-crawler/storyScripts.js +109 -14
  159. package/dist/genres/dungeon-crawler/summarizeScene.d.ts +13 -0
  160. package/dist/genres/dungeon-crawler/summarizeScene.js +21 -0
  161. package/dist/genres/dungeon-crawler/turnOrder.d.ts +8 -9
  162. package/dist/genres/dungeon-crawler/turnOrder.js +33 -23
  163. package/dist/genres/guide/create.js +2 -0
  164. package/dist/genres/guide/turnOrder.d.ts +3 -3
  165. package/dist/genres/guide/turnOrder.js +29 -13
  166. package/dist/genres/lair/answerForm.js +4 -1
  167. package/dist/genres/lair/buildRoom.js +4 -3
  168. package/dist/genres/lair/castellanAction.js +160 -154
  169. package/dist/genres/lair/create.js +2 -0
  170. package/dist/genres/lair/fileCurrentRoom.js +13 -10
  171. package/dist/genres/lair/fileRoom.js +4 -3
  172. package/dist/genres/lair/keeper.js +6 -2
  173. package/dist/genres/lair/names.d.ts +2 -0
  174. package/dist/genres/lair/names.js +2 -0
  175. package/dist/genres/lair/reply.js +16 -6
  176. package/dist/genres/lair/roomAnswer.js +4 -3
  177. package/dist/genres/lair/scratchpad.js +9 -7
  178. package/dist/genres/lair/scripts.js +8 -6
  179. package/dist/genres/lair/turnOrder.d.ts +3 -2
  180. package/dist/genres/lair/turnOrder.js +45 -16
  181. package/dist/genres/story/ask.d.ts +4 -0
  182. package/dist/genres/story/ask.js +4 -0
  183. package/dist/genres/story/create.js +15 -0
  184. package/dist/genres/story/index.d.ts +1 -1
  185. package/dist/genres/story/index.js +1 -1
  186. package/dist/genres/story/narrate.js +8 -0
  187. package/dist/genres/story/narrateCharacter.js +8 -0
  188. package/dist/genres/story/reckon.d.ts +5 -19
  189. package/dist/genres/story/reckon.js +53 -40
  190. package/dist/genres/story/reckoning.js +3 -0
  191. package/dist/genres/story/respond.js +17 -28
  192. package/dist/genres/story/sweep.d.ts +1 -1
  193. package/dist/genres/story/sweep.js +1 -1
  194. package/dist/genres/story/turnOrder.d.ts +21 -3
  195. package/dist/genres/story/turnOrder.js +87 -21
  196. package/dist/index.d.ts +3 -0
  197. package/dist/index.js +23 -9
  198. package/dist/loadouts.d.ts +1 -0
  199. package/dist/loadouts.js +17 -1
  200. package/dist/primers/ninth-mile.d.ts +3 -4
  201. package/dist/registry/entries.d.ts +2 -0
  202. package/dist/registry/entries.js +18 -5
  203. package/dist/registry/genres.d.ts +146 -40
  204. package/dist/registry/genres.js +373 -101
  205. package/dist/registry/hostState.d.ts +1 -2
  206. package/dist/registry/hostState.js +2 -4
  207. package/dist/registry/layouts.d.ts +141 -111
  208. package/dist/registry/layouts.js +302 -141
  209. package/dist/registry/slots.d.ts +4 -3
  210. package/dist/registry/slots.js +4 -3
  211. package/dist/registry/widgets.d.ts +12 -2
  212. package/dist/registry/widgets.js +259 -106
  213. package/dist/rulesets/vis-itineris/ruleset.js +8 -5
  214. package/dist/rulesets/wherewithal/ruleset.js +2 -1
  215. package/dist/seed/presets.js +15 -9
  216. package/dist/seed/prompts.js +24 -5
  217. package/dist/seed/scripts.js +3 -0
  218. package/dist/shared/annexField.js +23 -3
  219. package/dist/shared/illustrateScene.d.ts +1 -0
  220. package/dist/shared/illustrateScene.js +29 -1
  221. package/dist/shared/lore.d.ts +13 -0
  222. package/dist/shared/lore.js +37 -1
  223. package/dist/shared/portrait.js +13 -4
  224. package/dist/shared/reckoning.d.ts +8 -2
  225. package/dist/shared/reckoning.js +47 -30
  226. package/dist/shared/roundTick.d.ts +20 -0
  227. package/dist/shared/roundTick.js +76 -0
  228. package/dist/shared/sceneBoundaries.d.ts +7 -0
  229. package/dist/shared/sceneBoundaries.js +62 -0
  230. package/dist/shared/sceneSummaries.d.ts +7 -0
  231. package/dist/shared/sceneSummaries.js +49 -0
  232. package/dist/shared/speakMessage.d.ts +9 -2
  233. package/dist/shared/speakMessage.js +32 -9
  234. package/dist/shared/speechFields.js +4 -0
  235. package/dist/shared/summarize/character.d.ts +1 -1
  236. package/dist/shared/summarize/history.d.ts +1 -1
  237. package/dist/shared/summarize/scene.d.ts +1 -1
  238. package/dist/shared/summarize/summarizeScene.js +1 -0
  239. package/dist/shared/summarize/summarizeSpec.d.ts +1 -1
  240. package/dist/shared/summarize/world.d.ts +1 -1
  241. package/dist/shared/ui/attendance/index.d.ts +3 -2
  242. package/dist/shared/ui/attendance/index.js +3 -7
  243. package/dist/shared/ui/chronicle/index.d.ts +24 -2
  244. package/dist/shared/ui/chronicle/index.js +58 -29
  245. package/dist/shared/ui/conversation/formAnswer.d.ts +16 -2
  246. package/dist/shared/ui/conversation/formAnswer.js +23 -9
  247. package/dist/shared/ui/conversation/index.d.ts +2 -0
  248. package/dist/shared/ui/conversation/index.js +4 -0
  249. package/dist/shared/ui/conversation/itemValues.d.ts +16 -3
  250. package/dist/shared/ui/conversation/itemValues.js +15 -5
  251. package/dist/shared/ui/conversation/messageVerbState.d.ts +17 -2
  252. package/dist/shared/ui/conversation/messageVerbState.js +5 -4
  253. package/dist/shared/ui/conversation/readingPlace.d.ts +40 -0
  254. package/dist/shared/ui/conversation/readingPlace.js +119 -0
  255. package/dist/shared/ui/conversation/rewindStrip.d.ts +13 -4
  256. package/dist/shared/ui/conversation/rewindStrip.js +29 -7
  257. package/dist/shared/ui/conversation/runsInProgress.d.ts +30 -0
  258. package/dist/shared/ui/conversation/runsInProgress.js +47 -0
  259. package/dist/shared/ui/conversation/storyDays.d.ts +7 -1
  260. package/dist/shared/ui/conversation/storyDays.js +8 -0
  261. package/dist/shared/ui/conversation/tableChannel.d.ts +8 -11
  262. package/dist/shared/ui/conversation/tableChannel.js +8 -9
  263. package/dist/shared/ui/places/index.d.ts +3 -2
  264. package/dist/shared/ui/places/index.js +4 -5
  265. package/dist/shared/ui/routine-log/index.d.ts +3 -0
  266. package/dist/shared/ui/routine-log/index.js +22 -0
  267. package/dist/shared/ui/scene-portraits/portraits.d.ts +50 -16
  268. package/dist/shared/ui/scene-portraits/portraits.js +84 -21
  269. package/dist/shared/ui/session-runs/index.d.ts +90 -0
  270. package/dist/shared/ui/session-runs/index.js +143 -0
  271. package/dist/shared/ui/session-state/stateView.d.ts +18 -5
  272. package/dist/shared/ui/session-state/stateView.js +29 -8
  273. package/dist/shared/ui/turn-order/index.d.ts +0 -9
  274. package/dist/shared/ui/turn-order/index.js +1 -2
  275. package/package.json +12 -8
  276. /package/dist/components/{shared-4ME6NFDK.js → shared-LUIF6DW7.js} +0 -0
@@ -0,0 +1 @@
1
+ {"slug":"turn-line","framework":"svelte","entry":"shared/turn-line/turn-line.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/composer/target.ts":"/**\n * The Messages copy a Composer or Turn line belongs to (owner R8 2026-11-05:\n * the composer and the turn line are widgets beside the log, not parts of it).\n *\n * The host gives each the same `session:full` dossier as its TARGET Messages\n * copy — its `composer.channels` narrowed the same way — and says which\n * channel that copy last showed (`show-channel`) under `dossier.composer`.\n * Those two fields are not yet in the SDK's `ConversationComposerV1`, so they\n * are read here, structurally, in ONE place; nothing else touches the shape.\n */\nimport type { SessionDossierV1 } from \"@serene-pub/sdk/component\"\n\nexport type TargetLineWidth = \"column\" | \"full\" | \"comfortable\"\nexport type TargetPresentation = \"rows\" | \"folio\"\n\n/** The Messages copy this Composer / Turn line writes beside. */\nexport interface ComposerTarget {\n\t/** The target Messages instance id (`messages`, `messages#sanctum`). */\n\tinstance: string\n\t/** The channel that copy shows, canonical. */\n\tchannel: string\n\t/** That channel's label in the viewer's language. */\n\tlabel: string\n\t/** The target's Line width, when the host says it. */\n\tlineWidth?: TargetLineWidth\n\t/** The target's effective presentation, when the host says it. */\n\tpresentation?: TargetPresentation\n}\n\nexport interface ComposerTargetFields {\n\t/** Absent: no target resolved — the first writable channel is the lane. */\n\ttarget: ComposerTarget | null\n\t/** Set when the target panel shows a tab that is not a Messages tab. */\n\twritingTo: { channel: string; label: string } | null\n}\n\nconst str = (v: unknown): v is string => typeof v === \"string\" && v !== \"\"\n\n/** Read `dossier.composer.target` and `.writingTo`; both null when the host sends none. */\nexport function composerTargetOf(dossier: unknown): ComposerTargetFields {\n\tconst composer = (dossier as { composer?: Record<string, unknown> } | null | undefined)?.composer\n\tconst t = composer?.target as Record<string, unknown> | null | undefined\n\tconst w = composer?.writingTo as Record<string, unknown> | null | undefined\n\tconst target: ComposerTarget | null =\n\t\tt && str(t.instance) && str(t.channel)\n\t\t\t? {\n\t\t\t\t\tinstance: t.instance,\n\t\t\t\t\tchannel: t.channel,\n\t\t\t\t\tlabel: typeof t.label === \"string\" ? t.label : t.channel,\n\t\t\t\t\t...(t.lineWidth === \"column\" || t.lineWidth === \"full\" || t.lineWidth === \"comfortable\"\n\t\t\t\t\t\t? { lineWidth: t.lineWidth }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(t.presentation === \"rows\" || t.presentation === \"folio\"\n\t\t\t\t\t\t? { presentation: t.presentation }\n\t\t\t\t\t\t: {})\n\t\t\t\t}\n\t\t\t: null\n\tconst writingTo =\n\t\tw && str(w.channel) ? { channel: w.channel, label: typeof w.label === \"string\" && w.label ? w.label : w.channel } : null\n\treturn { target, writingTo }\n}\n\n/**\n * 🚧 Whether the Composer beside this Turn line draws Send (`dossier.composer.sendShown`,\n * the host's answer from the layout). `undefined` when the host says nothing: read as shown.\n */\nexport function composerSendShownOf(dossier: SessionDossierV1 | null | undefined): boolean | undefined {\n\treturn dossier?.composer?.sendShown\n}\n\n/**\n * 🚧 Whether Send is shown: the one rule the Composer and the Turn line both read.\n * At the compact (phone) width Enter writes a new line and only the button sends,\n * so Send shows whatever the setting says; otherwise the setting, absent read as\n * shown. @experimental\n */\nexport function composerSendShown(setting: boolean | undefined, tier: string | undefined): boolean {\n\treturn tier === \"compact\" || setting !== false\n}\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/messages/NextCharacterBlock.svelte":"<script lang=\"ts\">\n\t/**\n\t * Who is due next (PLAN-turn-order §4.9), rendered from the session's\n\t * stored turn order — never derived on the client. It reads the entries\n\t * on **its own log's channel** (the composer's, `conversation.lane`;\n\t * lair re-plan R5): an entry with no `channel` is `main`'s. That\n\t * channel's first entry is its head, named from the order's candidates:\n\t *\n\t * - a character or envoy: \"<name> is ready to continue\", with Continue;\n\t * - `ref: null`, the pipeline's own voice: \"<own voice> is ready to\n\t * continue\", with Continue — the name the page resolved\n\t * (`turn.ownVoiceName`: the Lair's \"Castellan\", else the narrator's);\n\t * - a person (a persona): \"<name>'s turn\", or \"Your turn\" when the\n\t * persona is the viewer's own, and no Continue — a person's turn is\n\t * taken by writing.\n\t *\n\t * An empty order with people to choose from — a round that is over, or\n\t * a manual strategy waiting to be told — waits on a message and offers\n\t * the pick (at the compact width, the shorter \"Your move, or pick who\n\t * speaks\", so the line fits a phone). 🚧 A round that waits on others once the viewer has had their\n\t * say (`waitingFor`, the page's reading) says so: \"Waiting for Maren Holt\". An order whose entries are all on other channels shows\n\t * nothing here.\n\t *\n\t * Continue hands its channel to `onContinue`, so the page fires this\n\t * channel's entry. \"Someone else\" asks the page to open the turn picker.\n\t * With `mode: 'list'` the entries after the head follow as one quiet line.\n\t *\n\t * 🚧 **Continue moves past a waiting player** (Lair rewrite D5,\n\t * 2026-10-21): a planned turn a person plays (`via: 'plan'`, a seated\n\t * player's delver) at the head waits for them — \"Waiting for Maren\".\n\t * The session's owner alone gets Continue there too, with the sentence\n\t * that says what it does: it moves past them (the server skips the seat,\n\t * `skipWaitingTurn`) and the next planned turn takes its place. Anyone\n\t * else waits; the player writes.\n\t *\n\t * It draws the turn line's right half (`TurnLine`, PLAN-core-widgets\n\t * §3.16). Its parts are `messages.turn-line-*` (STYLE-GUIDE §6.16), each\n\t * beside its old name `messages.next-up-*`, ⏳ kept one release so a\n\t * person's style keeps matching: the markup carries no look; the default\n\t * widget stylesheet draws it, keyed on the new names.\n\t */\n\timport type { NextUp } from \"../turn-line/settings\"\n\timport { useConversation } from \"./conversation.svelte\"\n\n\ttype Entry = { ref: string | null; channel?: unknown; [k: string]: unknown }\n\ttype Candidate = {\n\t\tref: string\n\t\tkind: string\n\t\tname: string\n\t\tnickname?: string\n\t\townerUserId?: number\n\t}\n\n\tinterface Props {\n\t\torder: Entry[]\n\t\tcandidates: Candidate[]\n\t\tmode: NextUp\n\t\tshouldShow: boolean\n\t\t/** A face for a ref, when the session has one loaded. */\n\t\tavatarFor?: (ref: string) => unknown\n\t\t/** Continue, with the channel of the log it was pressed under (R5). */\n\t\tonContinue: (channel: string) => void\n\t\tonSomeoneElse: () => void\n\t\t/** Whether anyone else could take the turn. */\n\t\tcanChooseSomeoneElse?: boolean\n\t\t/** The person looking: their own persona's turn reads \"Your turn\". */\n\t\tviewerUserId?: number | null\n\t\t/** 🚧 Whom the round waits on (Q3-3): \"Waiting for Maren Holt\". */\n\t\twaitingFor?: readonly string[]\n\t\t/** 🚧 The viewer owns the session: their Continue moves past a waiting player (D5). */\n\t\tviewerIsOwner?: boolean\n\t\t/** Why nothing starts by itself, as the server sent it (to the owner only): said under the line, or in place of the waiting sentence. */\n\t\tstandstill?: \"no-turn-order\" | \"no-auto-advance\" | \"no-extent\"\n\t}\n\n\tlet {\n\t\torder,\n\t\tcandidates,\n\t\tmode,\n\t\tshouldShow,\n\t\tavatarFor,\n\t\tonContinue,\n\t\tonSomeoneElse,\n\t\tcanChooseSomeoneElse = true,\n\t\tviewerUserId = null,\n\t\twaitingFor = [],\n\t\tviewerIsOwner = false,\n\t\tstandstill\n\t}: Props = $props()\n\tconst STANDSTILL_WORDS = {\n\t\t\"no-turn-order\": \"This genre sets no turn order. Pick who speaks, or press Continue.\",\n\t\t\"no-auto-advance\": \"This genre sets no Auto-advance, so nothing starts by itself. Press Continue.\",\n\t\t\"no-extent\":\n\t\t\t\"Auto-advance is on, but this genre does not say how far it runs, so nothing starts by itself. Press Continue.\"\n\t} as const\n\tconst waitingWords = $derived(\n\t\twaitingFor.length ? `Waiting for ${new Intl.ListFormat(\"en\", { style: \"long\", type: \"conjunction\" }).format([...waitingFor])}` : \"\"\n\t)\n\n\tconst conversation = useConversation()\n\t/** This log's channel — the composer's — `main` by default. */\n\tconst channel = $derived(conversation.lane.current || \"main\")\n\tconst channelOf = (e: Entry) =>\n\t\ttypeof e.channel === \"string\" && e.channel ? e.channel : \"main\"\n\t/** The entries prepared on this channel, in the order's order. */\n\tconst here = $derived(order.filter((e) => channelOf(e) === channel))\n\tconst byRef = $derived(new Map(candidates.map((c) => [c.ref, c])))\n\tconst head = $derived(here[0])\n\tconst nameOf = (ref: string | null): string => {\n\t\tif (ref === null)\n\t\t\treturn conversation.dossier?.turn.ownVoiceName || \"The narrator\"\n\t\tconst c = byRef.get(ref)\n\t\treturn c?.nickname || c?.name || \"Someone\"\n\t}\n\tconst isPerson = (ref: string | null) =>\n\t\tref !== null && byRef.get(ref)?.kind === \"persona\"\n\tconst headName = $derived(head ? nameOf(head.ref) : \"\")\n\tconst headIsPerson = $derived(!!head && isPerson(head.ref))\n\tconst headIsMine = $derived(\n\t\theadIsPerson &&\n\t\t\tviewerUserId != null &&\n\t\t\tbyRef.get(head!.ref as string)?.ownerUserId === viewerUserId\n\t)\n\t/**\n\t * 🚧 The head is a planned turn somebody else plays (a seated player's\n\t * delver, D5): the turn waits for them.\n\t */\n\tconst headWaits = $derived(headIsPerson && !headIsMine && head?.via === \"plan\")\n\t/** 🚧 …and the owner may move past them: Continue skips the seat. */\n\tconst ownerSkips = $derived(headWaits && viewerIsOwner)\n\tconst line = $derived(\n\t\theadIsMine\n\t\t\t? \"Your turn\"\n\t\t\t: headWaits\n\t\t\t\t? `Waiting for ${headName}`\n\t\t\t\t: headIsPerson\n\t\t\t\t\t? `${headName}'s turn`\n\t\t\t\t\t: `${headName} is ready to continue`\n\t)\n\tconst face = $derived(head?.ref ? avatarFor?.(head.ref) : undefined)\n\tconst after = $derived(mode === \"list\" ? here.slice(1) : [])\n</script>\n\n{#if !here.length && waitingWords}\n\t<!-- 🚧 The round waits on others, the viewer's say made (Q3-3). -->\n\t<div data-widget-part=\"messages.turn-line-waiting turn-line.waiting messages.next-up-waiting turn-line.next-up-waiting\" data-waiting-for=\"\">\n\t\t<sp-icon name=\"hourglass\" size=\"14\"></sp-icon>\n\t\t<span data-widget-part=\"messages.turn-line-text turn-line.text messages.next-up-text turn-line.next-up-text\">{waitingWords}</span>\n\t</div>\n{:else if shouldShow && !order.length && candidates.length}\n\t<div data-widget-part=\"messages.turn-line-waiting turn-line.waiting messages.next-up-waiting turn-line.next-up-waiting\">\n\t\t<span data-widget-part=\"messages.turn-line-text turn-line.text messages.next-up-text turn-line.next-up-text\">\n\t\t\t{standstill === \"no-turn-order\" ? STANDSTILL_WORDS[\"no-turn-order\"] : conversation.ctx.layout?.v1?.tier === \"compact\"\n\t\t\t\t? \"Your move, or pick who speaks\"\n\t\t\t\t: \"Waiting for a message — or pick who speaks next\"}\n\t\t</span>\n\t\t<button type=\"button\" data-widget-part=\"messages.turn-line-pick turn-line.pick messages.next-up-pick turn-line.next-up-pick\" onclick={onSomeoneElse}>\n\t\t\t<sp-icon name=\"users\" size=\"14\"></sp-icon>\n\t\t\t<span>Pick</span>\n\t\t</button>\n\t</div>\n{:else if shouldShow && head}\n\t<!-- One line: who is up, and what you can do about it. -->\n\t<div data-widget-part=\"messages.turn-line-head turn-line.head messages.next-up-head turn-line.next-up-head\">\n\t\t<div data-widget-part=\"messages.turn-line-due turn-line.due messages.next-up-line turn-line.next-up-line\">\n\t\t\t{#if face}\n\t\t\t\t<sp-avatar ref={head.ref} size=\"sm\"></sp-avatar>\n\t\t\t{:else if head.ref === null}\n\t\t\t\t<sp-icon name=\"book-open-text\" size=\"18\" data-widget-part=\"messages.turn-line-narrator turn-line.narrator messages.next-up-narrator turn-line.next-up-narrator\"></sp-icon>\n\t\t\t{/if}\n\t\t\t<span data-widget-part=\"messages.turn-line-text turn-line.text messages.next-up-text turn-line.next-up-text\">\n\t\t\t\t{line}\n\t\t\t</span>\n\t\t\t<div data-widget-part=\"messages.turn-line-controls turn-line.controls messages.next-up-controls turn-line.next-up-controls\">\n\t\t\t\t{#if canChooseSomeoneElse}\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-pick turn-line.pick messages.next-up-pick turn-line.next-up-pick\"\n\t\t\t\t\t\tonclick={onSomeoneElse}\n\t\t\t\t\t\ttitle=\"Someone else\"\n\t\t\t\t\t\taria-label=\"Pick someone else to continue\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"users\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t<span data-widget-part=\"messages.turn-line-pick-label turn-line.pick-label messages.next-up-pick-label turn-line.next-up-pick-label\">Someone else</span>\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t\t{#if !headIsPerson}\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-continue turn-line.continue messages.next-up-continue turn-line.next-up-continue\"\n\t\t\t\t\t\tonclick={() => onContinue(channel)}\n\t\t\t\t\t\ttitle=\"Continue\"\n\t\t\t\t\t\taria-label=\"Continue with {headName}\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"play\"></sp-icon>\n\t\t\t\t\t\t<span>Continue</span>\n\t\t\t\t\t</button>\n\t\t\t\t{:else if ownerSkips}\n\t\t\t\t\t<!-- 🚧 D5: the owner's Continue moves past the waiting player. -->\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-continue turn-line.continue messages.next-up-continue turn-line.next-up-continue\"\n\t\t\t\t\t\tdata-skips=\"\"\n\t\t\t\t\t\tonclick={() => onContinue(channel)}\n\t\t\t\t\t\ttitle=\"Move past {headName}: the next turn goes ahead without them\"\n\t\t\t\t\t\taria-label=\"Continue without {headName}\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"skip-forward\"></sp-icon>\n\t\t\t\t\t\t<span>Continue</span>\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t</div>\n\t\t{#if ownerSkips}\n\t\t\t<p data-widget-part=\"messages.turn-line-skip turn-line.skip\">\n\t\t\t\tContinue moves past {headName}: their turn is skipped this round.\n\t\t\t</p>\n\t\t{/if}\n\t\t{#if standstill === \"no-auto-advance\" || standstill === \"no-extent\"}\n\t\t\t<p data-widget-part=\"messages.turn-line-standstill turn-line.standstill\">{STANDSTILL_WORDS[standstill]}</p>\n\t\t{/if}\n\t\t{#if after.length}\n\t\t\t<p data-widget-part=\"messages.turn-line-after turn-line.after messages.next-up-after turn-line.next-up-after\">\n\t\t\t\tThen {after.map((e) => nameOf(e.ref)).join(\", \")}\n\t\t\t</p>\n\t\t{/if}\n\t</div>\n{/if}\n","shared/messages/StateProposalList.svelte":"<script lang=\"ts\">\n\t/**\n\t * Held changes, with the two buttons that decide them.\n\t *\n\t * The model is the one writer with no authority: what it produces is a\n\t * pending line, not a change. So nothing here applies anything — Accept runs\n\t * the same write a script's would have run, Reject leaves the world as it\n\t * was, and until one of them is pressed the stat says what it said.\n\t *\n\t * The same list under a message and in the Review panel, because \"everything\n\t * waiting\" and \"what this turn asked for\" are the same rows read at two\n\t * scopes, and two components would be two ways to describe one payload.\n\t *\n\t * A **superseded** row (plans/29 R-15 *Staleness and order*; U5f) is an\n\t * accept that applied nothing: the slot moved since the proposal was\n\t * made. It stays under its message, collapsed, naming what moved, with\n\t * no buttons — the ledger's word on why the model's ask never landed.\n\t *\n\t * 🚧 A player's **offer** (Give to…, ★4; PLAN-dc-after-walk3 R1-2) is no\n\t * model's ask: offered to the viewer it reads *offered* with Accept and\n\t * Decline; the viewer's OWN offer reads *Offered to Maren Holt — waiting\n\t * for their answer* with Withdraw alone — the giver never accepts their\n\t * own gift (the host refuses it, and the walk's giver met that refusal).\n\t */\n\timport type { ConversationProposalV1 } from \"@serene-pub/core-catalog/conversation\"\n\timport { useConversation, useT } from \"./conversation.svelte\"\n\n\tinterface Props {\n\t\tproposals: ConversationProposalV1[]\n\t\t/** Shown in the Review panel, where a row is not under its message. */\n\t\tshowAnchor?: boolean\n\t\t/**\n\t\t * The widget that draws this copy, when it is not Messages (the Turn\n\t\t * line): every part also carries `<alias>.<name>`, beside its\n\t\t * `messages.<name>`. Unset: the log's copy, unchanged.\n\t\t */\n\t\talias?: string\n\t}\n\tlet { proposals, showAnchor = false, alias }: Props = $props()\n\n\t/** `messages.<name>` for each name, and `<alias>.<name>` beside it when an alias is set. */\n\tconst parts = (...names: string[]): string =>\n\t\tnames.map((n) => (alias ? `messages.${n} ${alias}.${n}` : `messages.${n}`)).join(\" \")\n\n\tconst conv = useConversation()\n\tconst t = useT()\n\tconst describe = (row: ConversationProposalV1) => row.text\n\tconst movedName = (row: ConversationProposalV1) => row.moved ?? t(\"a value\")\n\tconst decide = (id: number, accept: boolean) =>\n\t\tvoid conv.request(\"decide-proposal\", { proposalId: id, accept })\n</script>\n\n{#each proposals as row (row.id)}\n\t{#if row.status === \"superseded\"}\n\t\t<div\n\t\t\tdata-widget-part={parts(\"proposal\")}\n\t\t\tdata-proposal-id={row.id}\n\t\t\tdata-superseded=\"true\"\n\t\t>\n\t\t\t<sp-icon name=\"history\" size=\"11\"></sp-icon>\n\t\t\t<span data-widget-part={parts(\"proposal-text\")}>\n\t\t\t\t{describe(row)}\n\t\t\t\t<span data-widget-part={parts(\"proposal-note\")}>\n\t\t\t\t\t· {t(\"Superseded — {slot} changed since this was proposed\").replace(\n\t\t\t\t\t\t\"{slot}\",\n\t\t\t\t\t\tmovedName(row)\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t{:else if row.offer?.yours}\n\t\t<div data-widget-part={parts(\"proposal\")} data-proposal-id={row.id} data-offer=\"yours\">\n\t\t\t<sp-icon name=\"hourglass\" size=\"11\"></sp-icon>\n\t\t\t<span data-widget-part={parts(\"proposal-text\")}>\n\t\t\t\t{t(\"Offered to {to} — waiting for their answer\").replace(\"{to}\", row.offer.to)}\n\t\t\t\t<span data-widget-part={parts(\"proposal-note\")}>· {describe(row)}</span>\n\t\t\t</span>\n\t\t\t<button\n\t\t\t\tdata-widget-part={parts(\"proposal-decide\", \"proposal-reject\")}\n\t\t\t\tonclick={() => decide(row.id, false)}\n\t\t\t>\n\t\t\t\t{t(\"Withdraw\")}\n\t\t\t</button>\n\t\t</div>\n\t{:else if row.offer}\n\t\t<div data-widget-part={parts(\"proposal\")} data-proposal-id={row.id} data-offer=\"to-you\">\n\t\t\t<sp-icon name=\"hand-helping\" size=\"11\"></sp-icon>\n\t\t\t<span data-widget-part={parts(\"proposal-text\")}>\n\t\t\t\t{describe(row)}\n\t\t\t\t{#if showAnchor && row.messageId != null}\n\t\t\t\t\t<span data-widget-part={parts(\"proposal-anchor\")}>on message {row.messageId}</span>\n\t\t\t\t{/if}\n\t\t\t</span>\n\t\t\t<span data-widget-part={parts(\"proposal-note\")} title={t(\"Offered by {from}\").replace(\"{from}\", row.offer.from)}>\n\t\t\t\t{t(\"offered\")}\n\t\t\t</span>\n\t\t\t<button\n\t\t\t\tdata-widget-part={parts(\"proposal-decide\", \"proposal-accept\")}\n\t\t\t\tonclick={() => decide(row.id, true)}\n\t\t\t>\n\t\t\t\t{t(\"Accept\")}\n\t\t\t</button>\n\t\t\t<button\n\t\t\t\tdata-widget-part={parts(\"proposal-decide\", \"proposal-reject\")}\n\t\t\t\tonclick={() => decide(row.id, false)}\n\t\t\t>\n\t\t\t\t{t(\"Decline\")}\n\t\t\t</button>\n\t\t</div>\n\t{:else}\n\t\t<div data-widget-part={parts(\"proposal\")} data-proposal-id={row.id}>\n\t\t\t<sp-icon name=\"sparkles\" size=\"11\"></sp-icon>\n\t\t\t<span data-widget-part={parts(\"proposal-text\")}>\n\t\t\t\t{describe(row)}\n\t\t\t\t{#if showAnchor && row.messageId != null}\n\t\t\t\t\t<span data-widget-part={parts(\"proposal-anchor\")}>on message {row.messageId}</span>\n\t\t\t\t{/if}\n\t\t\t</span>\n\t\t\t<span data-widget-part={parts(\"proposal-note\")} title=\"Proposed by {row.proposedBy || 'a run'}\">\n\t\t\t\tproposed\n\t\t\t</span>\n\t\t\t<button\n\t\t\t\tdata-widget-part={parts(\"proposal-decide\", \"proposal-accept\")}\n\t\t\t\tonclick={() => decide(row.id, true)}\n\t\t\t>\n\t\t\t\tAccept\n\t\t\t</button>\n\t\t\t<button\n\t\t\t\tdata-widget-part={parts(\"proposal-decide\", \"proposal-reject\")}\n\t\t\t\tonclick={() => decide(row.id, false)}\n\t\t\t>\n\t\t\t\tReject\n\t\t\t</button>\n\t\t</div>\n\t{/if}\n{/each}\n","shared/messages/TurnLine.svelte":"<script lang=\"ts\">\n\t/**\n\t * The **turn line** (PLAN-core-widgets §3.16; owner 2026-10-10: \"the last\n\t * run and the next response trigger above the composer should be\n\t * combined\"): ONE row between the log and the composer, in two halves.\n\t *\n\t * - **Left, what the last run is doing** (`messages.turn-line-run`): a\n\t * status pill read off the newest reply in this log — *Last run\n\t * failed*, the row's error as the pill's title — then *Review N changes* when proposals\n\t * wait for the viewer. While a reply streams it says nothing: the row\n\t * says it beside the name, and the run's card above the composer names the\n\t * run and leaves the status to the row (owner, 2026-11-13). At rest it says nothing (polish parity L1,\n\t * 2026-10-24: one control row under the log): *Wren replied · 6.2 s*,\n\t * *Last run stopped* and *Inspect run* are the newest reply's ⋮ menu's\n\t * (`MessageControls`), and the pill is *Review N changes* alone when\n\t * something waits. When none of those holds the left half, background\n\t * work in this session says so in one short line (*Summarizing <scene>*,\n\t * *<routine> is running*, or a count with the list in its tooltip); a\n\t * failed run and Review always win it, and it stays quiet while a reply\n\t * streams. It informs: no Stop.\n\t * - **Background runs** (`turn-line.runs`): the session's actions,\n * routines and summaries in progress (`dossier.runsInProgress`), one\n * item each — name, status words, elapsed, **Stop** where the viewer may\n * stop it (`stop-run`); *waiting for review* with no Stop when parked;\n * past three, a count button expands the rest in place. A run that ends\n * stays a moment as *‹name› finished*. One polite live region announces\n * arrivals. Never a reply's run, never a line-bound run.\n * - **Right, who is next** (`messages.turn-line-next`): who is typing (the\n\t * page's `session-banners` view), then `NextCharacterBlock` exactly as\n\t * it always drew — or **Stop** while the reply streams, or **Try again**\n\t * (the reply's `retry` verb, the error row's own Retry) after it failed.\n\t * The `nextUp` setting governs this half; `hidden` drops it, and only\n\t * it — who is typing still shows, at the row's end.\n\t *\n\t * In a narrow box the pill is all of the left half: its links live in the\n\t * pill's own panel (`sp-popover`), which the pill opens at every width.\n\t * The notice place (`turn-line.notice`) shows *Time limits off* while the\n\t * dossier's `stepTimeLimitsOff` is set, unless a `notice` snippet fills it.\n\t *\n\t * Reads only the conversation (its rows, its dossier, its events); acts\n\t * only through its verbs and requests.\n\t */\n\timport { untrack, type Snippet } from \"svelte\"\n\timport {\n\t\tRUNS_SHOWN_BEFORE_COUNT,\n\t\trunElapsedWords,\n\t\trunItemWords,\n\t\trunTickMs\n\t} from \"@serene-pub/core-catalog/conversation\"\n\timport { composerSendShown, composerSendShownOf } from \"../composer/target\"\n\timport type { NextUp } from \"../turn-line/settings\"\n\timport NextCharacterBlock from \"./NextCharacterBlock.svelte\"\n\timport StateProposalList from \"./StateProposalList.svelte\"\n\timport { useConversation } from \"./conversation.svelte\"\n\n\tinterface Props {\n\t\t/** The `nextUp` setting: what the right half shows; `hidden`, none of it. */\n\t\tnextUp: NextUp\n\t\t/** 🚧 Fills the notice place; when absent it shows *Time limits off* while the dossier's `stepTimeLimitsOff` is set. */\n\t\tnotice?: Snippet\n\t}\n\n\tlet { nextUp, notice }: Props = $props()\n\n\tconst conv = useConversation()\n\tconst dossier = $derived(conv.dossier)\n\n\ttype Row = {\n\t\tid: number\n\t\tisGenerating?: boolean\n\t\terror?: { message: string; code?: string } | null\n\t\tgenerationOutcome?: string | null\n\t\tgenerationStatus?: unknown\n\t\tcharacterId?: number | null\n\t\tisNarratorResponse?: boolean\n\t\tspeakerLabel?: string | null\n\t\tmetadata?: { isGreeting?: boolean }\n\t}\n\tconst rows = $derived(conv.rows as Row[])\n\t/**\n\t * 🚧 The Composer beside this line draws Send: the host's answer for the\n\t * setting (`dossier.composer.sendShown`, absent reads as shown), and at the\n\t * compact width always, as the Composer reads it (`composerSendShown`).\n\t */\n\tconst sendShown = $derived(composerSendShown(composerSendShownOf(dossier), conv.ctx.layout?.v1?.tier))\n\t/**\n\t * 🚧 The composer under this line already offers Stop (it shows Send and its\n\t * newest row is generating): this line does not offer a second. With Send\n\t * hidden, or no Composer beside, this line always offers the reply's Stop.\n\t */\n\tconst composerStops = $derived(sendShown && !!rows[rows.length - 1]?.isGenerating)\n\t/** A reply some run wrote: a greeting opens the session, no run wrote it. */\n\tconst isReply = (m: Row) =>\n\t\t(!!m.characterId || !!m.isNarratorResponse || !!m.isGenerating) && !m.metadata?.isGreeting\n\n\t/** The newest reply in this log: the run the left half is about. */\n\tconst reply = $derived.by((): Row | null => {\n\t\tfor (let i = rows.length - 1; i >= 0; i--) if (isReply(rows[i])) return rows[i]\n\t\treturn null\n\t})\n\t/** The reply is the log's last line: a retry is still offered on it. */\n\tconst replyIsLast = $derived(!!reply && rows[rows.length - 1]?.id === reply.id)\n\n\ttype TurnState = \"live\" | \"failed\" | \"stopped\" | \"done\"\n\tconst turnState = $derived.by((): TurnState | null => {\n\t\tif (!reply) return null\n\t\tif (reply.isGenerating) return \"live\"\n\t\tif (reply.error) return \"failed\"\n\t\tif (reply.generationOutcome === \"stopped\") return \"stopped\"\n\t\treturn \"done\"\n\t})\n\n\t/**\n\t * The pill while something needs saying here: the last run failed. A reply\n\t * being written says nothing on this line: its own row says *Wren is\n\t * typing* beside the name, and the run's card above the composer names the\n\t * run and leaves the status to the row; a second copy here was noise\n\t * (owner, 2026-11-13). A\n\t * finished or stopped run says nothing either: its reply's ⋮ menu says it.\n\t */\n\tconst status = $derived.by((): string => {\n\t\tif (!reply || !turnState) return \"\"\n\t\tif (turnState === \"failed\") return \"Last run failed\"\n\t\treturn \"\"\n\t})\n\n\t/** The failed run's reason, the pill's title; empty when the run did not fail. */\n\tconst statusReason = $derived(\n\t\treply && turnState === \"failed\" ? (reply.error?.message ?? \"\") : \"\"\n\t)\n\n\tconst waiting = $derived(dossier?.state.waiting ?? [])\n\t/**\n\t * 🚧 What waits ON the viewer, and the viewer's own offers waiting on\n\t * somebody else (PLAN-dc-after-walk3 R1-2, the walk's NEW-4): the giver's\n\t * Review panel showed Accept · Reject on her own offer under \"The AI\n\t * asked for these\". Her offers are listed apart, with Withdraw.\n\t */\n\tconst toDecide = $derived(waiting.filter((p) => !p.offer?.yours))\n\tconst ownOffers = $derived(waiting.filter((p) => !!p.offer?.yours))\n\t/** Who asked for what waits on the viewer: the AI, a player, or both. */\n\tconst decideNote = $derived.by(() => {\n\t\tconst offers = toDecide.filter((p) => !!p.offer).length\n\t\tif (!offers) return \"The AI asked for these. Nothing changes until you accept one.\"\n\t\tif (offers === toDecide.length)\n\t\t\treturn offers === 1 ? \"Offered to you. Nothing changes until you accept it.\" : \"Offered to you. Nothing changes until you accept one.\"\n\t\treturn \"The AI asked for some, a player offered others. Nothing changes until you accept one.\"\n\t})\n\tconst reviewLabel = $derived(\n\t\ttoDecide.length\n\t\t\t? toDecide.length === 1\n\t\t\t\t? \"Review 1 change\"\n\t\t\t\t: `Review ${toDecide.length} changes`\n\t\t\t: ownOffers.length === 1\n\t\t\t\t? \"Your offer is waiting\"\n\t\t\t\t: `Your ${ownOffers.length} offers are waiting`\n\t)\n\tconst hasLinks = $derived(waiting.length > 0)\n\t/** The link beside the pill: Review, only when the pill is not already it. */\n\tconst hasSideLinks = $derived(waiting.length > 0 && !!status)\n\tlet panelOpen = $state(false)\n\t/** The background list's own open state: Review's popover and this one are two popovers, and one opening must not open the other when the line changes hands. */\n\tlet backgroundOpen = $state(false)\n\n\t/**\n\t * Background work for this session: scene summaries under way (the\n\t * owner's scene list is the one kept current) then the routines the host\n\t * names as running.\n\t */\n\tconst backgroundItems = $derived.by((): string[] => {\n\t\tconst items: string[] = []\n\t\tif (dossier?.isOwner)\n\t\t\tfor (const scene of dossier.scenes)\n\t\t\t\tif (scene.summaryStatus === \"running\") items.push(scene.name?.trim() ? `Summarizing ${scene.name.trim()}` : \"Summarizing a scene\")\n\t\tfor (const name of dossier?.runningRoutineNames ?? []) items.push(`${name} is running`)\n\t\treturn items\n\t})\n\t/**\n\t * 🚧 Background runs in progress. Present: this list is the background\n\t * line (the host sent it). Absent (an older host): the scenes' summary\n\t * state and `runningRoutineNames` above are read instead.\n\t */\n\tconst runs = $derived(dossier?.runsInProgress)\n\t/** The left half's text for background work: nothing while a reply, a failure or Review holds it. */\n\tconst backgroundLine = $derived(\n\t\truns || !backgroundItems.length || status || hasLinks || turnState === \"live\"\n\t\t\t? \"\"\n\t\t\t: backgroundItems.length === 1\n\t\t\t\t? backgroundItems[0]\n\t\t\t\t: `${backgroundItems.length} things are running in the background`\n\t)\n\n\t/** 🚧 With Send hidden Continue stays reachable here, even under `hidden`. */\n\tconst nextShown = $derived(nextUp !== \"hidden\" || !sendShown)\n\tconst nextMode = $derived<NextUp>(nextUp === \"hidden\" ? \"head\" : nextUp)\n\tconst showNext = $derived(nextShown && !!dossier && !dossier.readOnly)\n\n\tlet runsOpen = $state(false)\n\tconst runsShown = $derived(runs ? (runsOpen ? runs : runs.slice(0, RUNS_SHOWN_BEFORE_COUNT)) : [])\n\tconst runsMore = $derived(runs ? Math.max(0, runs.length - RUNS_SHOWN_BEFORE_COUNT) : 0)\n\n\t/** Elapsed words tick once a second; once a minute under reduced motion. */\n\tlet now = $state(Date.now())\n\t$effect(() => {\n\t\tif (!runs?.length) return\n\t\tnow = Date.now()\n\t\tconst reduced = typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\t\tconst timer = setInterval(() => (now = Date.now()), runTickMs(reduced))\n\t\treturn () => clearInterval(timer)\n\t})\n\n\t/** How long a finished run stays on the line. */\n\tconst FINISHED_MOMENT_MS = 4000\n\tlet finished = $state<{ id: string; name: string }[]>([])\n\tlet seen = new Map<string, string>()\n\tconst finishTimers = new Set<ReturnType<typeof setTimeout>>()\n\t$effect(() => {\n\t\tconst current = runs\n\t\tuntrack(() => {\n\t\t\tif (!current) {\n\t\t\t\tseen = new Map()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst ids = new Set(current.map((r) => r.id))\n\t\t\tfor (const [id, name] of seen) {\n\t\t\t\tif (ids.has(id)) continue\n\t\t\t\tfinished = [...finished.filter((f) => f.id !== id), { id, name }]\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tfinishTimers.delete(timer)\n\t\t\t\t\tfinished = finished.filter((f) => f.id !== id)\n\t\t\t\t}, FINISHED_MOMENT_MS)\n\t\t\t\tfinishTimers.add(timer)\n\t\t\t}\n\t\t\tfinished = finished.filter((f) => !ids.has(f.id))\n\t\t\tseen = new Map(current.map((r) => [r.id, r.name]))\n\t\t})\n\t})\n\t$effect(() => () => {\n\t\tfor (const t of finishTimers) clearTimeout(t)\n\t})\n</script>\n\n<!-- The turn line's parts (`messages.turn-line*`, STYLE-GUIDE §6.16): no\n look here; the default widget stylesheet draws them. -->\n<div data-widget-part=\"messages.turn-line turn-line.turn-line\" data-turn-state={turnState ?? undefined}>\n\t{#if status || hasLinks || backgroundLine}\n\t\t<div data-widget-part=\"messages.turn-line-run turn-line.run\">\n\t\t\t{#if hasLinks}\n\t\t\t\t<!-- `sp-popover` (§3.5): the pill is the trigger; its panel holds\n\t\t\t\t the links, which is all a narrow box shows of them. -->\n\t\t\t\t<sp-popover\n\t\t\t\t\tplacement=\"top-start\"\n\t\t\t\t\tlabel=\"The last run\"\n\t\t\t\t\topen={panelOpen}\n\t\t\t\t\tonopen-change={(e: CustomEvent<{ open: boolean }>) => (panelOpen = e.detail.open)}\n\t\t\t\t>\n\t\t\t\t\t<button\n\t\t\t\t\t\tslot=\"trigger\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-status turn-line.status\"\n\t\t\t\t\t\tdata-turn-state={turnState ?? undefined}\n\t\t\t\t\t\ttitle={statusReason || reviewLabel}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span data-widget-part=\"messages.turn-line-status-text turn-line.status-text\">{status || reviewLabel}</span>\n\t\t\t\t\t\t<sp-icon name=\"chevron-up\" size=\"12\" data-widget-part=\"messages.turn-line-status-more turn-line.status-more\"></sp-icon>\n\t\t\t\t\t</button>\n\t\t\t\t\t<div data-widget-part=\"messages.turn-line-panel turn-line.panel\">\n\t\t\t\t\t\t{#if toDecide.length}\n\t\t\t\t\t\t\t<header data-widget-part=\"messages.ledger-review-title turn-line.ledger-review-title\">\n\t\t\t\t\t\t\t\t<sp-icon name=\"clipboard-check\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t<span>Waiting for you</span>\n\t\t\t\t\t\t\t</header>\n\t\t\t\t\t\t\t<p data-widget-part=\"messages.ledger-review-note turn-line.ledger-review-note\">{decideNote}</p>\n\t\t\t\t\t\t\t<StateProposalList proposals={toDecide} showAnchor alias=\"turn-line\" />\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{#if ownOffers.length}\n\t\t\t\t\t\t\t<header data-widget-part=\"messages.ledger-review-title turn-line.ledger-review-title\">\n\t\t\t\t\t\t\t\t<sp-icon name=\"hourglass\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t<span>{ownOffers.length === 1 ? \"Your offer\" : \"Your offers\"}</span>\n\t\t\t\t\t\t\t</header>\n\t\t\t\t\t\t\t<p data-widget-part=\"messages.ledger-review-note turn-line.ledger-review-note\">\n\t\t\t\t\t\t\t\tNothing moves until it is accepted. You can take an offer back.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<StateProposalList proposals={ownOffers} alias=\"turn-line\" />\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\t\t\t\t</sp-popover>\n\t\t\t{:else if backgroundLine && backgroundItems.length > 1}\n\t\t\t\t<sp-popover\n\t\t\t\t\tplacement=\"top-start\"\n\t\t\t\t\tlabel=\"Running in the background\"\n\t\t\t\t\topen={backgroundOpen}\n\t\t\t\t\tonopen-change={(e: CustomEvent<{ open: boolean }>) => (backgroundOpen = e.detail.open)}\n\t\t\t\t>\n\t\t\t\t\t<button\n\t\t\t\t\t\tslot=\"trigger\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-status turn-line.status\"\n\t\t\t\t\t\ttitle={backgroundItems.join(\"\\n\")}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span data-widget-part=\"messages.turn-line-status-text turn-line.status-text\">{backgroundLine}</span>\n\t\t\t\t\t\t<sp-icon name=\"chevron-up\" size=\"12\" data-widget-part=\"messages.turn-line-status-more turn-line.status-more\"></sp-icon>\n\t\t\t\t\t</button>\n\t\t\t\t\t<div data-widget-part=\"messages.turn-line-panel turn-line.panel\">\n\t\t\t\t\t\t<ul data-widget-part=\"turn-line.background-list\">\n\t\t\t\t\t\t\t{#each backgroundItems as item, i (i)}\n\t\t\t\t\t\t\t\t<li>{item}</li>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</sp-popover>\n\t\t\t{:else if backgroundLine}\n\t\t\t\t<span data-widget-part=\"messages.turn-line-status turn-line.status\" title={backgroundLine}>\n\t\t\t\t\t<span data-widget-part=\"messages.turn-line-status-text turn-line.status-text\">{backgroundLine}</span>\n\t\t\t\t</span>\n\t\t\t{:else}\n\t\t\t\t<span data-widget-part=\"messages.turn-line-status turn-line.status\" data-turn-state={turnState ?? undefined} title={statusReason || undefined}>\n\t\t\t\t\t<span data-widget-part=\"messages.turn-line-status-text turn-line.status-text\">{status}</span>\n\t\t\t\t</span>\n\t\t\t{/if}\n\t\t\t{#if hasSideLinks}\n\t\t\t\t<!-- The same link, beside the pill where the box has room. Not\n\t\t\t\t when the pill already says it (no status): one Review per\n\t\t\t\t screen, never two side by side. -->\n\t\t\t\t<span data-widget-part=\"messages.turn-line-links turn-line.links\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-review turn-line.review\"\n\t\t\t\t\t\tonclick={() => (panelOpen = true)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"clipboard-check\" size=\"12\"></sp-icon>\n\t\t\t\t\t\t<span>{reviewLabel}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</span>\n\t\t\t{/if}\n\t\t</div>\n\t{/if}\n\t{#if runs}\n\t\t<!-- One polite live region for the list: arrivals are announced here,\n\t\t never per item. Drawn whenever the dossier carries the list, empty when no run is in progress. -->\n\t\t<div data-widget-part=\"turn-line.runs\" aria-live=\"polite\" aria-relevant=\"additions text\">\n\t\t\t{#each runsShown as run (run.id)}\n\t\t\t\t{@const words = runItemWords(run)}\n\t\t\t\t<span data-widget-part=\"turn-line.run-item\" data-run-kind={run.kind} data-parked={run.parked ? \"\" : undefined}>\n\t\t\t\t\t<span data-widget-part=\"turn-line.run-name\">{run.name}</span>\n\t\t\t\t\t{#if words.length}\n\t\t\t\t\t\t<span data-widget-part=\"turn-line.run-status\">{words.join(\" · \")}</span>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if run.since !== undefined}\n\t\t\t\t\t\t<span data-widget-part=\"turn-line.run-since\" aria-hidden=\"true\">{runElapsedWords(run.since, now)}</span>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if run.mayStop && !run.parked}\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tdata-widget-part=\"turn-line.run-stop\"\n\t\t\t\t\t\t\taria-label={`Stop ${run.name}`}\n\t\t\t\t\t\t\tonclick={() => void conv.request(\"stop-run\", { id: run.id })}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"square\" size=\"12\"></sp-icon>\n\t\t\t\t\t\t\t<span>Stop</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t{/if}\n\t\t\t\t</span>\n\t\t\t{/each}\n\t\t\t{#if runsMore > 0}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"turn-line.runs-more\"\n\t\t\t\t\taria-expanded={runsOpen}\n\t\t\t\t\tonclick={() => (runsOpen = !runsOpen)}\n\t\t\t\t>\n\t\t\t\t\t{runsOpen ? \"Show fewer\" : `${runsMore} more`}\n\t\t\t\t</button>\n\t\t\t{/if}\n\t\t\t{#each finished as done (done.id)}\n\t\t\t\t<span data-widget-part=\"turn-line.run-item\" data-finished=\"\">\n\t\t\t\t\t<span data-widget-part=\"turn-line.run-name\">{done.name}</span>\n\t\t\t\t\t<span data-widget-part=\"turn-line.run-status\">finished</span>\n\t\t\t\t</span>\n\t\t\t{/each}\n\t\t</div>\n\t{/if}\n\t{#if notice}\n\t\t<div data-widget-part=\"turn-line.notice\">{@render notice()}</div>\n\t{:else if dossier?.stepTimeLimitsOff === true}\n\t\t<div data-widget-part=\"turn-line.notice\">\n\t\t\t<span\n\t\t\t\tdata-widget-part=\"turn-line.limits-off\"\n\t\t\t\ttitle=\"Step time limits are off in Admin › Diagnostics. A stuck step waits until someone stops it.\"\n\t\t\t\t>Time limits off</span\n\t\t\t>\n\t\t</div>\n\t{/if}\n\t{#if showNext && dossier}\n\t\t<div data-widget-part=\"messages.turn-line-next turn-line.next messages.next-up turn-line.next-up\">\n\t\t\t<!-- Who else is writing (the page's view): a pill, when someone is. -->\n\t\t\t<span data-widget-part=\"messages.turn-line-typing turn-line.typing\"><sp-host-view name=\"session-banners\"></sp-host-view></span>\n\t\t\t{#if turnState === \"live\"}\n\t\t\t\t<!-- 🚧 Live with the composer's own Stop right under it: nothing here. -->\n\t\t\t\t{#if !composerStops}\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-stop turn-line.stop\"\n\t\t\t\t\t\ttitle=\"Stop\"\n\t\t\t\t\t\taria-label=\"Stop generating\"\n\t\t\t\t\t\tonclick={() => conv.invoke(\"stop\")}\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"square\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t<span>Stop</span>\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t{:else if turnState === \"failed\" && replyIsLast && reply}\n\t\t\t\t<!-- Absent unless the viewer may rerun this line (`rerunnable`); a line with no verdict keeps it. -->\n\t\t\t\t{#if conv.line(reply.id).rerunnable !== false}\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"messages.turn-line-retry turn-line.retry\"\n\t\t\t\t\t\ttitle=\"Write this reply again\"\n\t\t\t\t\t\tonclick={() => conv.invoke(\"retry\", reply)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"refresh-cw\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t<span>Try again</span>\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t{:else}\n\t\t\t\t<NextCharacterBlock\n\t\t\t\t\torder={dossier.turn.order}\n\t\t\t\t\tcandidates={dossier.turn.candidates}\n\t\t\t\t\tmode={nextMode}\n\t\t\t\t\tshouldShow={dossier.turn.show && conv.edit.id === null}\n\t\t\t\t\tavatarFor={(ref) =>\n\t\t\t\t\t\t// 🚧 `seated-member:` resolves to a face as `character:` does. Not `player-seat:`: the page's\n\t\t\t\t\t\t// `sp-avatar` lookup has no face for it, and a ref returned here draws the blank avatar\n\t\t\t\t\t\t// where a card-less seat draws nothing today.\n\t\t\t\t\t\tref.startsWith(\"character:\") || ref.startsWith(\"seated-member:\") ? ref : undefined}\n\t\t\t\t\tcanChooseSomeoneElse={dossier.turn.canChoose}\n\t\t\t\t\tviewerUserId={conv.ctx.viewer.v1.userId}\n\t\t\t\t\twaitingFor={dossier.turn.waitingFor ?? []}\n\t\t\t\t\tviewerIsOwner={!!dossier.isOwner}\n\t\t\t\t\tstandstill={dossier.turn.standstill}\n\t\t\t\t\tonContinue={(channel) => void conv.request(\"fire-turn\", { channel })}\n\t\t\t\t\tonSomeoneElse={() => void conv.request(\"pick-turn\", {})}\n\t\t\t\t/>\n\t\t\t{/if}\n\t\t</div>\n\t{:else}\n\t\t<span data-widget-part=\"messages.turn-line-typing turn-line.typing\"><sp-host-view name=\"session-banners\"></sp-host-view></span>\n\t{/if}\n</div>\n","shared/messages/conversation.svelte.ts":"/**\n * The conversation widget's own model (C0b): what its parts read, derived\n * from the widget context alone, and what they do, through its verbs alone.\n *\n * `MessagesWidget` creates one and provides it (so do the Composer and Turn\n * line, each its own: they share no state, only the host's dossier); the log,\n * each message, its controls and the composer read it (`useConversation`) instead of taking the\n * page's callbacks as props. So the widget's state — which line is being\n * edited, whose menu is open, what is selected for a summary — is the\n * widget's, and every effect is an `invoke` (core's verbs, a contributed\n * action) or a `request` (something the host opens). Nothing here imports a\n * store, the socket or the page: the same source runs in a UI worker.\n */\nimport { getContext, setContext, tick, untrack } from \"svelte\"\nimport { SvelteMap, SvelteSet } from \"svelte/reactivity\"\nimport { useWidgetContext } from \"../context\"\nimport type { WidgetContextRef } from \"@serene-pub/core-catalog/conversation\"\nimport {\n\tNO_LINE,\n\ttype ConversationDossierV1,\n\ttype ConversationLineV1\n} from \"@serene-pub/core-catalog/conversation\"\nimport type { WidgetRequestKind, WidgetRequests } from \"@serene-pub/sdk/component\"\nimport { canAnswerForm } from \"@serene-pub/core-catalog/conversation\"\nimport {\n\tcanonicalListedChannel,\n\tisNoLaneChannel,\n\trowOnListedChannels\n} from \"@serene-pub/core-catalog/conversation\"\nimport { setStatusTextResolver, statusTextIn } from \"@serene-pub/core-catalog/conversation\"\nimport type { RequestDeclineCode, StatusText } from \"@serene-pub/sdk/component\"\nimport { composerTargetOf } from \"../composer/target\"\nimport { boundaryOffer, laneOf, markedRun, type BoundaryOffer, type SceneMarkRow } from \"./sceneMarks\"\nimport { anyGenerating, indexRowsById, rowWithId, scenedSetOf } from \"./rowFacts\"\nimport { interleaveByAnchor, interleaveMode, interleaveSlug, isInterleavedRow, rowKindOf, rowKindsOf, rowsByKind } from \"./interleave\"\n\n/** A seat's participant reference, as the conversation cast carries it. */\ntype SeatRef = NonNullable<ConversationDossierV1[\"cast\"][\"sessionPersonas\"][number][\"ref\"]>\n\nconst KEY = Symbol(\"sp-conversation\")\n\nexport type Conversation = ReturnType<typeof createConversation>\n\n/** What a verb's subject is: a message, by id. */\ntype Subject = { id: number }\n\n/**\n * 🚧 Where a scene write was asked, so its refusal is said there: under a\n * line, in a scene's divider, in the selection bar, or in a scene cue's chip\n * (lane E).\n */\ntype SceneAsk = \"line\" | \"scene\" | \"selection\" | \"cue\"\n\n/**\n * A request declined because the view went away — the page's decline of what\n * it never answered, or the wire's own at `close()`. Expected at every\n * unmount with a request in flight (the composer's `draft` is nearly always\n * one), so it is not a failure worth a line on stderr. Read by its\n * `code` (`unmounted`, a {@link RequestDeclineCode}); an older host declines\n * with its sentence alone (\"the page was unmounted before it answered\"), so\n * the text is the fallback.\n */\nexport function isUnmountDecline(e: unknown): boolean {\n\tconst code: unknown = typeof e === \"object\" && e !== null ? (e as { code?: unknown }).code : undefined\n\tif (code !== undefined) return code === (\"unmounted\" satisfies RequestDeclineCode)\n\tconst message = e instanceof Error ? e.message : String(e)\n\treturn /\\bunmounted\\b/.test(message)\n}\n\n/** What differs between the Messages copy and the widgets beside it (owner R8 2026-11-05). */\nexport interface ConversationOptions {\n\t/**\n\t * Composer and Turn line only: the lane is the one the target Messages copy\n\t * shows (`dossier.composer.target.channel`), not a choice of this mount's\n\t * own, and `lane.set` does nothing. Without a target, or without this\n\t * option, the lane is the first writable channel as ever.\n\t */\n\tfollowTarget?: boolean\n\t/**\n\t * 🚧 Dialogue box only (PLAN-visual-novel-layout §6 answer 1): no selection\n\t * for a summary — `select.start` does nothing and a row's menu leaves out\n\t * *Select for summary* — since the selection bar, the only way out of a\n\t * selection, is MessagesWidget's (2026-11-05 D7).\n\t */\n\tnoSelection?: boolean\n}\n\nexport function createConversation(widget: WidgetContextRef, options: ConversationOptions = {}) {\n\tconst followTarget = !!options.followTarget\n\tconst noSelection = !!options.noSelection\n\tconst ctx = () => widget.current\n\tconst warn = (what: string) => (e: unknown) => {\n\t\tif (isUnmountDecline(e)) return\n\t\tconsole.warn(`conversation: ${what} — ${e instanceof Error ? e.message : String(e)}`)\n\t}\n\n\tlet editingId = $state<number | null>(null)\n\t/**\n\t * 🚧 The last scene boundary the host refused, said where it was asked:\n\t * under a line (*Start scene here*, *End scene here*), in a scene's\n\t * divider, or in the selection bar (*Mark as scene*). One at a time.\n\t */\n\tlet sceneRefusal = $state<{ at: SceneAsk; id: number; text: string } | null>(null)\n\t/** A scene boundary is being written: its presses wait. */\n\tlet sceneBusy = $state(false)\n\tlet menuFor = $state<number | undefined>(undefined)\n\t/**\n\t * 🚧 Heading audio control (2026-10-29): the ONE line audible in this\n\t * widget, and which of its players holds it. Starting any line's audio\n\t * stops the previous one (pause + rewind). `takes` re-keys a player so a\n\t * stopped one starts over from the top; plain records, not a Map.\n\t */\n\tlet speechNow = $state<{ id: number; player: \"line\" | \"menu\" } | null>(null)\n\tlet speechTakes = $state<Record<string, number>>({})\n\t/** The menu player's last playhead for a line (caption + state glyph read it). */\n\tlet speechMenuAt = $state<{ id: number; at: { currentTime: number; duration: number; paused: boolean } } | null>(null)\n\tconst bumpTake = (id: number, player: \"line\" | \"menu\") => {\n\t\tconst k = `${id}:${player}`\n\t\tspeechTakes = { ...speechTakes, [k]: (speechTakes[k] ?? 0) + 1 }\n\t}\n\tlet selecting = $state(false)\n\t/** The lane the composer writes to, and the log shows (`main` by default). */\n\tlet lane = $state(\"main\")\n\tconst selected = new SvelteSet<number>()\n\n\t// Status sentences in this widget's language (`text.ts`).\n\tsetStatusTextResolver(\n\t\t() => ctx().locale.v1,\n\t\t(source) => ctx().t(source)\n\t)\n\n\t// Through the context's own type — its scoped keys come from the SDK's\n\t// one table — so a renamed section fails to compile here.\n\tconst dossier = $derived((ctx().scope(\"session:full\") ?? null) as ConversationDossierV1 | null)\n\n\t/**\n\t * 🚧 The channel this copy draws inline (`interleave`, PLAN-rulesets §30):\n\t * its rows sit straight after the line each is anchored to\n\t * (`metadata.anchorMessageId`), faceless. `''`: none.\n\t */\n\tconst interleave = $derived(\n\t\tinterleaveSlug((ctx().settings?.v1 as { interleave?: unknown } | undefined)?.interleave)\n\t)\n\t/** 🚧 How an interleaved row reads (`interleaveAs`, §16): a fold, closed by default, or open. */\n\tconst interleaveAs = $derived(\n\t\tinterleaveMode((ctx().settings?.v1 as { interleaveAs?: unknown } | undefined)?.interleaveAs)\n\t)\n\t/** 🚧 Which kinds of a folio's lines this copy draws (`rowKinds`, §16); none is every line. */\n\tconst rowKinds = $derived(rowKindsOf((ctx().settings?.v1 as { rowKinds?: unknown } | undefined)?.rowKinds))\n\t/**\n\t * The channels this copy shows (lair re-plan S1): its composer's, which\n\t * the host narrows per mount — a copy pinned to the Sanctum is told\n\t * `['sanctum']`, the primary log the channels no pinned copy claims.\n\t * `null` (no dossier yet, or an empty list) is every channel.\n\t */\n\tconst channels = $derived.by((): string[] | null => {\n\t\tconst listed = dossier?.composer?.channels\n\t\tif (!listed || !listed.length) return null\n\t\t// 🚧 The interleaved channel is drawn under its anchors, never a\n\t\t// lane of this copy's own: its composer never writes there and its\n\t\t// strip never offers it — unless it is all the copy shows.\n\t\tconst own = interleave ? listed.filter((c) => c !== interleave) : listed\n\t\treturn own.length ? own : listed\n\t})\n\t/**\n\t * 🚧 The viewer is in no lane of the channel this copy claims (its\n\t * `channelLaneFrom` found none): the copy shows nothing and writes\n\t * nowhere. A display claim — who may read a lane is the genre's to keep.\n\t */\n\tconst noLane = $derived(!!channels && channels.every(isNoLaneChannel))\n\t/**\n\t * The rows this log holds: the host's log narrowed to this copy's\n\t * channels — a bare slug holds every lane of its channel, a listed lane\n\t * (`parley:2`) that lane alone (`rowOnListedChannels`). A row on a channel\n\t * another copy claims is not drawn here at all (never merely hidden), so\n\t * two copies never hold the same line.\n\t */\n\tconst rows = $derived.by(() => {\n\t\tconst all = ctx().messages.v1\n\t\tconst listed = channels\n\t\tconst mine = listed\n\t\t\t? all.filter(\n\t\t\t\t\t(m) =>\n\t\t\t\t\t\trowOnListedChannels(listed, (m as { channel?: unknown }).channel) ||\n\t\t\t\t\t\tisInterleavedRow(m as { id: number; channel?: unknown }, interleave)\n\t\t\t\t)\n\t\t\t: all\n\t\tconst anchored = interleave ? interleaveByAnchor(mine, interleave) : mine\n\t\t// 🚧 A journal's kinds (§16): the named ones, a round under its `did` line.\n\t\treturn rowsByKind(anchored as Array<(typeof anchored)[number] & { metadata?: unknown }>, rowKinds)\n\t})\n\n\t/**\n\t * Facts the rows read off the whole list, once per list change: whether\n\t * any row is being written, each row by id (the first on a duplicate), the\n\t * lines a scene has captured, and the count. A row reads these O(1) instead\n\t * of scanning the list on every streamed token.\n\t */\n\tconst generatingNow = $derived(anyGenerating(ctx().messages.v1))\n\tconst rowIndex = $derived(indexRowsById(ctx().messages.v1))\n\tconst scenedSet = $derived(scenedSetOf(dossier?.scened))\n\tconst messageTotal = $derived(ctx().messages.v1.length)\n\n\t// The host's summary finished: the selection it was handed ends.\n\tlet summaryEnded: number | null = null\n\t$effect(() => {\n\t\tconst n = dossier?.summaryEnded ?? 0\n\t\tif (summaryEnded !== null && n !== summaryEnded) {\n\t\t\tselecting = false\n\t\t\tselected.clear()\n\t\t}\n\t\tsummaryEnded = n\n\t})\n\n\t/**\n\t * How long each run took, as this view saw it: `generation:start` to\n\t * `generation:end`, per reply. A run that finished before the page opened\n\t * has none, and a stopped run keeps none. Read by the newest reply's ⋮\n\t * menu (`MessageControls`), which says *Replied · 6.2 s* — the turn line's\n\t * pill said it at rest until polish parity L1 (2026-10-24).\n\t */\n\tconst runStartedAt = new Map<number, number>()\n\tconst runTook = new SvelteMap<number, number>()\n\t$effect(() =>\n\t\tuntrack(() => {\n\t\t\tconst offStart = ctx().on(\"generation:start\", (e) => {\n\t\t\t\tif (e.kind === \"generation:start\" && e.messageId != null) runStartedAt.set(e.messageId, Date.now())\n\t\t\t})\n\t\t\tconst offEnd = ctx().on(\"generation:end\", (e) => {\n\t\t\t\tif (e.kind !== \"generation:end\" || e.messageId == null) return\n\t\t\t\tconst t0 = runStartedAt.get(e.messageId)\n\t\t\t\trunStartedAt.delete(e.messageId)\n\t\t\t\tif (t0 === undefined || e.aborted) runTook.delete(e.messageId)\n\t\t\t\telse runTook.set(e.messageId, (Date.now() - t0) / 1000)\n\t\t\t})\n\t\t\treturn () => {\n\t\t\t\toffStart()\n\t\t\t\toffEnd()\n\t\t\t}\n\t\t})\n\t)\n\n\t/** `text`: what the press supplies — the composer's slash argument (S2). */\n\tfunction invoke(key: string, subject?: Subject, payload?: Record<string, unknown>, text?: string) {\n\t\ttry {\n\t\t\tctx().invoke(key, { messageId: subject?.id, payload, ...(text !== undefined ? { text } : {}) })\n\t\t} catch (e) {\n\t\t\twarn(key)(e)\n\t\t}\n\t}\n\n\tfunction request<K extends WidgetRequestKind>(kind: K, params: WidgetRequests[K][\"params\"]) {\n\t\treturn ctx().request(kind, params).catch(warn(kind))\n\t}\n\n\t/**\n\t * 🚧 One scene write (`scene-*`, a scene's `summarize`): its refusal is\n\t * said where it was asked (`sceneRefusal`), never dropped on stderr —\n\t * a view going away is no refusal. Resolves with the answer, or null.\n\t */\n\tasync function sceneWrite<K extends WidgetRequestKind>(\n\t\twhere: { at: SceneAsk; id: number },\n\t\tkind: K,\n\t\tparams: WidgetRequests[K][\"params\"]\n\t): Promise<WidgetRequests[K][\"result\"] | null> {\n\t\tsceneRefusal = null\n\t\ttry {\n\t\t\treturn await ctx().request(kind, params)\n\t\t} catch (e) {\n\t\t\tif (!isUnmountDecline(e))\n\t\t\t\tsceneRefusal = { ...where, text: e instanceof Error ? e.message : String(e) }\n\t\t\treturn null\n\t\t}\n\t}\n\n\treturn {\n\t\tget ctx() {\n\t\t\treturn ctx()\n\t\t},\n\t\tget dossier() {\n\t\t\treturn dossier\n\t\t},\n\t\t/** The page's word on one line; nothing when it has none. */\n\t\tline(id: number): ConversationLineV1 {\n\t\t\treturn dossier?.lines[id] ?? NO_LINE\n\t\t},\n\t\tt: (source: string) => ctx().t(source),\n\t\t/** How long the run that wrote this reply took, in seconds, as this view saw it; undefined when it did not see it. */\n\t\trunTook: (messageId: number): number | undefined => runTook.get(messageId),\n\t\t/** A status sentence in the viewer's language. */\n\t\tstatusText: (status: StatusText | null | undefined) =>\n\t\t\tstatusTextIn(status, ctx().locale.v1, (source) => ctx().t(source)),\n\n\t\t/** May the viewer answer a form put to `addressee`? */\n\t\tcanAnswer(addressee: string | undefined) {\n\t\t\tconst f = dossier\n\t\t\treturn canAnswerForm(\n\t\t\t\taddressee,\n\t\t\t\t{ userId: ctx().viewer.v1.userId, isOwner: !!f?.isOwner, isAdmin: ctx().viewer.v1.isAdmin },\n\t\t\t\tf?.cast\n\t\t\t)\n\t\t},\n\n\t\t/**\n\t\t * 🚧 The cast lookup: a cast member id → that seat's `ref`, off the\n\t\t * conversation cast row (either list) whose `castMemberId` matches; null on\n\t\t * a miss or a host that fills none (⏳ the card form is then read). The\n\t\t * optional `seatKind` prefers a seat of that kind (`'character-seat'` looks\n\t\t * in the character seats first; `'player-seat'` or none, the player seats\n\t\t * first) and falls back to the other, so it changes identity only.\n\t\t */\n\t\trefOfMember(castMemberId: number, seatKind?: \"character-seat\" | \"player-seat\"): SeatRef | null {\n\t\t\tconst cast = dossier?.cast\n\t\t\tconst players = cast?.sessionPersonas ?? []\n\t\t\tconst characters = cast?.sessionCharacters ?? []\n\t\t\tfor (const row of seatKind === \"character-seat\" ? [...characters, ...players] : [...players, ...characters])\n\t\t\t\tif (row?.castMemberId === castMemberId && row.ref) return row.ref\n\t\t\treturn null\n\t\t},\n\n\t\t// ── verbs ────────────────────────────────────────────────────────────\n\t\tinvoke,\n\t\t/** A reply swiped: to the newer alternative (right) or the older (left). */\n\t\tswipe(subject: Subject, direction: \"left\" | \"right\") {\n\t\t\tinvoke(\"swipe\", subject, { direction })\n\t\t},\n\t\trequest,\n\n\t\t// ── 🚧 Back · Forward (RF fix 5): the session's forward stack ───────\n\t\trewind: {\n\t\t\t/** The host's word (`SessionDossierV1.rewind`); null from a host that sends none. */\n\t\t\tget state() {\n\t\t\t\treturn dossier?.rewind ?? null\n\t\t\t},\n\t\t\t/** Back: the newest turn out of the history. The host refuses in words. */\n\t\t\tback() {\n\t\t\t\tvoid request(\"rewind-turn\", {})\n\t\t\t},\n\t\t\t/** Forward: the newest rewound turn back into it. */\n\t\t\tforward() {\n\t\t\t\tvoid request(\"forward-turn\", {})\n\t\t\t}\n\t\t},\n\n\t\t/** 🚧 The session's settle line (`SessionDossierV1.settledThrough`): the newest settled message id; null when none or from a host that sends none. */\n\t\tget settledThrough(): number | null {\n\t\t\treturn typeof dossier?.settledThrough === 'number' ? dossier.settledThrough : null\n\t\t},\n\n\t\t// ── editing: the widget's own state; saving is the `edit` verb ───────\n\t\tedit: {\n\t\t\tget id() {\n\t\t\t\treturn editingId\n\t\t\t},\n\t\t\tstart(subject: Subject) {\n\t\t\t\teditingId = subject.id\n\t\t\t\tmenuFor = undefined\n\t\t\t},\n\t\t\tcancel() {\n\t\t\t\teditingId = null\n\t\t\t},\n\t\t\tsave(subject: Subject, content: string) {\n\t\t\t\tinvoke(\"edit\", subject, { content })\n\t\t\t\teditingId = null\n\t\t\t}\n\t\t},\n\n\t\t/** The rows this copy's log holds — its channels' (S1), in the host's order. */\n\t\tget rows() {\n\t\t\treturn rows\n\t\t},\n\t\t/** Whether any line of the host's log is being written. */\n\t\tget anyGenerating() {\n\t\t\treturn generatingNow\n\t\t},\n\t\t/** A line of the host's log by id; the first on a duplicate id, as `find` answers. */\n\t\trowById(id: unknown) {\n\t\t\treturn rowWithId(rowIndex, id)\n\t\t},\n\t\t/** Whether a scene has already captured this line. */\n\t\tisScened(id: number): boolean {\n\t\t\treturn scenedSet.has(id)\n\t\t},\n\t\t/** How many lines the host's log holds. */\n\t\tget messageCount() {\n\t\t\treturn messageTotal\n\t\t},\n\t\t/** The channels this copy shows, or `null` for every channel. */\n\t\tget channels() {\n\t\t\treturn channels\n\t\t},\n\t\t/**\n\t\t * 🚧 Older lines remain for THIS copy (owner ruling ★7): one of its\n\t\t * channels — or the channel it interleaves — is among the dossier's\n\t\t * `olderIn`; a host that predates it answers with `hasOlder`.\n\t\t */\n\t\tget hasOlder(): boolean {\n\t\t\tconst olderIn = dossier?.olderIn\n\t\t\tif (!Array.isArray(olderIn)) return !!dossier?.hasOlder\n\t\t\tif (!channels) return olderIn.length > 0\n\t\t\tconst mine = interleave ? [...channels, interleave] : channels\n\t\t\treturn olderIn.some((c) => rowOnListedChannels(mine, c))\n\t\t},\n\t\t/** 🚧 Ask for the next older page of this copy's own channels (`load-older`, ★7). */\n\t\tloadOlder(): void {\n\t\t\tconst mine = channels ? (interleave ? [...channels, interleave] : [...channels]) : null\n\t\t\tvoid request(\"load-older\", mine ? { channels: mine } : {})\n\t\t},\n\t\t/** 🚧 The channel this copy draws inline under its anchors, or `''`. */\n\t\tget interleave() {\n\t\t\treturn interleave\n\t\t},\n\t\t/** 🚧 Whether `row` is drawn inline from the interleaved channel. */\n\t\tisInterleaved(row: { id: number; channel?: unknown }): boolean {\n\t\t\treturn isInterleavedRow(row, interleave)\n\t\t},\n\t\t/** 🚧 How an interleaved row reads: `fold` (the default) or `open`. */\n\t\tget interleaveAs() {\n\t\t\treturn interleaveAs\n\t\t},\n\t\t/** 🚧 A row's kind (`metadata.kind`), or `null` — a journal's `did`, `found`, `met`… */\n\t\trowKind(row: { metadata?: unknown }): string | null {\n\t\t\treturn rowKindOf(row)\n\t\t},\n\t\t/** 🚧 The viewer is in no lane of this copy's claimed channel: nothing to show or write. */\n\t\tget noLane() {\n\t\t\treturn noLane\n\t\t},\n\t\t/**\n\t\t * What a channel is CALLED: its declared label in the viewer's language\n\t\t * (`ChannelDecl.label`, the Lair's _Sanctum_), else its slug, title-cased\n\t\t * (`manuscript` reads _Manuscript_).\n\t\t */\n\t\tchannelName(slug: string): string {\n\t\t\tconst label = dossier?.composer?.channelLabels?.[slug]\n\t\t\tif (label) return label\n\t\t\treturn slug\n\t\t\t\t.split(/[-_]/)\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n\t\t\t\t.join(\" \")\n\t\t},\n\t\t/**\n\t\t * What a channel IS (`ChannelDecl.role`, PLAN-core-widgets §3.7):\n\t\t * `folio` for a manuscript-style channel, else `conversation` — the\n\t\t * default every channel has, and the answer while the host says\n\t\t * nothing (`composer.channelRoles` absent).\n\t\t */\n\t\tchannelRole(slug: string): \"conversation\" | \"folio\" {\n\t\t\treturn dossier?.composer?.channelRoles?.[slug] === \"folio\"\n\t\t\t\t? \"folio\"\n\t\t\t\t: \"conversation\"\n\t\t},\n\n\t\t/**\n\t\t * The lane the composer writes to; the log shows that lane's rows. It is\n\t\t * always one of this copy's channels: a copy told one channel writes on\n\t\t * it whatever was chosen before (S1).\n\t\t */\n\t\tlane: {\n\t\t\tget current() {\n\t\t\t\tconst followed = followTarget ? composerTargetOf(dossier).target : null\n\t\t\t\tif (followed) return canonicalListedChannel(followed.channel)\n\t\t\t\tif (!channels) return lane\n\t\t\t\t// A listed lane is written and compared in its canonical form\n\t\t\t\t// (`parley:1` is the row stored `parley`); the no-lane marker is\n\t\t\t\t// never a lane to write on while a real channel is listed.\n\t\t\t\tconst writable = channels.filter((c) => !isNoLaneChannel(c))\n\t\t\t\tif (!writable.length) return channels[0]!\n\t\t\t\tconst pick = writable.includes(lane) ? lane : writable[0]!\n\t\t\t\treturn canonicalListedChannel(pick)\n\t\t\t},\n\t\t\tset(next: string) {\n\t\t\t\tif (followTarget) return\n\t\t\t\tlane = next || \"main\"\n\t\t\t}\n\t\t},\n\n\t\t/** Whose ⋮ menu is open — one at a time across the log. */\n\t\tmenu: {\n\t\t\tget open() {\n\t\t\t\treturn menuFor\n\t\t\t},\n\t\t\tset(id: number | undefined) {\n\t\t\t\tmenuFor = id\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * 🚧 Heading audio control: which line's audio is playing (one at a\n\t\t * time) and through which player. `take(id, player)` is the rewind\n\t\t * counter a player is keyed by.\n\t\t */\n\t\tspeech: {\n\t\t\tget playing() {\n\t\t\t\treturn speechNow\n\t\t\t},\n\t\t\tisPlaying(id: number, player: \"line\" | \"menu\") {\n\t\t\t\treturn speechNow?.id === id && speechNow.player === player\n\t\t\t},\n\t\t\t/** The ⋮ player's playhead for this line while it is the current player; else null. */\n\t\t\tmenuAt(id: number) {\n\t\t\t\treturn speechMenuAt?.id === id && speechNow?.id === id && speechNow.player === \"menu\"\n\t\t\t\t\t? speechMenuAt.at\n\t\t\t\t\t: null\n\t\t\t},\n\t\t\treportMenuAt(id: number, at: { currentTime: number; duration: number; paused: boolean } | null) {\n\t\t\t\tif (at) speechMenuAt = { id, at }\n\t\t\t},\n\t\t\ttake(id: number, player: \"line\" | \"menu\" = \"line\"): number {\n\t\t\t\treturn speechTakes[`${id}:${player}`] ?? 0\n\t\t\t},\n\t\t\t/**\n\t\t\t * Make this line's player the playing one. Another line is stopped\n\t\t\t * first (its `playing` off, its player re-keyed = pause + rewind),\n\t\t\t * a tick ahead of the new one flipping on; the same line's other\n\t\t\t * player is only paused.\n\t\t\t */\n\t\t\tasync play(id: number, player: \"line\" | \"menu\" = \"line\") {\n\t\t\t\tconst prev = speechNow\n\t\t\t\tif (prev && !(prev.id === id && prev.player === player)) {\n\t\t\t\t\tif (prev.id !== id) bumpTake(prev.id, prev.player)\n\t\t\t\t\tspeechNow = null\n\t\t\t\t\tawait tick()\n\t\t\t\t}\n\t\t\t\tspeechNow = { id, player }\n\t\t\t},\n\t\t\t/** Pause and rewind: nothing playing, that player starts over. */\n\t\t\tstop(id: number) {\n\t\t\t\tif (speechNow?.id === id) {\n\t\t\t\t\tbumpTake(id, speechNow.player)\n\t\t\t\t\tspeechNow = null\n\t\t\t\t}\n\t\t\t},\n\t\t\t/**\n\t\t\t * A player's own play / pause / ended. A play makes it the current\n\t\t\t * one (stopping any other line); a pause or end of the current one\n\t\t\t * clears it. A pause from a player that is not current is old news.\n\t\t\t */\n\t\t\theard(id: number, player: \"line\" | \"menu\", paused: boolean) {\n\t\t\t\tconst cur = speechNow\n\t\t\t\tconst mine = cur?.id === id && cur.player === player\n\t\t\t\tif (paused) {\n\t\t\t\t\tif (mine) speechNow = null\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (mine) return\n\t\t\t\tif (cur && cur.id !== id) bumpTake(cur.id, cur.player)\n\t\t\t\tspeechNow = { id, player }\n\t\t\t}\n\t\t},\n\n\t\t// ── 🚧 live scenes: the boundaries a person places (§7, §14 C) ─────\n\t\tscenes: {\n\t\t\t/** The viewer may place scene boundaries here (the dossier's verdict). */\n\t\t\tget boundaries() {\n\t\t\t\treturn !!dossier?.sceneBoundaries\n\t\t\t},\n\t\t\t/** The last refusal, and where it is said. */\n\t\t\tget refusal() {\n\t\t\t\treturn sceneRefusal\n\t\t\t},\n\t\t\tdismiss() {\n\t\t\t\tsceneRefusal = null\n\t\t\t},\n\t\t\t/** A boundary write is in flight. */\n\t\t\tget busy() {\n\t\t\t\treturn sceneBusy\n\t\t\t},\n\t\t\t/**\n\t\t\t * 🚧 A scene's summary may be asked for here — not when the\n\t\t\t * session's summaries are off (`sceneSummaryMode: 'never'`).\n\t\t\t */\n\t\t\tget summarizes() {\n\t\t\t\treturn dossier?.sceneSummaryMode !== \"never\"\n\t\t\t},\n\t\t\t/**\n\t\t\t * 🚧 The scene cues waiting at lines — Suggested mode's *New\n\t\t\t * scene?* chips (lane E) — only where the viewer may place a\n\t\t\t * boundary.\n\t\t\t */\n\t\t\tget cues() {\n\t\t\t\treturn dossier?.sceneBoundaries ? (dossier.sceneCues ?? []) : []\n\t\t\t},\n\t\t\t/** Which boundaries this line's menu offers (none without the verdict). */\n\t\t\toffer(row: SceneMarkRow): BoundaryOffer {\n\t\t\t\tif (!dossier?.sceneBoundaries) return { start: false, end: null }\n\t\t\t\treturn boundaryOffer(row, dossier.scenes ?? [])\n\t\t\t},\n\t\t\t/** *Start scene here*: a scene opens at this line, on its lane. */\n\t\t\tasync startAt(row: SceneMarkRow) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite({ at: \"line\", id: row.id }, \"scene-open\", {\n\t\t\t\t\t\tmessageId: row.id,\n\t\t\t\t\t\tchannel: laneOf(row.channel)\n\t\t\t\t\t})\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** *End scene here* (a line), or *End scene* (its divider: at the lane's newest line). */\n\t\t\tasync endAt(sceneId: number, row?: SceneMarkRow) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite(\n\t\t\t\t\t\trow ? { at: \"line\", id: row.id } : { at: \"scene\", id: sceneId },\n\t\t\t\t\t\t\"scene-close\",\n\t\t\t\t\t\trow ? { sceneId, messageId: row.id } : { sceneId }\n\t\t\t\t\t)\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/**\n\t\t\t * 🚧 Move where a live scene starts — a divider dragged between\n\t\t\t * lines, or its menu's *Move start up/down one line* (lane E).\n\t\t\t */\n\t\t\tasync moveStart(sceneId: number, openedAt: number) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite({ at: \"scene\", id: sceneId }, \"scene-move\", { sceneId, openedAt })\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** 🚧 *Reopen scene*: a closed scene runs on to its lane's newest line again (lane E). */\n\t\t\tasync reopen(sceneId: number) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite({ at: \"scene\", id: sceneId }, \"scene-move\", { sceneId, closedAt: null })\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** 🚧 A scene cue's **Yes** (a scene opens at its line) or **Not here** (lane E). */\n\t\t\tasync decideCue(cueId: number, accept: boolean) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite({ at: \"cue\", id: cueId }, \"decide-scene-cue\", { cueId, accept })\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** A divider's name, renamed; whether the host took it. */\n\t\t\tasync rename(sceneId: number, name: string | null) {\n\t\t\t\tconst done = await sceneWrite({ at: \"scene\", id: sceneId }, \"scene-rename\", { sceneId, name })\n\t\t\t\treturn done !== null\n\t\t\t},\n\t\t\t/** *Remove boundary*: the host asks the person, then removes the scene. */\n\t\t\tasync remove(sceneId: number) {\n\t\t\t\tif (sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tawait sceneWrite({ at: \"scene\", id: sceneId }, \"scene-remove\", { sceneId })\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** *Summarize* a scene in the host's review. */\n\t\t\tsummarize(sceneId: number) {\n\t\t\t\tvoid sceneWrite({ at: \"scene\", id: sceneId }, \"summarize\", { kind: \"scene\", sceneId })\n\t\t\t},\n\t\t\t/**\n\t\t\t * *Mark as scene* (the selection bar's boundary path): the picked run\n\t\t\t * becomes one closed live scene — opened at its first line and\n\t\t\t * closed at its last on that lane, in ONE write (`closeAt`, lane E),\n\t\t\t * so any run that overlaps no scene can be marked, an earlier one\n\t\t\t * included — and the selection ends. A refusal keeps it.\n\t\t\t */\n\t\t\tasync markSelection() {\n\t\t\t\tconst run = markedRun(selected, rows as SceneMarkRow[])\n\t\t\t\tif (!run || sceneBusy) return\n\t\t\t\tsceneBusy = true\n\t\t\t\ttry {\n\t\t\t\t\tconst opened = await sceneWrite({ at: \"selection\", id: run.first }, \"scene-open\", {\n\t\t\t\t\t\tmessageId: run.first,\n\t\t\t\t\t\tchannel: run.lane,\n\t\t\t\t\t\tcloseAt: run.last\n\t\t\t\t\t})\n\t\t\t\t\tif (!opened) return\n\t\t\t\t\tselecting = false\n\t\t\t\t\tselected.clear()\n\t\t\t\t} finally {\n\t\t\t\t\tsceneBusy = false\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// ── selecting lines for a summary ────────────────────────────────────\n\t\tselect: {\n\t\t\tget active() {\n\t\t\t\treturn selecting\n\t\t\t},\n\t\t\tget ids() {\n\t\t\t\treturn selected\n\t\t\t},\n\t\t\t/** Whether this copy offers selecting lines for a summary; false only for a Dialogue box. */\n\t\t\tget offered() {\n\t\t\t\treturn !noSelection\n\t\t\t},\n\t\t\tstart(subject?: Subject) {\n\t\t\t\tif (noSelection) return\n\t\t\t\tselecting = true\n\t\t\t\tselected.clear()\n\t\t\t\tif (subject) selected.add(subject.id)\n\t\t\t\tmenuFor = undefined\n\t\t\t},\n\t\t\tstop() {\n\t\t\t\tselecting = false\n\t\t\t\tselected.clear()\n\t\t\t},\n\t\t\ttoggle(subject: Subject) {\n\t\t\t\t// A line a scene already captured cannot join another.\n\t\t\t\tif (scenedSet.has(subject.id)) return\n\t\t\t\tif (selected.has(subject.id)) selected.delete(subject.id)\n\t\t\t\telse selected.add(subject.id)\n\t\t\t},\n\t\t\tset(ids: number[]) {\n\t\t\t\tselected.clear()\n\t\t\t\tfor (const id of ids) selected.add(id)\n\t\t\t},\n\t\t\t/**\n\t\t\t * From a line toward one end, up to the nearest line already\n\t\t\t * selected — never through a line a scene has already captured.\n\t\t\t */\n\t\t\trange(index: number, toward: \"above\" | \"below\") {\n\t\t\t\t// The log's own rows: `index` counts the lines this copy draws.\n\t\t\t\tconst list = rows\n\t\t\t\tconst taken = scenedSet\n\t\t\t\tconst step = toward === \"above\" ? -1 : 1\n\t\t\t\tfor (let i = index; i >= 0 && i < list.length; i += step) {\n\t\t\t\t\tconst id = list[i].id\n\t\t\t\t\tif (taken.has(id)) break\n\t\t\t\t\tif (selected.has(id) && i !== index) break\n\t\t\t\t\tselected.add(id)\n\t\t\t\t}\n\t\t\t},\n\t\t\t/**\n\t\t\t * Hand the selection to the host's summarizer. It stays until the host\n\t\t\t * says the summary finished (`summaryEnded`): a cancelled or failed\n\t\t\t * create keeps a hand-picked selection.\n\t\t\t */\n\t\t\tcommit(kind: \"scene\" | \"world\" | \"character\") {\n\t\t\t\tctx().request(\"summarize\", { kind, messageIds: [...selected] }).catch(warn(\"summarize\"))\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function setConversation(c: Conversation): Conversation {\n\treturn setContext(KEY, c)\n}\n\nexport function useConversation(): Conversation {\n\tconst c = getContext<Conversation | undefined>(KEY)\n\tif (!c) throw new Error(\"a conversation part rendered outside MessagesWidget\")\n\treturn c\n}\n\n/**\n * The widget's `t` for a part that may also render outside a widget (a\n * block view in a test): the English source there.\n */\nexport function useT(): (source: string) => string {\n\tconst w = useWidgetContext()\n\treturn (source) => w?.current.t?.(source) ?? source\n}\n","shared/messages/interleave.ts":"/**\n * 🚧 **Interleave** (PLAN-rulesets §30, 2026-10-16): a conversation copy's\n * `interleave` setting names another channel — the `table` 🚧 channel, where\n * a Dungeon Crawler's rolls, stakes and rest lines live — whose rows this copy\n * draws inline, each straight after the line it belongs to\n * (`metadata.anchorMessageId`), faceless. Both views read the same rows: a\n * copy pinned to that channel itself shows them as a log.\n *\n * Pure, so the order is a fact a test can read without a mount.\n */\n\n/** A row as far as interleaving reads it. */\nexport interface InterleaveRow {\n\tid: number\n\tchannel?: unknown\n\tmetadata?: { anchorMessageId?: unknown } | null | Record<string, unknown>\n}\n\n/** The slug part of a stored channel (`table:2` → `table`); absent is `main`. */\nfunction slugOf(channel: unknown): string {\n\tconst c = typeof channel === \"string\" && channel ? channel : \"main\"\n\tconst at = c.indexOf(\":\")\n\treturn at < 0 ? c : c.slice(0, at)\n}\n\n/** The `interleave` setting, read: a trimmed slug, or `''` for none. */\nexport function interleaveSlug(raw: unknown): string {\n\treturn typeof raw === \"string\" ? raw.trim() : \"\"\n}\n\n/** The message a row is anchored to (`metadata.anchorMessageId`), or `null`. */\nexport function anchorOf(row: InterleaveRow): number | null {\n\tconst v = (row.metadata as { anchorMessageId?: unknown } | null | undefined)?.anchorMessageId\n\treturn typeof v === \"number\" && Number.isInteger(v) ? v : null\n}\n\n/** Whether `row` is one of the interleaved channel's rows (`slug` set). */\nexport function isInterleavedRow(row: InterleaveRow, slug: string): boolean {\n\treturn !!slug && slugOf(row.channel) === slug\n}\n\n/**\n * `rows` (the host's order, oldest first) with each row of channel `slug`\n * that names a present anchor moved to straight after that anchor — after\n * any earlier row anchored to it, by id. A row of `slug` whose anchor is not\n * among `rows` (older than the page loaded, or none) keeps its own place.\n * No `slug`: `rows`, untouched.\n */\nexport function interleaveByAnchor<T extends InterleaveRow>(rows: readonly T[], slug: string): T[] {\n\tif (!slug) return rows as T[]\n\tconst present = new Set<number>()\n\tfor (const r of rows) if (!isInterleavedRow(r, slug)) present.add(r.id)\n\tconst under = new Map<number, T[]>()\n\tconst rest: T[] = []\n\tfor (const r of rows) {\n\t\tconst anchor = isInterleavedRow(r, slug) ? anchorOf(r) : null\n\t\tif (anchor !== null && present.has(anchor)) {\n\t\t\tconst list = under.get(anchor)\n\t\t\tif (list) list.push(r)\n\t\t\telse under.set(anchor, [r])\n\t\t} else rest.push(r)\n\t}\n\tif (!under.size) return rows as T[]\n\tconst out: T[] = []\n\tfor (const r of rest) {\n\t\tout.push(r)\n\t\tconst list = under.get(r.id)\n\t\tif (list) out.push(...list.sort((a, b) => a.id - b.id))\n\t}\n\treturn out\n}\n\n// ─── How an interleaved row reads, and a folio's kinds (PLAN-sheet-widget §16) ──\n\n/**\n * 🚧 The `interleaveAs` setting, read (owner ruling 2026-10-17, \"under the\n * fold\"): `fold` — one head line that opens into the whole row, closed by\n * default — or `open`, the row as it was written. Unsaid is `fold`.\n */\nexport function interleaveMode(raw: unknown): \"fold\" | \"open\" {\n\treturn raw === \"open\" ? \"open\" : \"fold\"\n}\n\n/** The head a folded row shows: the host's `metadata.summary` when it sent one, else the row's first line. */\nexport function foldHeadOf(row: { content?: unknown; metadata?: unknown }): string {\n\tconst meta = row.metadata as { summary?: unknown } | null | undefined\n\tconst summary = typeof meta?.summary === \"string\" ? meta.summary.trim() : \"\"\n\tconst source = summary || (typeof row.content === \"string\" ? row.content : \"\")\n\tconst first = source.split(\"\\n\").map((l) => l.trim()).find(Boolean) ?? \"\"\n\t// A heading's or a list's marks are not words.\n\tconst bare = first.replace(/^(#{1,6}\\s+|[-*]\\s+|>\\s+)/, \"\").replace(/\\*\\*|__/g, \"\")\n\treturn bare.length > 160 ? `${bare.slice(0, 159)}…` : bare\n}\n\n/**\n * 🚧 A fold's body (PLAN-dc-after-walk2 Q3-2, the walk's N14): every line\n * AFTER its head, one result a line — the open fold repeated its head and\n * ran its lines together into one. Empty when the head is all there is.\n */\nexport function foldRestOf(row: { content?: unknown; metadata?: unknown }): string[] {\n\tconst meta = row.metadata as { summary?: unknown } | null | undefined\n\tconst lines = (typeof row.content === \"string\" ? row.content : \"\").split(\"\\n\").map((l) => l.trim()).filter(Boolean)\n\tconst summary = typeof meta?.summary === \"string\" ? meta.summary.trim() : \"\"\n\t// A summary heads the fold apart from the lines: every line is the body.\n\treturn summary ? lines : lines.slice(1)\n}\n\n/**\n * 🚧 The `rowKinds` setting, read: the kinds ticked (a list), trimmed and\n * lower-cased; none is every line. ⏳ A copy stored as one comma-separated\n * string (before 2026-10-18) reads the same.\n */\nexport function rowKindsOf(raw: unknown): string[] {\n\tconst listed = Array.isArray(raw) ? raw.filter((k): k is string => typeof k === \"string\") : typeof raw === \"string\" ? raw.split(\",\") : []\n\treturn listed.map((k) => k.trim().toLowerCase()).filter(Boolean)\n}\n\n/** A row's kind (`metadata.kind` — a journal's `did`, `found`, `met`, …), or `null`. */\nexport function rowKindOf(row: { metadata?: unknown }): string | null {\n\tconst k = (row.metadata as { kind?: unknown } | null | undefined)?.kind\n\treturn typeof k === \"string\" && k.trim() ? k.trim().toLowerCase() : null\n}\n\n/**\n * The round a row belongs to: the Narrator's row every journal line of that\n * round is anchored to (`metadata.anchorMessageId`, what the ledger writes),\n * else a `metadata.round` a genre may spell; or `null`.\n */\nfunction roundOf(row: { metadata?: unknown }): string | null {\n\tconst m = row.metadata as { round?: unknown; anchorMessageId?: unknown } | null | undefined\n\tconst a = m?.anchorMessageId\n\tif (typeof a === \"number\" || (typeof a === \"string\" && a)) return `anchor:${String(a)}`\n\tconst r = m?.round\n\treturn typeof r === \"number\" || (typeof r === \"string\" && r) ? String(r) : null\n}\n\n/**\n * 🚧 A folio copy's rows by kind (PLAN-sheet-widget §16): `kinds` keeps the\n * rows whose kind it names — a row with no kind always shows — and a\n * round's rows (anchored to one Narrator row, `metadata.anchorMessageId`) are drawn together under its `did` row,\n * the other kinds after it as small lines. A round with no `did` row keeps\n * its rows where the first of them was. No kind anywhere: `rows`, untouched.\n */\nexport function rowsByKind<T extends { id: number; metadata?: unknown }>(rows: readonly T[], kinds: readonly string[]): T[] {\n\tconst kept = kinds.length\n\t\t? rows.filter((r) => {\n\t\t\t\tconst k = rowKindOf(r)\n\t\t\t\treturn k === null || kinds.includes(k)\n\t\t\t})\n\t\t: rows.slice()\n\tif (!kept.some((r) => rowKindOf(r) !== null && roundOf(r) !== null)) return kept as T[]\n\tconst byRound = new Map<string, T[]>()\n\tfor (const r of kept) {\n\t\tconst round = rowKindOf(r) !== null ? roundOf(r) : null\n\t\tif (round === null) continue\n\t\tconst list = byRound.get(round)\n\t\tif (list) list.push(r)\n\t\telse byRound.set(round, [r])\n\t}\n\tconst placed = new Set<string>()\n\tconst out: T[] = []\n\tfor (const r of kept) {\n\t\tconst round = rowKindOf(r) !== null ? roundOf(r) : null\n\t\tif (round === null) {\n\t\t\tout.push(r)\n\t\t\tcontinue\n\t\t}\n\t\tconst list = byRound.get(round)!\n\t\tconst head = list.find((x) => rowKindOf(x) === \"did\")\n\t\t// The round is drawn where its `did` row stands (or its first row, with none).\n\t\tif (placed.has(round) || (head && r !== head)) continue\n\t\tplaced.add(round)\n\t\tconst rest = list.filter((x) => x !== head).sort((a, b) => a.id - b.id)\n\t\tif (head) out.push(head)\n\t\tout.push(...rest)\n\t}\n\treturn out\n}\n","shared/messages/rowFacts.ts":"/**\n * Facts every conversation row reads off the whole message list, worked out\n * once per list change (by the conversation) instead of once per row per\n * streamed token. Pure, so a test reads each equivalence without a mount.\n */\n\n/** A row as far as these facts read it. */\nexport interface FactRow {\n\tid?: unknown\n\tisGenerating?: unknown\n}\n\n/** Whether any row is being written: what `rows.some((m) => m.isGenerating)` answers. */\nexport function anyGenerating(rows: ReadonlyArray<FactRow>): boolean {\n\treturn rows.some((m) => m.isGenerating)\n}\n\n/**\n * Each row by its id, for a read that answers what\n * `rows.find((m) => m?.id === id)` answers: on a duplicate id the first row\n * stays. Hold it, then read with {@link rowWithId}.\n */\nexport function indexRowsById<T extends FactRow | null | undefined>(\n\trows: ReadonlyArray<T>,\n): Map<unknown, T> {\n\tconst out = new Map<unknown, T>()\n\tfor (const m of rows) {\n\t\tconst id = m?.id\n\t\t// `===` never matches NaN; a Map would.\n\t\tif (typeof id === 'number' && Number.isNaN(id)) continue\n\t\tif (!out.has(id)) out.set(id, m)\n\t}\n\treturn out\n}\n\n/** The row `find((m) => m?.id === id)` would return, from an {@link indexRowsById} index. */\nexport function rowWithId<T>(index: ReadonlyMap<unknown, T>, id: unknown): T | undefined {\n\treturn index.get(id)\n}\n\n/** The ids a scene has already captured, as a Set; `has` answers what `includes` does. */\nexport function scenedSetOf(scened: ReadonlyArray<number> | null | undefined): Set<number> {\n\treturn new Set(scened ?? [])\n}\n","shared/messages/sceneMarks.ts":"/**\n * 🚧 The conversation's **scene dividers** and **day marks**, as pure\n * functions (PROPOSAL-live-scenes §3, §7, §14 C): what the log draws between\n * its rows, and which scene boundaries a line's menu may offer.\n *\n * A scene is one of two kinds while live scenes land. A **live scene** opens\n * at a message and is the run of its channel lane's lines from there to the\n * message it closes at — open-ended while it is the **open scene**. A scene\n * **captured by selection** (ticked lines, no opening) is its\n * `selectedMessageIds` alone. A row sits in at most one scene: a captured\n * scene's lines are taken first, then the live ranges fill the rest.\n *\n * A row's **story clock stamp** (`storyClock*`, the session's story now when\n * it was written) gives the day marks: one before the first stamped line of\n * each story day on the lane the log shows.\n *\n * Self-contained — no import — so a component bundles it from source and a\n * test reads it as it stands.\n */\n\n/** A story time as a scene's clock and a row's stamp carry it. */\nexport interface StoryDayParts {\n\tyear: number\n\tmonth?: number | null\n\tday?: number | null\n\thour?: number | null\n\tminute?: number | null\n}\n\n/** A scene as these functions read it (the dossier's `ConversationSceneV1`). */\nexport interface SceneMarkScene {\n\tid: number\n\tname: string | null\n\tselectedMessageIds: number[]\n\thistoryEntryId?: number | null\n\thistoryEntry?: { year: number; month: number | null; day: number | null } | null\n\tchannel?: string\n\topenedAtMessageId?: number | null\n\tclosedAtMessageId?: number | null\n\topenedAt?: StoryDayParts | null\n\tclosedAt?: StoryDayParts | null\n\tsummaryStatus?: string\n}\n\n/** A row as these functions read it (a `MessageV1`). */\nexport interface SceneMarkRow {\n\tid: number\n\tchannel?: unknown\n\tisHidden?: boolean\n\tstoryClockYear?: unknown\n\tstoryClockMonth?: unknown\n\tstoryClockDay?: unknown\n\tstoryClockHour?: unknown\n\tstoryClockMinute?: unknown\n}\n\n/** How many scene colours the conversation's palette has (the Chronicle's swatches). */\nexport const SCENE_SWATCH_COUNT = 8\n\n/**\n * A channel string as one lane, canonically: a bare slug is lane 1, so\n * `main` and `main:1` are one lane; unset is `main`.\n */\nexport function laneOf(channel: unknown): string {\n\tconst raw = typeof channel === \"string\" && channel.trim() ? channel.trim() : \"main\"\n\tconst at = raw.indexOf(\":\")\n\tif (at < 0) return raw\n\tconst lane = raw.slice(at + 1)\n\treturn lane === \"1\" ? raw.slice(0, at) : raw\n}\n\n/** A scene opened at a message — not one captured by selection. */\nexport const isLiveScene = (s: SceneMarkScene): boolean =>\n\ttypeof s.openedAtMessageId === \"number\"\n\n/** A live scene still open: no closing message yet. */\nexport const isOpenScene = (s: SceneMarkScene): boolean =>\n\tisLiveScene(s) && s.closedAtMessageId == null\n\n/**\n * Where a scene begins in the session: its opening message, else its first\n * captured line; a scene with neither sorts last. The order scenes take\n * their colours in, here and in the Chronicle.\n */\nexport function sceneStartOf(s: SceneMarkScene): number {\n\tif (isLiveScene(s)) return s.openedAtMessageId as number\n\tconst ids = s.selectedMessageIds ?? []\n\treturn ids.length ? Math.min(...ids) : Number.POSITIVE_INFINITY\n}\n\n/** Each scene's colour (0–7): its place among the session's scenes, oldest first. */\nexport function sceneSwatches(scenes: readonly SceneMarkScene[]): Map<number, number> {\n\tconst out = new Map<number, number>()\n\t;[...scenes]\n\t\t.sort((a, b) => sceneStartOf(a) - sceneStartOf(b) || a.id - b.id)\n\t\t.forEach((s, i) => out.set(s.id, i % SCENE_SWATCH_COUNT))\n\treturn out\n}\n\n/** Whether a live scene's range holds a row: its lane, from its opening to its close. */\nexport function liveSceneHolds(s: SceneMarkScene, row: SceneMarkRow): boolean {\n\tif (!isLiveScene(s)) return false\n\tif (laneOf(row.channel) !== laneOf(s.channel)) return false\n\tif (row.id < (s.openedAtMessageId as number)) return false\n\treturn s.closedAtMessageId == null || row.id <= s.closedAtMessageId\n}\n\nconst whole = (v: unknown): number | null =>\n\ttypeof v === \"number\" && Number.isInteger(v) ? v : null\n\n/** A row's stamped story day, or null for a row written before stamps. */\nexport function storyDayOfRow(row: SceneMarkRow): StoryDayParts | null {\n\tconst year = whole(row.storyClockYear)\n\tif (year === null) return null\n\tconst month = whole(row.storyClockMonth)\n\treturn { year, month, day: month === null ? null : whole(row.storyClockDay) }\n}\n\n/**\n * A row's stamped story time with its time of day, or null when the stamp is\n * not a place in time (no whole year). A day needs its month and a minute its\n * hour, as the columns' checks hold.\n */\nexport function storyTimeOfRow(row: SceneMarkRow): StoryDayParts | null {\n\tconst day = storyDayOfRow(row)\n\tif (day === null) return null\n\tconst hour = whole(row.storyClockHour)\n\tconst out: StoryDayParts = { year: day.year }\n\tif (day.month != null) out.month = day.month\n\tif (day.day != null) out.day = day.day\n\tif (hour !== null) {\n\t\tout.hour = hour\n\t\tout.minute = whole(row.storyClockMinute) ?? 0\n\t}\n\treturn out\n}\n\n/** How a story time is spelled; handed in so this file stays import-free. */\nexport interface StoryTimeSpelling {\n\t/** The time through the book's calendar, in full. */\n\tfull(t: StoryDayParts): string\n\t/** The time through the copy's `timeFormat`; null when the format is empty. */\n\tas(t: StoryDayParts, format: string): string | null\n\t/** The calendar's day spelling, the time of day left off. */\n\tday(t: StoryDayParts): string\n}\n\n/**\n * What a line's time reads while the story has a clock or a dated present:\n * `text` beside the name (the copy's `timeFormat` when set, else `HH:MM`\n * when the stamp has an hour, else the day), `full` for the hover. Null on an\n * unstamped row, which keeps its real time.\n */\nexport function messageStoryTime(\n\trow: SceneMarkRow,\n\tspell: StoryTimeSpelling,\n\ttimeFormat?: string | null\n): { text: string; full: string } | null {\n\tconst t = storyTimeOfRow(row)\n\tif (t === null) return null\n\tconst full = spell.full(t)\n\tconst formatted = timeFormat && timeFormat.trim() ? spell.as(t, timeFormat) : null\n\tif (formatted) return { text: formatted, full }\n\tif (t.hour != null) {\n\t\tconst pad = (n: number) => String(n).padStart(2, '0')\n\t\treturn { text: `${pad(t.hour)}:${pad(t.minute ?? 0)}`, full }\n\t}\n\treturn { text: spell.day(t), full }\n}\n\n/** Whether two story times fall on one day (as precise as both are). */\nexport function sameStoryDay(a: StoryDayParts, b: StoryDayParts): boolean {\n\treturn (\n\t\ta.year === b.year &&\n\t\t(a.month ?? null) === (b.month ?? null) &&\n\t\t(a.day ?? null) === (b.day ?? null)\n\t)\n}\n\n/**\n * A story day spelled free-form, the calendar's bottom rung\n * (`formatStoryTime` with no calendar), the time of day left off: `Year\n * 412, Mo. 3, Day 5`. 🚧 What `sceneMarks` spells with when it is handed no\n * `dayLabel` — the conversation hands it the book's calendar's\n * (`storyDayLabelIn`, §15 G9).\n */\nexport function storyDayLabel(t: StoryDayParts): string {\n\tlet out = `Year ${Math.trunc(t.year)}`\n\tif (t.month) out += `, Mo. ${t.month}`\n\tif (t.month && t.day) out += `, Day ${t.day}`\n\treturn out\n}\n\n/** What a scene divider says and holds. */\nexport interface SceneDivider {\n\tscene: SceneMarkScene\n\t/** Its colour, 0–7. */\n\tswatch: number\n\tlive: boolean\n\t/** The lane's open scene: its divider reads *since …* and carries the open mark. */\n\topen: boolean\n\t/**\n\t * The story lines it holds: a closed scene's recorded lines, else the\n\t * shown lines of its range that are loaded (an open scene's grow).\n\t */\n\tlineCount: number\n\t/** The loaded rows it holds, in conversation order — whose faces it shows. */\n\trowIds: number[]\n\t/** The day a live scene opened on; null for a captured scene, or one opened with no story clock. */\n\tdateLabel: string | null\n\t/**\n\t * 🚧 Where *Move start up one line* moves a live scene's opening: the\n\t * shown line before it on its lane, when that line is loaded and in no\n\t * other scene; else null (lane E).\n\t */\n\tstartEarlier: number | null\n\t/**\n\t * 🚧 Where *Move start down one line* moves it: the scene's next shown\n\t * line on its lane, when the scene would keep a line; else null.\n\t */\n\tstartLater: number | null\n\t/**\n\t * 🚧 *Reopen scene* is offered: a closed live scene with no open scene\n\t * and no later scene on its lane, so it may run on to the newest line.\n\t */\n\treopens: boolean\n}\n\n/** What the log draws between its rows. */\nexport interface SceneMarks {\n\t/** Per row id: the scene it sits in, and that scene's colour. */\n\tsceneOf: Map<number, { sceneId: number; swatch: number; name: string }>\n\t/** Per row id: the divider drawn at it — its scene's first loaded row. */\n\tdividers: Map<number, SceneDivider>\n\t/** Per row id: the day mark drawn before it. */\n\tdayMarks: Map<number, { label: string; day: StoryDayParts }>\n}\n\nconst sceneName = (s: SceneMarkScene) => (s.name?.trim() ? s.name : \"Scene\")\n\n/**\n * The marks over `rows` (conversation order, oldest first). `lane` is the\n * lane the log shows: day marks compare only its rows, since the others are\n * drawn hidden. Absent, every row counts. 🚧 `dayLabel` spells a divider's\n * day and a day mark — the book's calendar's (§15 G9); absent, free-form\n * (`storyDayLabel`).\n */\nexport function sceneMarks(\n\trows: readonly SceneMarkRow[],\n\tscenes: readonly SceneMarkScene[],\n\topts: { lane?: string; dayLabel?: (t: StoryDayParts) => string } = {}\n): SceneMarks {\n\tconst dayLabel = opts.dayLabel ?? storyDayLabel\n\tconst sceneOf: SceneMarks[\"sceneOf\"] = new Map()\n\tconst dividers: SceneMarks[\"dividers\"] = new Map()\n\tconst dayMarks: SceneMarks[\"dayMarks\"] = new Map()\n\tconst swatches = sceneSwatches(scenes)\n\n\t// Captured scenes take their ticked lines first…\n\tconst byId = new Map(rows.map((r) => [r.id, r]))\n\tconst holds = new Map<number, number[]>()\n\tfor (const s of scenes) {\n\t\tif (isLiveScene(s)) continue\n\t\tfor (const id of s.selectedMessageIds ?? []) {\n\t\t\tif (!byId.has(id) || sceneOf.has(id)) continue\n\t\t\tsceneOf.set(id, { sceneId: s.id, swatch: swatches.get(s.id) ?? 0, name: sceneName(s) })\n\t\t}\n\t}\n\t// …then each live range fills what is left on its lane.\n\tconst live = scenes.filter(isLiveScene)\n\tfor (const row of rows) {\n\t\tif (sceneOf.has(row.id)) continue\n\t\tconst s = live.find((x) => liveSceneHolds(x, row))\n\t\tif (s) sceneOf.set(row.id, { sceneId: s.id, swatch: swatches.get(s.id) ?? 0, name: sceneName(s) })\n\t}\n\tfor (const row of rows) {\n\t\tconst at = sceneOf.get(row.id)\n\t\tif (!at) continue\n\t\tconst list = holds.get(at.sceneId) ?? []\n\t\tlist.push(row.id)\n\t\tholds.set(at.sceneId, list)\n\t}\n\n\tfor (const s of scenes) {\n\t\tconst ids = holds.get(s.id)\n\t\tif (!ids?.length) continue\n\t\tconst liveScene = isLiveScene(s)\n\t\tconst open = isOpenScene(s)\n\t\tconst shown = ids.filter((id) => !byId.get(id)?.isHidden).length\n\t\tconst recorded = s.selectedMessageIds?.length ?? 0\n\t\t// A captured scene's date is its history entry's, which the log's\n\t\t// history marker already says above the entry's first scene.\n\t\tconst when = liveScene ? s.openedAt : null\n\t\tconst nudge = liveScene ? startNudges(s, rows, sceneOf) : { startEarlier: null, startLater: null }\n\t\tdividers.set(ids[0], {\n\t\t\tscene: s,\n\t\t\tswatch: swatches.get(s.id) ?? 0,\n\t\t\tlive: liveScene,\n\t\t\topen,\n\t\t\tlineCount: !open && recorded > 0 ? recorded : shown,\n\t\t\trowIds: ids,\n\t\t\tdateLabel: when && typeof when.year === \"number\" ? dayLabel(when) : null,\n\t\t\t...nudge,\n\t\t\treopens: liveScene && !open && mayReopen(s, live)\n\t\t})\n\t}\n\n\tlet last: StoryDayParts | null = null\n\tfor (const row of rows) {\n\t\tif (opts.lane !== undefined && (typeof row.channel === \"string\" && row.channel ? row.channel : \"main\") !== opts.lane)\n\t\t\tcontinue\n\t\tconst day = storyDayOfRow(row)\n\t\tif (!day) continue\n\t\tif (!last || !sameStoryDay(last, day)) dayMarks.set(row.id, { label: dayLabel(day), day })\n\t\tlast = day\n\t}\n\treturn { sceneOf, dividers, dayMarks }\n}\n\n/**\n * 🚧 Where a live scene's opening may move by one line (lane E): the shown\n * line before it on its lane — loaded and in no scene — and the scene's own\n * next shown line, while the scene would keep at least one line.\n */\nfunction startNudges(\n\ts: SceneMarkScene,\n\trows: readonly SceneMarkRow[],\n\tsceneOf: SceneMarks[\"sceneOf\"],\n): { startEarlier: number | null; startLater: number | null } {\n\tconst lane = laneOf(s.channel)\n\tconst onLane = rows.filter((r) => laneOf(r.channel) === lane)\n\tconst at = onLane.findIndex((r) => r.id === s.openedAtMessageId)\n\tif (at < 0) return { startEarlier: null, startLater: null }\n\tlet earlier: SceneMarkRow | undefined\n\tfor (let i = at - 1; i >= 0; i--)\n\t\tif (!onLane[i]!.isHidden) {\n\t\t\tearlier = onLane[i]\n\t\t\tbreak\n\t\t}\n\tlet later: SceneMarkRow | undefined\n\tfor (let i = at + 1; i < onLane.length; i++)\n\t\tif (!onLane[i]!.isHidden) {\n\t\t\tlater = onLane[i]\n\t\t\tbreak\n\t\t}\n\treturn {\n\t\tstartEarlier: earlier && !sceneOf.has(earlier.id) ? earlier.id : null,\n\t\tstartLater:\n\t\t\tlater &&\n\t\t\tsceneOf.get(later.id)?.sceneId === s.id &&\n\t\t\t(s.closedAtMessageId == null || later.id <= s.closedAtMessageId)\n\t\t\t\t? later.id\n\t\t\t\t: null,\n\t}\n}\n\n/** A closed live scene may run on again: no open scene and no later scene on its lane. */\nfunction mayReopen(s: SceneMarkScene, live: readonly SceneMarkScene[]): boolean {\n\tconst lane = laneOf(s.channel)\n\treturn !live.some(\n\t\t(x) =>\n\t\t\tx.id !== s.id &&\n\t\t\tlaneOf(x.channel) === lane &&\n\t\t\t(isOpenScene(x) || (x.openedAtMessageId as number) > (s.openedAtMessageId as number)),\n\t)\n}\n\n/** Which scene boundaries a line's menu may offer. */\nexport interface BoundaryOffer {\n\t/** *Start scene here*: a scene may open at this line. */\n\tstart: boolean\n\t/** *End scene here*: the open scene this line may close, by id; null when none. */\n\tend: number | null\n}\n\n/**\n * What the host would accept at this line — mirrored so the menu hides what\n * it would refuse (`scenes:open`, `scenes:close`):\n *\n * - **Start** where the line is in no scene captured by selection and in no\n * closed scene, and the lane's open scene (if any) opened before it — the\n * open one is then closed at the line before. With no open scene, every\n * closed scene on the lane must end before the line (a new one runs on to\n * the newest line, and may not cover another).\n * - **End** where the lane's open scene opened at or before the line.\n */\nexport function boundaryOffer(row: SceneMarkRow, scenes: readonly SceneMarkScene[]): BoundaryOffer {\n\tconst lane = laneOf(row.channel)\n\tconst onLane = scenes.filter((s) => isLiveScene(s) && laneOf(s.channel) === lane)\n\tconst open = onLane.find(isOpenScene) ?? null\n\tconst captured = scenes.some(\n\t\t(s) => !isLiveScene(s) && (s.selectedMessageIds ?? []).includes(row.id)\n\t)\n\tconst inClosed = onLane.some((s) => !isOpenScene(s) && liveSceneHolds(s, row))\n\tconst start =\n\t\t!captured &&\n\t\t!inClosed &&\n\t\t(open\n\t\t\t? row.id > (open.openedAtMessageId as number)\n\t\t\t: onLane.every((s) => s.closedAtMessageId != null && s.closedAtMessageId < row.id))\n\tconst end = open && row.id >= (open.openedAtMessageId as number) ? open.id : null\n\treturn { start, end }\n}\n\n/**\n * 🚧 Whether a run may become one closed scene (*Mark as scene*, lane E) —\n * what the host would take, mirrored: no line of it on its lane is in a\n * scene captured by selection, and it overlaps no live scene on its lane,\n * except that the lane's open scene, opened before the run, is closed at the\n * line before (as *Start scene here* closes it).\n */\nexport function runOffer(\n\trun: { lane: string; first: number; last: number },\n\tscenes: readonly SceneMarkScene[],\n\trows: readonly SceneMarkRow[],\n): boolean {\n\tconst onLane = scenes.filter((s) => isLiveScene(s) && laneOf(s.channel) === run.lane)\n\tfor (const s of onLane) {\n\t\tconst opened = s.openedAtMessageId as number\n\t\tif (isOpenScene(s)) {\n\t\t\tif (run.last < opened) continue\n\t\t\tif (run.first <= opened) return false\n\t\t\tcontinue\n\t\t}\n\t\tif (run.first <= (s.closedAtMessageId as number) && opened <= run.last) return false\n\t}\n\tconst captured = new Set(scenes.filter((s) => !isLiveScene(s)).flatMap((s) => s.selectedMessageIds ?? []))\n\treturn !rows.some(\n\t\t(r) => r.id >= run.first && r.id <= run.last && laneOf(r.channel) === run.lane && captured.has(r.id),\n\t)\n}\n\n/**\n * The run a selection marks as one scene (*Mark as scene*): from the\n * earliest line picked to the latest picked on that line's lane, or null for\n * an empty selection.\n */\nexport function markedRun(\n\tselected: Iterable<number>,\n\trows: readonly SceneMarkRow[]\n): { lane: string; first: number; last: number } | null {\n\tconst picked = new Set(selected)\n\tconst chosen = rows.filter((r) => picked.has(r.id))\n\tif (!chosen.length) return null\n\tconst first = chosen.reduce((a, b) => (b.id < a.id ? b : a))\n\tconst lane = laneOf(first.channel)\n\tconst last = chosen\n\t\t.filter((r) => laneOf(r.channel) === lane)\n\t\t.reduce((a, b) => (b.id > a.id ? b : a))\n\treturn { lane, first: first.id, last: last.id }\n}\n","shared/turn-line/TurnLineMount.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's turn-line widget as a remote component: the component context, as\n\t * the native widget context, around `TurnLineWidget`.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/conversation\"\n\timport TurnLineWidget from \"./TurnLineWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"turn-line\", instanceId: \"turn-line\", title: \"Turn line\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><TurnLineWidget /></WidgetBoundary>\n","shared/turn-line/TurnLineWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * The `turn-line` widget's component (owner R8 2026-11-05): what the last\n\t * run did and who is next, one row, beside the log and the composer it\n\t * was drawn between. It owns a conversation of its own that follows the\n\t * Messages copy it belongs to (`followTarget`): same rows, same dossier,\n\t * the lane that copy shows. Reads its `nextUp` setting off the widget\n\t * context.\n\t */\n\timport { useWidgetContext } from \"../context\"\n\timport TurnLine from \"../messages/TurnLine.svelte\"\n\timport { createConversation, setConversation } from \"../messages/conversation.svelte\"\n\timport { readTurnLineSettings } from \"./settings\"\n\n\tconst ctx = useWidgetContext()\n\tconst conversation = ctx ? setConversation(createConversation(ctx, { followTarget: true })) : null\n\tconst settings = $derived(readTurnLineSettings(ctx?.current.settings.v1 as Record<string, unknown> | undefined))\n</script>\n\n<!-- The widget's parts (`turn-line.*`, STYLE-GUIDE §6.16): no look here. -->\n{#if conversation && !conversation.noLane}\n\t<div data-widget-part=\"turn-line.root\">\n\t\t<TurnLine nextUp={settings.nextUp} />\n\t</div>\n{/if}\n","shared/turn-line/settings.ts":"/**\n * The `turn-line` widget's one setting (owner R8 2026-11-05: `nextUp` was the\n * `messages` widget's, moved verbatim).\n */\n\n/**\n * Who is due next (PLAN-turn-order §4.9): the order's head with Continue,\n * the head and who follows it, or nothing.\n */\nexport type NextUp = \"head\" | \"list\" | \"hidden\"\n\nexport interface TurnLineSettings {\n\tnextUp: NextUp\n}\n\n/** The declared default (`CORE_WIDGETS`, the `turn-line` entry). */\nexport const TURN_LINE_DEFAULTS: TurnLineSettings = { nextUp: \"head\" }\n\nexport function readTurnLineSettings(raw: Record<string, unknown> | undefined): TurnLineSettings {\n\tconst v = raw ?? {}\n\tconst of: readonly NextUp[] = [\"head\", \"list\", \"hidden\"]\n\treturn {\n\t\tnextUp:\n\t\t\ttypeof v.nextUp === \"string\" && (of as readonly string[]).includes(v.nextUp)\n\t\t\t\t? (v.nextUp as NextUp)\n\t\t\t\t// ⏳ `showNudge: false` was this setting before `nextUp` (A8).\n\t\t\t\t: v.showNudge === false\n\t\t\t\t\t? \"hidden\"\n\t\t\t\t\t: TURN_LINE_DEFAULTS.nextUp\n\t}\n}\n","shared/turn-line/turn-line.ts":"/**\n * Core's `turn-line` component (owner R8 2026-11-05): what the last run did\n * and who is next, split from the log. `npm run build` compiles it with the\n * CLI's component bundler to `dist/components/turn-line.js`, the module the\n * app serves at `/core-ui/turn-line`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport TurnLineMount from './TurnLineMount.svelte'\n\nexport default svelteComponent(TurnLineMount)\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"83ed60f397141f2ee14befc6193267565f9291ac5cda0e703faaca0c414e5c30","catalogVersion":"0.6.0-pr-9"}
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  renderStatusText
3
- } from "./shared-XBDUENRA.js";
4
- import "./shared-QXF5CJVN.js";
5
- import "./shared-YDS7HYL6.js";
6
- import "./shared-W3XS5FEL.js";
7
- import "./shared-4ME6NFDK.js";
3
+ } from "./shared-JXYPKSTQ.js";
4
+ import "./shared-NICRJ4Z2.js";
5
+ import "./shared-5E4RQYRX.js";
6
+ import "./shared-EFMMT76D.js";
7
+ import "./shared-LUIF6DW7.js";
8
8
  import {
9
9
  CORE_ACTION_SPEC_ID,
10
10
  WIDGET_CONTEXT_KEY,
11
+ WidgetBoundary,
11
12
  append,
12
13
  child,
13
14
  comment,
@@ -36,7 +37,7 @@ import {
36
37
  useWidgetContext,
37
38
  user_derived,
38
39
  widgetRefFromComponent
39
- } from "./shared-JPG5DQO7.js";
40
+ } from "./shared-HEAKNNZB.js";
40
41
 
41
42
  // dist/shared/ui/turn-order/index.js
42
43
  var TURN_ORDER_DEFAULTS = Object.freeze({
@@ -214,13 +215,12 @@ var root = from_html(`<img data-widget-part="turn-order.face" alt=""/>`);
214
215
  var root_1 = from_html(`<span data-widget-part="turn-order.face" data-blank=""><sp-icon></sp-icon></span>`, 2);
215
216
  var root_2 = from_html(`<li data-widget-part="turn-order.row row"><!> <span data-widget-part="turn-order.name"> </span> <span data-widget-part="turn-order.state chip"> </span></li>`);
216
217
  var root_3 = from_html(`<p data-widget-part="turn-order.alert" role="alert"> </p>`);
217
- var root_4 = from_html(`<div data-widget-part="turn-order.empty empty" role="status"><sp-icon></sp-icon> <span> </span></div>`, 2);
218
- var root_5 = from_html(`<sp-icon></sp-icon>`, 2);
219
- var root_6 = from_html(`<ol data-widget-part="turn-order.list list"></ol>`);
220
- var root_7 = from_html(`<p data-widget-part="turn-order.head" role="status"><!> <span data-widget-part="turn-order.head-text"> </span></p> <!>`, 1);
221
- var root_8 = from_html(`<ul data-widget-part="turn-order.benched list"></ul>`);
222
- var root_9 = from_html(`<p data-widget-part="turn-order.strategy"> </p>`);
223
- var root_10 = from_html(`<div data-widget-part="turn-order.root"><!> <!> <!> <div data-widget-part="turn-order.controls toolbar"><button type="button" data-widget-part="turn-order.pick"><sp-icon></sp-icon> <span> </span></button> <button type="button" data-widget-part="turn-order.continue"><sp-icon></sp-icon> <span> </span></button></div> <!></div>`, 2);
218
+ var root_4 = from_html(`<sp-icon></sp-icon>`, 2);
219
+ var root_5 = from_html(`<ol data-widget-part="turn-order.list list"></ol>`);
220
+ var root_6 = from_html(`<p data-widget-part="turn-order.head" role="status"><!> <span data-widget-part="turn-order.head-text"> </span></p> <!>`, 1);
221
+ var root_7 = from_html(`<ul data-widget-part="turn-order.benched list"></ul>`);
222
+ var root_8 = from_html(`<p data-widget-part="turn-order.strategy"> </p>`);
223
+ var root_9 = from_html(`<div data-widget-part="turn-order.root"><!> <!> <!> <div data-widget-part="turn-order.controls toolbar"><button type="button" data-widget-part="turn-order.pick"><sp-icon></sp-icon> <span> </span></button> <button type="button" data-widget-part="turn-order.continue"><sp-icon></sp-icon> <span> </span></button></div> <!></div>`, 2);
224
224
  function TurnOrderWidget($$anchor, $$props) {
225
225
  push($$props, true);
226
226
  const turnRow = ($$anchor2, row = noop) => {
@@ -296,7 +296,7 @@ function TurnOrderWidget($$anchor, $$props) {
296
296
  }
297
297
  const onContinue = () => press(() => widget?.current.request("fire-turn", get(view).continueTurn.channel ? { channel: get(view).continueTurn.channel } : {}));
298
298
  const onPick = () => press(() => widget?.current.request("pick-turn", {}));
299
- var div = root_10();
299
+ var div = root_9();
300
300
  var node_2 = child(div);
301
301
  {
302
302
  var consequent_2 = ($$anchor2) => {
@@ -312,48 +312,36 @@ function TurnOrderWidget($$anchor, $$props) {
312
312
  }
313
313
  var node_3 = sibling(node_2, 2);
314
314
  {
315
- var consequent_3 = ($$anchor2) => {
316
- var div_1 = root_4();
317
- var sp_icon_1 = child(div_1);
318
- set_custom_element_data(sp_icon_1, "name", "list-ordered");
319
- set_custom_element_data(sp_icon_1, "size", "20");
320
- var span_3 = sibling(sp_icon_1, 2);
321
- var text_3 = child(span_3, true);
322
- reset(span_3);
323
- reset(div_1);
324
- template_effect(() => set_text(text_3, get(view).empty));
325
- append($$anchor2, div_1);
326
- };
327
- var alternate_1 = ($$anchor2) => {
328
- var fragment_1 = root_7();
315
+ var consequent_6 = ($$anchor2) => {
316
+ var fragment_1 = root_6();
329
317
  var p_1 = first_child(fragment_1);
330
318
  var node_4 = child(p_1);
331
319
  {
332
- var consequent_4 = ($$anchor3) => {
320
+ var consequent_3 = ($$anchor3) => {
333
321
  var img_1 = root();
334
322
  template_effect(() => set_attribute(img_1, "src", get(view).headFace));
335
323
  append($$anchor3, img_1);
336
324
  };
337
- var consequent_5 = ($$anchor3) => {
338
- var sp_icon_2 = root_5();
339
- set_custom_element_data(sp_icon_2, "name", "book-open-text");
340
- set_custom_element_data(sp_icon_2, "size", "18");
341
- set_custom_element_data(sp_icon_2, "data-widget-part", "turn-order.voice");
342
- append($$anchor3, sp_icon_2);
325
+ var consequent_4 = ($$anchor3) => {
326
+ var sp_icon_1 = root_4();
327
+ set_custom_element_data(sp_icon_1, "name", "book-open-text");
328
+ set_custom_element_data(sp_icon_1, "size", "18");
329
+ set_custom_element_data(sp_icon_1, "data-widget-part", "turn-order.voice");
330
+ append($$anchor3, sp_icon_1);
343
331
  };
344
332
  if_block(node_4, ($$render) => {
345
- if (get(view).headFace) $$render(consequent_4);
346
- else if (get(view).headIsVoice) $$render(consequent_5, 1);
333
+ if (get(view).headFace) $$render(consequent_3);
334
+ else if (get(view).headIsVoice) $$render(consequent_4, 1);
347
335
  });
348
336
  }
349
- var span_4 = sibling(node_4, 2);
350
- var text_4 = child(span_4, true);
351
- reset(span_4);
337
+ var span_3 = sibling(node_4, 2);
338
+ var text_3 = child(span_3, true);
339
+ reset(span_3);
352
340
  reset(p_1);
353
341
  var node_5 = sibling(p_1, 2);
354
342
  {
355
- var consequent_6 = ($$anchor3) => {
356
- var ol = root_6();
343
+ var consequent_5 = ($$anchor3) => {
344
+ var ol = root_5();
357
345
  each(ol, 21, () => get(view).rows, (row) => row.key, ($$anchor4, row) => {
358
346
  turnRow($$anchor4, () => get(row));
359
347
  });
@@ -362,21 +350,20 @@ function TurnOrderWidget($$anchor, $$props) {
362
350
  append($$anchor3, ol);
363
351
  };
364
352
  if_block(node_5, ($$render) => {
365
- if (get(view).rows.length) $$render(consequent_6);
353
+ if (get(view).rows.length) $$render(consequent_5);
366
354
  });
367
355
  }
368
- template_effect(() => set_text(text_4, get(view).head));
356
+ template_effect(() => set_text(text_3, get(view).head));
369
357
  append($$anchor2, fragment_1);
370
358
  };
371
359
  if_block(node_3, ($$render) => {
372
- if (get(view).status === "empty") $$render(consequent_3);
373
- else $$render(alternate_1, -1);
360
+ if (get(view).status !== "empty") $$render(consequent_6);
374
361
  });
375
362
  }
376
363
  var node_6 = sibling(node_3, 2);
377
364
  {
378
365
  var consequent_7 = ($$anchor2) => {
379
- var ul = root_8();
366
+ var ul = root_7();
380
367
  each(ul, 21, () => get(view).benched, (row) => row.key, ($$anchor3, row) => {
381
368
  turnRow($$anchor3, () => get(row));
382
369
  });
@@ -388,31 +375,31 @@ function TurnOrderWidget($$anchor, $$props) {
388
375
  if (get(view).benched.length) $$render(consequent_7);
389
376
  });
390
377
  }
391
- var div_2 = sibling(node_6, 2);
392
- var button = child(div_2);
393
- var sp_icon_3 = child(button);
394
- set_custom_element_data(sp_icon_3, "name", "users");
378
+ var div_1 = sibling(node_6, 2);
379
+ var button = child(div_1);
380
+ var sp_icon_2 = child(button);
381
+ set_custom_element_data(sp_icon_2, "name", "users");
382
+ set_custom_element_data(sp_icon_2, "size", "14");
383
+ var span_4 = sibling(sp_icon_2, 2);
384
+ var text_4 = child(span_4, true);
385
+ reset(span_4);
386
+ reset(button);
387
+ var button_1 = sibling(button, 2);
388
+ var sp_icon_3 = child(button_1);
389
+ set_custom_element_data(sp_icon_3, "name", "play");
395
390
  set_custom_element_data(sp_icon_3, "size", "14");
396
391
  var span_5 = sibling(sp_icon_3, 2);
397
392
  var text_5 = child(span_5, true);
398
393
  reset(span_5);
399
- reset(button);
400
- var button_1 = sibling(button, 2);
401
- var sp_icon_4 = child(button_1);
402
- set_custom_element_data(sp_icon_4, "name", "play");
403
- set_custom_element_data(sp_icon_4, "size", "14");
404
- var span_6 = sibling(sp_icon_4, 2);
405
- var text_6 = child(span_6, true);
406
- reset(span_6);
407
394
  reset(button_1);
408
- reset(div_2);
409
- var node_7 = sibling(div_2, 2);
395
+ reset(div_1);
396
+ var node_7 = sibling(div_1, 2);
410
397
  {
411
398
  var consequent_8 = ($$anchor2) => {
412
- var p_2 = root_9();
413
- var text_7 = child(p_2, true);
399
+ var p_2 = root_8();
400
+ var text_6 = child(p_2, true);
414
401
  reset(p_2);
415
- template_effect(() => set_text(text_7, get(view).strategy));
402
+ template_effect(() => set_text(text_6, get(view).strategy));
416
403
  append($$anchor2, p_2);
417
404
  };
418
405
  if_block(node_7, ($$render) => {
@@ -426,11 +413,11 @@ function TurnOrderWidget($$anchor, $$props) {
426
413
  set_attribute(div, "data-faces", get(settings).faces ? "" : void 0);
427
414
  button.disabled = !get(view).pick.enabled;
428
415
  set_attribute(button, "title", $0);
429
- set_text(text_5, $1);
416
+ set_text(text_4, $1);
430
417
  button_1.disabled = !get(view).continueTurn.enabled;
431
418
  set_attribute(button_1, "title", $2);
432
419
  set_attribute(button_1, "aria-label", get(view).continueTurn.label);
433
- set_text(text_6, $3);
420
+ set_text(text_5, $3);
434
421
  },
435
422
  [
436
423
  () => get(view).pick.reason ?? t("Pick who speaks"),
@@ -454,7 +441,15 @@ function TurnOrder($$anchor, $$props) {
454
441
  instanceId: "turn-order",
455
442
  title: "Turn order"
456
443
  }));
457
- TurnOrderWidget($$anchor, {});
444
+ WidgetBoundary($$anchor, {
445
+ get ctx() {
446
+ return $$props.ctx;
447
+ },
448
+ children: ($$anchor2, $$slotProps) => {
449
+ TurnOrderWidget($$anchor2, {});
450
+ },
451
+ $$slots: { default: true }
452
+ });
458
453
  pop();
459
454
  }
460
455
 
@@ -1 +1 @@
1
- {"slug":"turn-order","framework":"svelte","entry":"shared/turn-order/turn-order.ts","files":{"shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/turn-order/TurnOrder.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Turn order widget as a remote component (W1): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport TurnOrderWidget from \"./TurnOrderWidget.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"turn-order\", instanceId: \"turn-order\", title: \"Turn order\" }\n\t\t)\n\t)\n</script>\n\n<TurnOrderWidget />\n","shared/turn-order/TurnOrderWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Turn order (PLAN-core-widgets W1): whose turn it is, who follows, and\n\t * may I change that — the session's stored turn order (`turnOrder.v1`),\n\t * drawn as a list to look at.\n\t *\n\t * The head line means what the composer's *Who is due next* line means\n\t * (the same `order[0]`, named from the same candidates, in the same\n\t * words); then one row per prepared turn — face, name, chip (*Due* ·\n\t * *Then* · *You*); then **Continue** (`fire-turn`, on the head's channel)\n\t * and **Pick who speaks** (`pick-turn`), and the strategy in force. It\n\t * never hides while a draft exists, unlike the composer's line: it is for\n\t * looking while someone else writes. Everything it shows is worked out in\n\t * the plain half (`turnOrderView`); this only draws it.\n\t *\n\t * A control the viewer may not press is greyed with its reason as its\n\t * title, never hidden. A request the page declines is this widget's own\n\t * line (R77).\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`turn-order.row row`, …), the row's chip state rides\n\t * on `data-state`, and the default widget stylesheet draws them\n\t * (STYLE-GUIDE §6.16). With `showBenched` (W6) the benched characters\n\t * follow the order as rows of their own (`turn-order.benched`,\n\t * `data-state=\"benched\"`).\n\t */\n\timport type { ViewerV1 } from \"@serene-pub/sdk/component\"\n\timport {\n\t\treadTurnOrderSettings,\n\t\tturnOrderView,\n\t\ttype TurnRowView\n\t} from \"@serene-pub/core-catalog/turn-order\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\tconst settings = $derived(\n\t\treadTurnOrderSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tturnOrderView({\n\t\t\tturnOrder: widget?.current.turnOrder?.v1,\n\t\t\tcharacters: widget?.current.scope(\"characters\"),\n\t\t\tviewer: widget?.current.viewer?.v1 ?? NOBODY,\n\t\t\tactions: widget?.current.actions?.v1,\n\t\t\tsettings,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function press(ask: () => Promise<unknown> | undefined): Promise<void> {\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait ask()\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n\n\tconst onContinue = () =>\n\t\tpress(() =>\n\t\t\twidget?.current.request(\n\t\t\t\t\"fire-turn\",\n\t\t\t\tview.continueTurn.channel ? { channel: view.continueTurn.channel } : {}\n\t\t\t)\n\t\t)\n\tconst onPick = () => press(() => widget?.current.request(\"pick-turn\", {}))\n</script>\n\n{#snippet turnRow(row: TurnRowView)}\n\t<li\n\t\tdata-widget-part=\"turn-order.row row\"\n\t\tdata-state={row.state}\n\t\tdata-kind={row.kind}\n\t\tdata-channel={row.channel}\n\t\tdata-ref={row.ref ?? undefined}\n\t>\n\t\t{#if settings.faces}\n\t\t\t{#if row.face}\n\t\t\t\t<img data-widget-part=\"turn-order.face\" src={row.face} alt=\"\" />\n\t\t\t{:else}\n\t\t\t\t<span data-widget-part=\"turn-order.face\" data-blank=\"\">\n\t\t\t\t\t<sp-icon\n\t\t\t\t\t\tname={row.kind === \"voice\" ? \"book-open-text\" : row.kind === \"envoy\" ? \"sparkles\" : \"user-round\"}\n\t\t\t\t\t\tsize=\"14\"\n\t\t\t\t\t></sp-icon>\n\t\t\t\t</span>\n\t\t\t{/if}\n\t\t{/if}\n\t\t<span data-widget-part=\"turn-order.name\">{row.name}</span>\n\t\t<span data-widget-part=\"turn-order.state chip\">{row.chip}</span>\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"turn-order.root\" data-status={view.status} data-faces={settings.faces ? \"\" : undefined}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"turn-order.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if view.status === \"empty\"}\n\t\t<div data-widget-part=\"turn-order.empty empty\" role=\"status\">\n\t\t\t<sp-icon name=\"list-ordered\" size=\"20\"></sp-icon>\n\t\t\t<span>{view.empty}</span>\n\t\t</div>\n\t{:else}\n\t\t<p data-widget-part=\"turn-order.head\" role=\"status\">\n\t\t\t{#if view.headFace}\n\t\t\t\t<img data-widget-part=\"turn-order.face\" src={view.headFace} alt=\"\" />\n\t\t\t{:else if view.headIsVoice}\n\t\t\t\t<sp-icon name=\"book-open-text\" size=\"18\" data-widget-part=\"turn-order.voice\"></sp-icon>\n\t\t\t{/if}\n\t\t\t<span data-widget-part=\"turn-order.head-text\">{view.head}</span>\n\t\t</p>\n\n\t\t{#if view.rows.length}\n\t\t\t<ol data-widget-part=\"turn-order.list list\" aria-label={t(\"Turn order\")}>\n\t\t\t\t{#each view.rows as row (row.key)}\n\t\t\t\t\t{@render turnRow(row)}\n\t\t\t\t{/each}\n\t\t\t</ol>\n\t\t{/if}\n\t{/if}\n\n\t{#if view.benched.length}\n\t\t<!-- 🚧 W6: who is in the session but out of the turns (`showBenched`). -->\n\t\t<ul data-widget-part=\"turn-order.benched list\" aria-label={t(\"Benched\")}>\n\t\t\t{#each view.benched as row (row.key)}\n\t\t\t\t{@render turnRow(row)}\n\t\t\t{/each}\n\t\t</ul>\n\t{/if}\n\n\t<div data-widget-part=\"turn-order.controls toolbar\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"turn-order.pick\"\n\t\t\tdisabled={!view.pick.enabled}\n\t\t\ttitle={view.pick.reason ?? t(\"Pick who speaks\")}\n\t\t\tonclick={onPick}\n\t\t>\n\t\t\t<sp-icon name=\"users\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Pick who speaks\")}</span>\n\t\t</button>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"turn-order.continue\"\n\t\t\tdisabled={!view.continueTurn.enabled}\n\t\t\ttitle={view.continueTurn.reason ?? t(\"Continue\")}\n\t\t\taria-label={view.continueTurn.label}\n\t\t\tonclick={onContinue}\n\t\t>\n\t\t\t<sp-icon name=\"play\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Continue\")}</span>\n\t\t</button>\n\t</div>\n\n\t{#if view.strategy}\n\t\t<p data-widget-part=\"turn-order.strategy\">{view.strategy}</p>\n\t{/if}\n</div>\n","shared/turn-order/turn-order.ts":"/**\n * Core's `turn-order` component (PLAN-core-widgets W1): whose turn it is, who\n * follows, and Continue and Pick who speaks, as the page's UI worker runs it.\n * `npm run build` compiles it with the CLI's component bundler to\n * `dist/components/turn-order.js`, the module the app serves at\n * `/core-ui/turn-order`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport TurnOrder from './TurnOrder.svelte'\n\nexport default svelteComponent(TurnOrder)\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"82bb08e26f12b8478e4a046cde3e0b296a3691f627908df30618467ceaeeb006","catalogVersion":"0.6.0-pr-7"}
1
+ {"slug":"turn-order","framework":"svelte","entry":"shared/turn-order/turn-order.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/turn-order/TurnOrder.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Turn order widget as a remote component (W1): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport TurnOrderWidget from \"./TurnOrderWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"turn-order\", instanceId: \"turn-order\", title: \"Turn order\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><TurnOrderWidget /></WidgetBoundary>\n","shared/turn-order/TurnOrderWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Turn order (PLAN-core-widgets W1): whose turn it is, who follows, and\n\t * may I change that — the session's stored turn order (`turnOrder.v1`),\n\t * drawn as a list to look at.\n\t *\n\t * The head line means what the composer's *Who is due next* line means\n\t * (the same `order[0]`, named from the same candidates, in the same\n\t * words); then one row per prepared turn — face, name, chip (*Due* ·\n\t * *Then* · *You*); then **Continue** (`fire-turn`, on the head's channel)\n\t * and **Pick who speaks** (`pick-turn`), and the strategy in force. It\n\t * never hides while a draft exists, unlike the composer's line: it is for\n\t * looking while someone else writes. Everything it shows is worked out in\n\t * the plain half (`turnOrderView`); this only draws it.\n\t *\n\t * A control the viewer may not press is greyed with its reason as its\n\t * title, never hidden. A request the page declines is this widget's own\n\t * line (R77).\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`turn-order.row row`, …), the row's chip state rides\n\t * on `data-state`, and the default widget stylesheet draws them\n\t * (STYLE-GUIDE §6.16). With `showBenched` (W6) the benched characters\n\t * follow the order as rows of their own (`turn-order.benched`,\n\t * `data-state=\"benched\"`).\n\t */\n\timport type { ViewerV1 } from \"@serene-pub/sdk/component\"\n\timport {\n\t\treadTurnOrderSettings,\n\t\tturnOrderView,\n\t\ttype TurnRowView\n\t} from \"@serene-pub/core-catalog/turn-order\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\tconst settings = $derived(\n\t\treadTurnOrderSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tturnOrderView({\n\t\t\tturnOrder: widget?.current.turnOrder?.v1,\n\t\t\tcharacters: widget?.current.scope(\"characters\"),\n\t\t\tviewer: widget?.current.viewer?.v1 ?? NOBODY,\n\t\t\tactions: widget?.current.actions?.v1,\n\t\t\tsettings,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function press(ask: () => Promise<unknown> | undefined): Promise<void> {\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait ask()\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n\n\tconst onContinue = () =>\n\t\tpress(() =>\n\t\t\twidget?.current.request(\n\t\t\t\t\"fire-turn\",\n\t\t\t\tview.continueTurn.channel ? { channel: view.continueTurn.channel } : {}\n\t\t\t)\n\t\t)\n\tconst onPick = () => press(() => widget?.current.request(\"pick-turn\", {}))\n</script>\n\n{#snippet turnRow(row: TurnRowView)}\n\t<li\n\t\tdata-widget-part=\"turn-order.row row\"\n\t\tdata-state={row.state}\n\t\tdata-kind={row.kind}\n\t\tdata-channel={row.channel}\n\t\tdata-ref={row.ref ?? undefined}\n\t>\n\t\t{#if settings.faces}\n\t\t\t{#if row.face}\n\t\t\t\t<img data-widget-part=\"turn-order.face\" src={row.face} alt=\"\" />\n\t\t\t{:else}\n\t\t\t\t<span data-widget-part=\"turn-order.face\" data-blank=\"\">\n\t\t\t\t\t<sp-icon\n\t\t\t\t\t\tname={row.kind === \"voice\" ? \"book-open-text\" : row.kind === \"envoy\" ? \"sparkles\" : \"user-round\"}\n\t\t\t\t\t\tsize=\"14\"\n\t\t\t\t\t></sp-icon>\n\t\t\t\t</span>\n\t\t\t{/if}\n\t\t{/if}\n\t\t<span data-widget-part=\"turn-order.name\">{row.name}</span>\n\t\t<span data-widget-part=\"turn-order.state chip\">{row.chip}</span>\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"turn-order.root\" data-status={view.status} data-faces={settings.faces ? \"\" : undefined}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"turn-order.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if view.status !== \"empty\"}\n\t\t<p data-widget-part=\"turn-order.head\" role=\"status\">\n\t\t\t{#if view.headFace}\n\t\t\t\t<img data-widget-part=\"turn-order.face\" src={view.headFace} alt=\"\" />\n\t\t\t{:else if view.headIsVoice}\n\t\t\t\t<sp-icon name=\"book-open-text\" size=\"18\" data-widget-part=\"turn-order.voice\"></sp-icon>\n\t\t\t{/if}\n\t\t\t<span data-widget-part=\"turn-order.head-text\">{view.head}</span>\n\t\t</p>\n\n\t\t{#if view.rows.length}\n\t\t\t<ol data-widget-part=\"turn-order.list list\" aria-label={t(\"Turn order\")}>\n\t\t\t\t{#each view.rows as row (row.key)}\n\t\t\t\t\t{@render turnRow(row)}\n\t\t\t\t{/each}\n\t\t\t</ol>\n\t\t{/if}\n\t{/if}\n\n\t{#if view.benched.length}\n\t\t<!-- 🚧 W6: who is in the session but out of the turns (`showBenched`). -->\n\t\t<ul data-widget-part=\"turn-order.benched list\" aria-label={t(\"Benched\")}>\n\t\t\t{#each view.benched as row (row.key)}\n\t\t\t\t{@render turnRow(row)}\n\t\t\t{/each}\n\t\t</ul>\n\t{/if}\n\n\t<div data-widget-part=\"turn-order.controls toolbar\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"turn-order.pick\"\n\t\t\tdisabled={!view.pick.enabled}\n\t\t\ttitle={view.pick.reason ?? t(\"Pick who speaks\")}\n\t\t\tonclick={onPick}\n\t\t>\n\t\t\t<sp-icon name=\"users\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Pick who speaks\")}</span>\n\t\t</button>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"turn-order.continue\"\n\t\t\tdisabled={!view.continueTurn.enabled}\n\t\t\ttitle={view.continueTurn.reason ?? t(\"Continue\")}\n\t\t\taria-label={view.continueTurn.label}\n\t\t\tonclick={onContinue}\n\t\t>\n\t\t\t<sp-icon name=\"play\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Continue\")}</span>\n\t\t</button>\n\t</div>\n\n\t{#if view.strategy}\n\t\t<p data-widget-part=\"turn-order.strategy\">{view.strategy}</p>\n\t{/if}\n</div>\n","shared/turn-order/turn-order.ts":"/**\n * Core's `turn-order` component (PLAN-core-widgets W1): whose turn it is, who\n * follows, and Continue and Pick who speaks, as the page's UI worker runs it.\n * `npm run build` compiles it with the CLI's component bundler to\n * `dist/components/turn-order.js`, the module the app serves at\n * `/core-ui/turn-order`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport TurnOrder from './TurnOrder.svelte'\n\nexport default svelteComponent(TurnOrder)\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"4fa5ea0d028611c33b5f584ddd0c085182eb1f92c61186fed330b49809bf8b01","catalogVersion":"0.6.0-pr-9"}
@@ -79,6 +79,12 @@ export interface AnswerFormOptions {
79
79
  prompt?: {
80
80
  templateId: string;
81
81
  };
82
+ /**
83
+ * 🚧 The key of the genre's field that carries Show outcomes: the history
84
+ * read wires it as `session-history@1`'s `outcomeNumbers`. Absent, the
85
+ * read wires nothing.
86
+ */
87
+ outcomeNumbersFrom?: string;
82
88
  }
83
89
  /**
84
90
  * The pipeline, for one genre. Exported so a plugin genre can publish its own