@serene-pub/core-catalog 0.6.0-pr-8 → 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 (147) hide show
  1. package/README.md +1 -1
  2. package/components/shared/chronicle/ChronicleWidget.svelte +127 -57
  3. package/components/shared/composer/ComposerWidget.svelte +17 -5
  4. package/components/shared/composer/settings.ts +6 -2
  5. package/components/shared/composer/target.ts +19 -0
  6. package/components/shared/dialogue-box/DialogueBoxWidget.svelte +2 -2
  7. package/components/shared/lore-entries/LoreEntriesWidget.svelte +39 -35
  8. package/components/shared/messages/MessageBlocksView.svelte +1 -1
  9. package/components/shared/messages/MessageControls.svelte +21 -4
  10. package/components/shared/messages/MessagesWidget.svelte +24 -8
  11. package/components/shared/messages/NextCharacterBlock.svelte +18 -3
  12. package/components/shared/messages/SceneDivider.svelte +22 -12
  13. package/components/shared/messages/SessionComposer.svelte +67 -22
  14. package/components/shared/messages/SessionContainer.svelte +87 -32
  15. package/components/shared/messages/SessionMessage.svelte +68 -29
  16. package/components/shared/messages/SpokenLine.svelte +45 -13
  17. package/components/shared/messages/TurnLine.svelte +233 -45
  18. package/components/shared/messages/conversation.svelte.ts +30 -2
  19. package/components/shared/messages/rowFacts.ts +44 -0
  20. package/components/shared/messages/spokenLine.ts +63 -14
  21. package/components/shared/places/PlacesWidget.svelte +32 -20
  22. package/components/shared/routine-log/routineLog.ts +5 -21
  23. package/components/shared/session-runs/SessionRunsWidget.svelte +16 -12
  24. package/dist/components/actions.js +5 -5
  25. package/dist/components/actions.source.json +1 -1
  26. package/dist/components/album.js +1 -1
  27. package/dist/components/album.source.json +1 -1
  28. package/dist/components/annex.js +1 -1
  29. package/dist/components/annex.source.json +1 -1
  30. package/dist/components/attendance.js +1 -1
  31. package/dist/components/attendance.source.json +1 -1
  32. package/dist/components/authors-note.js +1 -1
  33. package/dist/components/authors-note.source.json +1 -1
  34. package/dist/components/backdrop.js +3 -3
  35. package/dist/components/backdrop.source.json +1 -1
  36. package/dist/components/chronicle.js +641 -484
  37. package/dist/components/chronicle.source.json +1 -1
  38. package/dist/components/composer.js +188 -153
  39. package/dist/components/composer.source.json +1 -1
  40. package/dist/components/core-ui.json +1 -1
  41. package/dist/components/dialogue-box.js +11 -11
  42. package/dist/components/dialogue-box.source.json +1 -1
  43. package/dist/components/lore-entries.js +101 -92
  44. package/dist/components/lore-entries.source.json +1 -1
  45. package/dist/components/messages.js +351 -275
  46. package/dist/components/messages.source.json +1 -1
  47. package/dist/components/places.js +237 -202
  48. package/dist/components/places.source.json +1 -1
  49. package/dist/components/routine-log.js +6 -17
  50. package/dist/components/routine-log.source.json +1 -1
  51. package/dist/components/scene-portraits.js +4 -4
  52. package/dist/components/scene-portraits.source.json +1 -1
  53. package/dist/components/session-runs.js +118 -211
  54. package/dist/components/session-runs.source.json +1 -1
  55. package/dist/components/{shared-OVDOAXYZ.js → shared-47J4TNSF.js} +1 -1
  56. package/dist/components/{shared-ASZVJYPD.js → shared-EFMMT76D.js} +56 -3
  57. package/dist/components/{shared-N7FFW5TX.js → shared-FOVKPMSK.js} +3 -3
  58. package/dist/components/{shared-7SWDK5MC.js → shared-HEAKNNZB.js} +4 -0
  59. package/dist/components/shared-JXP6SHKF.js +159 -0
  60. package/dist/components/{shared-TNJZHTMT.js → shared-JXYPKSTQ.js} +1 -1
  61. package/dist/components/{shared-2FMI3LEE.js → shared-KJIOSSE3.js} +2 -2
  62. package/dist/components/{shared-RQYMTMHF.js → shared-KLURQFWI.js} +2 -2
  63. package/dist/components/{shared-BR2KXM25.js → shared-MHCNUDUT.js} +96 -12
  64. package/dist/components/{shared-6S23SGJB.js → shared-NICRJ4Z2.js} +1 -1
  65. package/dist/components/{shared-M7AYID43.js → shared-W2BBJCNE.js} +7 -7
  66. package/dist/components/{shared-XJD6Y2OU.js → shared-YYYXFDZU.js} +387 -248
  67. package/dist/components/stats.js +5 -5
  68. package/dist/components/stats.source.json +1 -1
  69. package/dist/components/turn-line.js +384 -112
  70. package/dist/components/turn-line.source.json +1 -1
  71. package/dist/components/turn-order.js +4 -4
  72. package/dist/components/turn-order.source.json +1 -1
  73. package/dist/factories/answerForm.d.ts +6 -0
  74. package/dist/factories/answerForm.js +104 -96
  75. package/dist/factories/turnOrder.d.ts +84 -107
  76. package/dist/factories/turnOrder.js +89 -131
  77. package/dist/genres/chat/create.js +2 -0
  78. package/dist/genres/chat/memory.js +64 -43
  79. package/dist/genres/chat/respond.d.ts +7 -6
  80. package/dist/genres/chat/respond.js +13 -4
  81. package/dist/genres/chat/turnOrder.d.ts +2 -2
  82. package/dist/genres/chat/turnOrder.js +28 -12
  83. package/dist/genres/defaults.d.ts +8 -2
  84. package/dist/genres/defaults.js +51 -27
  85. package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
  86. package/dist/genres/dungeon-crawler/journal.js +1 -1
  87. package/dist/genres/dungeon-crawler/rest.js +5 -3
  88. package/dist/genres/dungeon-crawler/story.d.ts +2 -1
  89. package/dist/genres/dungeon-crawler/story.js +7 -4
  90. package/dist/genres/dungeon-crawler/storyScripts.js +85 -9
  91. package/dist/genres/dungeon-crawler/turnOrder.d.ts +8 -9
  92. package/dist/genres/dungeon-crawler/turnOrder.js +33 -23
  93. package/dist/genres/guide/create.js +2 -0
  94. package/dist/genres/guide/turnOrder.d.ts +3 -3
  95. package/dist/genres/guide/turnOrder.js +29 -13
  96. package/dist/genres/lair/answerForm.js +4 -1
  97. package/dist/genres/lair/buildRoom.js +4 -3
  98. package/dist/genres/lair/castellanAction.js +160 -154
  99. package/dist/genres/lair/fileCurrentRoom.js +13 -10
  100. package/dist/genres/lair/fileRoom.js +4 -3
  101. package/dist/genres/lair/keeper.js +2 -0
  102. package/dist/genres/lair/names.d.ts +2 -0
  103. package/dist/genres/lair/names.js +2 -0
  104. package/dist/genres/lair/reply.js +16 -6
  105. package/dist/genres/lair/roomAnswer.js +4 -3
  106. package/dist/genres/lair/scratchpad.js +9 -7
  107. package/dist/genres/lair/turnOrder.d.ts +3 -2
  108. package/dist/genres/lair/turnOrder.js +45 -16
  109. package/dist/genres/story/create.d.ts +1 -0
  110. package/dist/genres/story/create.js +1 -0
  111. package/dist/genres/story/reckon.js +43 -10
  112. package/dist/genres/story/turnOrder.d.ts +13 -3
  113. package/dist/genres/story/turnOrder.js +79 -22
  114. package/dist/index.js +8 -8
  115. package/dist/primers/ninth-mile.d.ts +3 -4
  116. package/dist/registry/entries.js +16 -5
  117. package/dist/registry/genres.d.ts +61 -54
  118. package/dist/registry/genres.js +123 -106
  119. package/dist/registry/widgets.js +12 -1
  120. package/dist/seed/presets.js +11 -7
  121. package/dist/seed/scripts.js +3 -0
  122. package/dist/shared/lore.d.ts +13 -0
  123. package/dist/shared/lore.js +37 -1
  124. package/dist/shared/reckoning.d.ts +7 -1
  125. package/dist/shared/reckoning.js +24 -17
  126. package/dist/shared/sceneBoundaries.js +7 -6
  127. package/dist/shared/speakMessage.d.ts +9 -2
  128. package/dist/shared/speakMessage.js +32 -9
  129. package/dist/shared/ui/chronicle/index.d.ts +7 -2
  130. package/dist/shared/ui/chronicle/index.js +21 -12
  131. package/dist/shared/ui/conversation/index.d.ts +1 -0
  132. package/dist/shared/ui/conversation/index.js +2 -0
  133. package/dist/shared/ui/conversation/messageVerbState.d.ts +5 -0
  134. package/dist/shared/ui/conversation/messageVerbState.js +3 -3
  135. package/dist/shared/ui/conversation/rewindStrip.d.ts +11 -4
  136. package/dist/shared/ui/conversation/rewindStrip.js +9 -7
  137. package/dist/shared/ui/conversation/runsInProgress.d.ts +30 -0
  138. package/dist/shared/ui/conversation/runsInProgress.js +47 -0
  139. package/dist/shared/ui/conversation/tableChannel.d.ts +8 -11
  140. package/dist/shared/ui/conversation/tableChannel.js +8 -9
  141. package/dist/shared/ui/routine-log/index.d.ts +3 -0
  142. package/dist/shared/ui/routine-log/index.js +22 -0
  143. package/dist/shared/ui/session-runs/index.d.ts +9 -1
  144. package/dist/shared/ui/session-runs/index.js +20 -14
  145. package/dist/shared/ui/turn-order/index.d.ts +0 -9
  146. package/dist/shared/ui/turn-order/index.js +1 -2
  147. package/package.json +8 -8
@@ -1 +1 @@
1
- {"slug":"chronicle","framework":"svelte","entry":"shared/chronicle/chronicle.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/chronicle/Chronicle.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Chronicle widget as a remote component (W3): the component\n\t * context, as the widget context, around `ChronicleWidget`.\n\t *\n\t * The widget asks the page only once its settings have arrived: the page\n\t * posts a widget's settings (it reads them) right after it says ready,\n\t * and an ask made before would be spent on the declared Earlier count\n\t * instead of this instance's.\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 ChronicleWidget from \"./ChronicleWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\tlet settled = $state(untrack(() => ctx.settings) !== undefined)\n\t$effect(() =>\n\t\tuntrack(() => ctx).subscribe((section) => {\n\t\t\tif (section === \"settings\") settled = true\n\t\t})\n\t)\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: \"chronicle\", instanceId: \"chronicle\", title: \"Chronicle\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><ChronicleWidget ready={settled} /></WidgetBoundary>\n","shared/chronicle/ChronicleWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Chronicle (PLAN-core-widgets W3): when are we in the story, and what\n\t * has the lorebook recorded of this session. Top to bottom: the story\n\t * clock, **Now** (the history entry the session reads), that entry's\n\t * scenes from this session, and **Earlier**, folded.\n\t *\n\t * It reads its settings, the viewer and the session; everything else is\n\t * asked of the page. One `history-entries` reads it all (the declared\n\t * `lore` scope is the grant for it), and it asks again whenever the page\n\t * says `story:moved` — a clock moved by a pipeline or the settings, an\n\t * entry added in the lorebook, a scene captured — and after each of its\n\t * own presses. The view is the plain half's (`chronicleView`); this only\n\t * draws it and presses.\n\t *\n\t * Writes are the session owner's: the clock's step, *Move the clock…*\n\t * and *Follow the line's present* (`set-story-clock`), *Start new history\n\t * entry* (`start-history-entry`, then the new entry opens in the\n\t * lorebook), *Summarize scene* (`summarize` with no lines: the\n\t * conversation's selection starts) and *Extend graph* (`extend-graph`).\n\t * A guest reads the clock alone. What the page declines is said here\n\t * (R77), never a toast.\n\t *\n\t * 🚧 Live scenes (§7, lane D): under the clock, the **Open scene** card —\n\t * its name, since when, its lines, its proposed cast with each one's\n\t * evidence, *Close scene* (`scene-close`) and *Close and summarize* (the\n\t * close, then `summarize-scenes` naming it). Each scene row carries its\n\t * summary dot (none · running · review · done · failed) and *Summarize*\n\t * (`summarize-scenes` naming it) — 🚧 or, while its finished run waits\n\t * in `review` (§15 G8), *Ready to review* (`summarize` naming the scene:\n\t * the host opens that run's review); *Summarize all (N)* asks for every\n\t * scene with no summary yet. While a scene is open it asks again when a\n\t * line arrives, so its line count keeps up.\n\t *\n\t * 🚧 ★S2-1b: under Now, **Not yet compiled** — the session's scenes no\n\t * history entry holds yet, by day (*Undated* last), each row the same as a\n\t * Scenes row; 🚧 ★S6-1 each day's **Compile** (`compile-history-entry`).\n\t *\n\t * The markup carries no look (STYLE-GUIDE §6.16): its elements carry\n\t * `chronicle.*` widget parts; a scene's colour rides on its swatch's\n\t * `data-swatch`, an entry that says nothing yet on `data-blank`. Earlier\n\t * folds in the host's accordion (`sp-accordion`), as the author's\n\t * note's Advanced does.\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { HistoryEntriesV1, StoryTime, WidgetRequests } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tchronicleClockDraft,\n\t\tchronicleClockFromDraft,\n\t\tchronicleView,\n\t\treadChronicleSettings,\n\t\ttype ChronicleClockDraft,\n\t\ttype ChronicleSceneView\n\t} from \"@serene-pub/core-catalog/chronicle\"\n\timport { useWidgetContext } from \"../context\"\n\n\t/** Whether to ask the page yet: false until the host has posted this instance's settings. */\n\tlet { ready = true }: { ready?: boolean } = $props()\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadChronicleSettings(widget?.current?.settings?.v1)\n\t)\n\t// Primitives, so a push that changes neither asks nothing again.\n\tconst earlierCount = $derived(settings.earlierCount)\n\tconst sessionId = $derived(widget?.current?.session?.v1?.id ?? null)\n\n\tlet answer = $state<HistoryEntriesV1 | null>(null)\n\t/** Why the page could not be read, or declined a press — this widget's own. */\n\tlet alert = $state<string | null>(null)\n\t/** A press in flight: its controls wait. */\n\tlet busy = $state<string | null>(null)\n\n\tconst view = $derived(chronicleView(answer, settings, widget?.current?.viewer?.v1, t))\n\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t// Which answer to show is this widget's: the latest ask's.\n\tlet asked = 0\n\tfunction ask() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tconst ticket = ++asked\n\t\tconst params: WidgetRequests[\"history-entries\"][\"params\"] = {\n\t\t\tearlierLimit: untrack(() => earlierCount)\n\t\t}\n\t\tctx.request(\"history-entries\", params).then(\n\t\t\t(res) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\tanswer = res\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\talert = t(\"Not read: {reason}\").replace(\"{reason}\", reason(e))\n\t\t\t}\n\t\t)\n\t}\n\n\t// The session, or how many earlier entries to show, moved: ask again.\n\t$effect(() => {\n\t\tif (!ready) return\n\t\tvoid sessionId\n\t\tvoid earlierCount\n\t\tuntrack(() => {\n\t\t\talert = null\n\t\t\task()\n\t\t})\n\t})\n\n\t// The story moved somewhere else (R81's shape): ask again, once per burst.\n\tlet timer: ReturnType<typeof setTimeout> | undefined\n\t$effect(() =>\n\t\tuntrack(() => {\n\t\t\tconst off = widget?.current?.on(\"story:moved\", () => {\n\t\t\t\tclearTimeout(timer)\n\t\t\t\ttimer = setTimeout(() => ready && ask(), 150)\n\t\t\t})\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(timer)\n\t\t\t\toff?.()\n\t\t\t}\n\t\t})\n\t)\n\n\t/** Press `kind` with `params`; the page's refusal is this widget's line. */\n\tasync function press<K extends keyof WidgetRequests>(\n\t\tname: string,\n\t\tkind: K,\n\t\tparams: WidgetRequests[K][\"params\"]\n\t): Promise<WidgetRequests[K][\"result\"] | undefined> {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx || busy) return undefined\n\t\tbusy = name\n\t\talert = null\n\t\ttry {\n\t\t\treturn await ctx.request(kind, params)\n\t\t} catch (e) {\n\t\t\talert = t(\"Not done: {reason}\").replace(\"{reason}\", reason(e))\n\t\t\treturn undefined\n\t\t} finally {\n\t\t\tbusy = null\n\t\t}\n\t}\n\n\t// A line arrived while a scene is open: its count moved. Asked again\n\t// once per burst, and only while the card is showing.\n\tlet lineTimer: ReturnType<typeof setTimeout> | undefined\n\t$effect(() =>\n\t\tuntrack(() => {\n\t\t\tconst off = widget?.current?.on(\"message:created\", () => {\n\t\t\t\tif (!answer?.openScene) return\n\t\t\t\tclearTimeout(lineTimer)\n\t\t\t\tlineTimer = setTimeout(() => ready && ask(), 800)\n\t\t\t})\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(lineTimer)\n\t\t\t\toff?.()\n\t\t\t}\n\t\t})\n\t)\n\n\t// ── the open scene and the summaries (live scenes §7) ──────────────────\n\t/** Close the open scene; with `summarize`, then summarize it in the background. */\n\tasync function closeOpenScene(sceneId: number, summarize: boolean) {\n\t\tconst closed = await press(summarize ? \"close-summarize\" : \"close\", \"scene-close\", { sceneId })\n\t\tif (!closed) return\n\t\tif (summarize) await press(\"summarize\", \"summarize-scenes\", { sceneIds: [sceneId] })\n\t\task()\n\t}\n\n\t/** Summarize `sceneIds` in the background — or, with none, every scene with no summary yet. */\n\tasync function summarizeScenes(sceneIds?: number[]) {\n\t\tconst done = await press(\"summarize\", \"summarize-scenes\", sceneIds ? { sceneIds } : {})\n\t\tif (done) ask()\n\t}\n\n\t/** 🚧 ★S6-1: compile one day's scenes not yet compiled (null = Undated); the run shows in the activity list. */\n\tasync function compileDay(date: StoryTime | null) {\n\t\tawait press(\"compile\", \"compile-history-entry\", { date })\n\t}\n\n\t// ── the clock ────────────────────────────────────────────────────────────\n\tlet moving = $state(false)\n\tlet draft = $state<ChronicleClockDraft>(chronicleClockDraft(null))\n\tlet formProblem = $state<string | null>(null)\n\n\tfunction openMove() {\n\t\tdraft = chronicleClockDraft(answer?.clock.present)\n\t\tformProblem = null\n\t\tmoving = !moving\n\t}\n\n\tasync function moveClock(params: WidgetRequests[\"set-story-clock\"][\"params\"], name: string) {\n\t\tconst clock = await press(name, \"set-story-clock\", params)\n\t\tif (!clock) return false\n\t\tif (answer) answer = { ...answer, clock }\n\t\task()\n\t\treturn true\n\t}\n\n\t/** Set the clock to the form's date (Set the clock, or Enter in a field). */\n\tasync function submitMove() {\n\t\tconst read = chronicleClockFromDraft(draft)\n\t\tif (read.problem !== undefined) {\n\t\t\tformProblem = t(read.problem)\n\t\t\treturn\n\t\t}\n\t\tformProblem = null\n\t\tif (await moveClock({ to: read.to }, \"move\")) moving = false\n\t}\n\n\tconst FIELDS: { key: keyof ChronicleClockDraft; label: string }[] = [\n\t\t{ key: \"year\", label: \"Year\" },\n\t\t{ key: \"month\", label: \"Month\" },\n\t\t{ key: \"day\", label: \"Day\" },\n\t\t{ key: \"hour\", label: \"Hour\" },\n\t\t{ key: \"minute\", label: \"Minute\" }\n\t]\n\n\t// ── the entries and scenes ───────────────────────────────────────────────\n\tfunction openEntry(entryId?: number) {\n\t\tconst lorebookId = answer?.lorebookId ?? undefined\n\t\tvoid press(\"open\", \"open-lore\", {\n\t\t\t...(lorebookId != null ? { lorebookId } : {}),\n\t\t\tscope: \"history\",\n\t\t\t...(entryId != null ? { entryId } : {})\n\t\t})\n\t}\n\n\tfunction openScene(sceneId: number) {\n\t\tconst lorebookId = answer?.lorebookId ?? undefined\n\t\tvoid press(\"open\", \"open-lore\", {\n\t\t\t...(lorebookId != null ? { lorebookId } : {}),\n\t\t\tscope: \"scenes\",\n\t\t\tsceneId\n\t\t})\n\t}\n\n\tasync function startEntry() {\n\t\tconst made = await press(\"start\", \"start-history-entry\", {})\n\t\tif (!made) return\n\t\task()\n\t\t// The new entry opens in the lorebook, ready to write — the pane's\n\t\t// old behaviour, and only for the press made here.\n\t\topenEntry(made.entryId)\n\t}\n</script>\n\n{#snippet sceneRow(s: ChronicleSceneView)}\n\t<li\n\t\tdata-widget-part=\"chronicle.scene row\"\n\t\tdata-scene-id={s.id}\n\t\tdata-open={s.open ? \"\" : undefined}\n\t>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"chronicle.scene-open\"\n\t\t\ttitle={t(\"Open in lorebook\")}\n\t\t\tonclick={() => openScene(s.id)}\n\t\t>\n\t\t\t<span data-widget-part=\"chronicle.scene-swatch\" data-swatch={s.swatch}></span>\n\t\t\t<span data-widget-part=\"chronicle.scene-name\">{s.name}</span>\n\t\t\t<span data-widget-part=\"chronicle.scene-span\">{s.span}</span>\n\t\t\t<span\n\t\t\t\tdata-widget-part=\"chronicle.scene-status\"\n\t\t\t\tdata-status={s.status}\n\t\t\t\trole=\"img\"\n\t\t\t\taria-label={s.statusLabel}\n\t\t\t\ttitle={s.statusLabel}\n\t\t\t></span>\n\t\t</button>\n\t\t{#if s.canSummarize}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"chronicle.scene-summarize\"\n\t\t\t\ttitle={t(\"Summarize this scene in the background\")}\n\t\t\t\tdisabled={!!busy}\n\t\t\t\tonclick={() => summarizeScenes([s.id])}\n\t\t\t>\n\t\t\t\t{t(\"Summarize\")}\n\t\t\t</button>\n\t\t{:else if s.canReview}\n\t\t\t<!-- 🚧 §15 G8: the run finished; its review opens in the host. -->\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"chronicle.scene-summarize chronicle.scene-review\"\n\t\t\t\ttitle={t(\"Its summary is ready: open the review to apply or discard it\")}\n\t\t\t\tdisabled={!!busy}\n\t\t\t\tonclick={() => press(\"review\", \"summarize\", { kind: \"scene\", sceneId: s.id })}\n\t\t\t>\n\t\t\t\t{t(\"Ready to review\")}\n\t\t\t</button>\n\t\t{:else if s.status === \"running\"}\n\t\t\t<!-- The run in words where its Summarize was, as the conversation's\n\t\t\t divider says it: the dot alone is too small to notice. -->\n\t\t\t<span data-widget-part=\"chronicle.scene-running\" role=\"status\">{s.statusLabel}</span>\n\t\t{/if}\n\t\t{#if s.writtenFrom}\n\t\t\t<p data-widget-part=\"chronicle.scene-written-from\">{s.writtenFrom}</p>\n\t\t{/if}\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"chronicle.root\" data-widget=\"chronicle\" data-state={view.state}>\n\t{#if view.state !== \"no-book\"}\n\t\t{#if alert}\n\t\t\t<p data-widget-part=\"chronicle.alert\" role=\"alert\">{alert}</p>\n\t\t{/if}\n\n\t\t{#if view.clock}\n\t\t\t<section data-widget-part=\"chronicle.clock\" aria-label={t(\"Story clock\")}>\n\t\t\t\t<div data-widget-part=\"chronicle.clock-head\">\n\t\t\t\t\t<span data-widget-part=\"chronicle.clock-date\">{view.clock.date}</span>\n\t\t\t\t\t{#if view.clock.behind}\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.behind chip\" title={view.clock.behindTitle}>\n\t\t\t\t\t\t\t{view.clock.behind}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t\t<p data-widget-part=\"chronicle.clock-note\">{view.clock.note}</p>\n\t\t\t\t{#if view.clock.canMove}\n\t\t\t\t\t<div data-widget-part=\"chronicle.clock-controls toolbar\">\n\t\t\t\t\t\t{#if view.clock.step}\n\t\t\t\t\t\t\t{@const step = view.clock.step}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.step\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => moveClock({ by: step.by, unit: step.unit }, \"step\")}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<sp-icon name=\"chevron-right\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t{step.label}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{/if}\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=\"chronicle.move\"\n\t\t\t\t\t\t\taria-expanded={moving}\n\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\tonclick={openMove}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"calendar-clock\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t{t(\"Move the clock…\")}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{#if view.clock.canFollow}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.follow\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => moveClock({ follow: true }, \"follow\")}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(\"Follow the line's present\")}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\t\t\t\t\t{#if moving}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tid=\"{uid}-move\"\n\t\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\t\taria-label={t(\"Move the clock\")}\n\t\t\t\t\t\t\tdata-widget-part=\"chronicle.move-form\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.fields\">\n\t\t\t\t\t\t\t\t{#each FIELDS as f (f.key)}\n\t\t\t\t\t\t\t\t\t<label data-widget-part=\"chronicle.field\">\n\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.field-label label\">{t(f.label)}</span>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.field-input\"\n\t\t\t\t\t\t\t\t\t\t\tname={f.key}\n\t\t\t\t\t\t\t\t\t\t\tvalue={draft[f.key]}\n\t\t\t\t\t\t\t\t\t\t\toninput={(e) => (draft = { ...draft, [f.key]: e.currentTarget.value })}\n\t\t\t\t\t\t\t\t\t\t\tonkeydown={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (e.key === \"Enter\") {\n\t\t\t\t\t\t\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\t\t\t\t\t\t\tvoid submitMove()\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{#if formProblem}\n\t\t\t\t\t\t\t\t<p data-widget-part=\"chronicle.alert\" role=\"alert\">{formProblem}</p>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.form-actions toolbar\">\n\t\t\t\t\t\t\t\t<button type=\"button\" data-widget-part=\"chronicle.cancel\" onclick={() => (moving = false)}>\n\t\t\t\t\t\t\t\t\t{t(\"Cancel\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.save\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={submitMove}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{t(\"Set the clock\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t{/if}\n\t\t\t</section>\n\t\t{/if}\n\n\t\t{#if view.ownerOnly}\n\t\t\t<p data-widget-part=\"chronicle.note\">{view.ownerOnly}</p>\n\t\t{:else if view.state === \"ready\"}\n\t\t\t{#if view.openScene}\n\t\t\t\t{@const open = view.openScene}\n\t\t\t\t<section\n\t\t\t\t\tdata-widget-part=\"chronicle.open-scene card\"\n\t\t\t\t\tdata-scene-id={open.id}\n\t\t\t\t\taria-labelledby=\"{uid}-open-scene\"\n\t\t\t\t>\n\t\t\t\t\t<h3 id=\"{uid}-open-scene\" data-widget-part=\"chronicle.heading label\">{t(\"Open scene\")}</h3>\n\t\t\t\t\t<div data-widget-part=\"chronicle.open-scene-head\">\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.scene-swatch\" data-swatch={open.swatch}></span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.open-scene-name\">{open.name}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<p data-widget-part=\"chronicle.open-scene-meta\">\n\t\t\t\t\t\t{#if open.since}<span data-widget-part=\"chronicle.open-scene-since\">{open.since}</span>{/if}\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.scene-span\">{open.span}</span>\n\t\t\t\t\t</p>\n\t\t\t\t\t{#if open.cast.length}\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.cast list\" aria-label={t(\"Proposed cast\")}>\n\t\t\t\t\t\t\t{#each open.cast as member, i (i)}\n\t\t\t\t\t\t\t\t<!-- Why they're proposed is the name's tooltip, in words (2026-11-06);\n\t\t\t\t\t\t\t\t never printed beside the name. -->\n\t\t\t\t\t\t\t\t<li data-widget-part=\"chronicle.cast-member chip\" title={member.evidence || undefined}>\n\t\t\t\t\t\t\t\t\t{member.name}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if open.canClose}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.open-scene-actions toolbar\">\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.close\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => closeOpenScene(open.id, false)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<sp-icon name=\"flag-off\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t{t(\"Close scene\")}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{#if open.canCloseAndSummarize}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.close-summarize\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => closeOpenScene(open.id, true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{t(\"Close and summarize\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if open.note}\n\t\t\t\t\t\t<p data-widget-part=\"chronicle.open-scene-note\">{open.note}</p>\n\t\t\t\t\t{/if}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t<section data-widget-part=\"chronicle.now\" aria-labelledby=\"{uid}-now\">\n\t\t\t\t<h3 id=\"{uid}-now\" data-widget-part=\"chronicle.heading label\">{t(\"Now\")}</h3>\n\t\t\t\t{#if view.now}\n\t\t\t\t\t<div data-widget-part=\"chronicle.entry card\" data-entry-id={view.now.id}>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-date\">{view.now.date}</span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-line\" data-blank={view.now.blank ? \"\" : undefined}>\n\t\t\t\t\t\t\t{view.now.firstLine}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-scenes\">{view.now.scenes}</span>\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t\t<div data-widget-part=\"chronicle.toolbar toolbar\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tdata-widget-part=\"chronicle.open\"\n\t\t\t\t\t\tonclick={() => openEntry(view.now?.id)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<sp-icon name=\"external-link\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t{t(\"Open in lorebook\")}\n\t\t\t\t\t</button>\n\t\t\t\t\t{#if view.canWrite && view.now}\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=\"chronicle.start\"\n\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\tonclick={startEntry}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"plus\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t{t(\"Start new history entry\")}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t</section>\n\n\t\t\t{#if view.now}\n\t\t\t\t<section data-widget-part=\"chronicle.scenes\" aria-labelledby=\"{uid}-scenes\">\n\t\t\t\t\t<h3 id=\"{uid}-scenes\" data-widget-part=\"chronicle.heading label\">{t(\"Scenes\")}</h3>\n\t\t\t\t\t{#if view.scenes.length}\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.scene-list list\">\n\t\t\t\t\t\t\t{#each view.scenes as s (s.id)}\n\t\t\t\t\t\t\t\t{@render sceneRow(s)}\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if view.canSummarize || view.extend || view.summarizeAll}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.scene-actions toolbar\">\n\t\t\t\t\t\t\t{#if view.canSummarize}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.summarize\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => press(\"summarize\", \"summarize\", { kind: \"scene\" })}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{t(\"Summarize scene\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{#if view.summarizeAll}\n\t\t\t\t\t\t\t\t{@const all = view.summarizeAll}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.summarize-all\"\n\t\t\t\t\t\t\t\t\ttitle={all.title}\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => summarizeScenes()}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{all.label}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{#if view.extend}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.extend\"\n\t\t\t\t\t\t\t\t\ttitle={view.extend.title}\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => press(\"extend\", \"extend-graph\", {})}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"network\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{view.extend.label}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if view.unfiled.length}\n\t\t\t\t<section data-widget-part=\"chronicle.unfiled\" aria-labelledby=\"{uid}-unfiled\">\n\t\t\t\t\t<h3 id=\"{uid}-unfiled\" data-widget-part=\"chronicle.heading label\">{t(\"Not yet compiled\")}</h3>\n\t\t\t\t\t{#each view.unfiled as day (day.key)}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.unfiled-day\" role=\"group\" aria-label={day.date}>\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.unfiled-day-head\">\n\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.unfiled-date\">{day.date}</span>\n\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.unfiled-count\">{day.count}</span>\n\t\t\t\t\t\t\t\t{#if day.compile}\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.unfiled-compile\"\n\t\t\t\t\t\t\t\t\t\ttitle={day.compile.title}\n\t\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\t\tonclick={() => compileDay(day.compile!.date)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<sp-icon name=\"wand\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t\t{day.compile.label}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<ul data-widget-part=\"chronicle.scene-list list\">\n\t\t\t\t\t\t\t\t{#each day.scenes as s (s.id)}{@render sceneRow(s)}{/each}\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/each}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if view.earlierHead}\n\t\t\t\t<!-- Folded: the host's accordion, its trigger the head (*Earlier (N)*). -->\n\t\t\t\t<sp-accordion data-widget-part=\"chronicle.earlier\" value=\"\">\n\t\t\t\t\t<sp-accordion-item value=\"earlier\" heading={view.earlierHead} level=\"3\">\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.earlier-list list\">\n\t\t\t\t\t\t\t{#each view.earlier as e (e.id)}\n\t\t\t\t\t\t\t\t<li data-widget-part=\"chronicle.earlier-row row\" data-entry-id={e.id}>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.earlier-entry\"\n\t\t\t\t\t\t\t\t\t\ttitle={t(\"Open in lorebook\")}\n\t\t\t\t\t\t\t\t\t\tonclick={() => openEntry(e.id)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-date\">{e.date}</span>\n\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-line\" data-blank={e.blank ? \"\" : undefined}>\n\t\t\t\t\t\t\t\t\t\t\t{e.firstLine}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-scenes\">{e.scenes}</span>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t{#if view.earlierMore}\n\t\t\t\t\t\t\t<p data-widget-part=\"chronicle.earlier-more\">{view.earlierMore}</p>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</sp-accordion-item>\n\t\t\t\t</sp-accordion>\n\t\t\t{/if}\n\t\t{/if}\n\t{/if}\n</div>\n","shared/chronicle/chronicle.ts":"/**\n * Core's `chronicle` component (PLAN-core-widgets W3): the session's story\n * clock, the history entry it reads now with this session's scenes under\n * it, and the entries before. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/chronicle.js`, the module the app\n * serves at `/core-ui/chronicle`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Chronicle from './Chronicle.svelte'\n\nexport default svelteComponent(Chronicle)\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/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":"4a4e70f777b4fdc1aff3f97553b71e2be6379d6c6334295a801a7689c410596a","catalogVersion":"0.6.0-pr-8"}
1
+ {"slug":"chronicle","framework":"svelte","entry":"shared/chronicle/chronicle.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/chronicle/Chronicle.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Chronicle widget as a remote component (W3): the component\n\t * context, as the widget context, around `ChronicleWidget`.\n\t *\n\t * The widget asks the page only once its settings have arrived: the page\n\t * posts a widget's settings (it reads them) right after it says ready,\n\t * and an ask made before would be spent on the declared Earlier count\n\t * instead of this instance's.\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 ChronicleWidget from \"./ChronicleWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\tlet settled = $state(untrack(() => ctx.settings) !== undefined)\n\t$effect(() =>\n\t\tuntrack(() => ctx).subscribe((section) => {\n\t\t\tif (section === \"settings\") settled = true\n\t\t})\n\t)\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: \"chronicle\", instanceId: \"chronicle\", title: \"Chronicle\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><ChronicleWidget ready={settled} /></WidgetBoundary>\n","shared/chronicle/ChronicleWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Chronicle (PLAN-core-widgets W3): when are we in the story, and what\n\t * has the lorebook recorded of this session. Top to bottom: the story\n\t * clock, **Now** (the history entry the session reads), that entry's\n\t * scenes from this session, and **Earlier**, folded.\n\t *\n\t * It reads its settings, the viewer and the session; everything else is\n\t * asked of the page. One `history-entries` reads it all (the declared\n\t * `lore` scope is the grant for it), and it asks again whenever the page\n\t * says `story:moved` — a clock moved by a pipeline or the settings, an\n\t * entry added in the lorebook, a scene captured — and after each of its\n\t * own presses. The view is the plain half's (`chronicleView`); this only\n\t * draws it and presses.\n\t *\n\t * Writes are the session owner's: the clock's step, *Move the clock…*\n\t * and *Follow the line's present* (`set-story-clock`), *Start new history\n\t * entry* (`start-history-entry`, then the new entry opens in the\n\t * lorebook), *Summarize scene* (`summarize` with no lines: the\n\t * conversation's selection starts) and *Extend graph* (`extend-graph`).\n\t * A guest reads the clock alone. What the page declines is said here\n\t * (R77), never a toast.\n\t *\n\t * 🚧 Live scenes (§7, lane D): under the clock, the **Open scene** card —\n\t * its name, since when, its lines, its proposed cast with each one's\n\t * evidence, *Close scene* (`scene-close`) and *Close and summarize* (the\n\t * close, then `summarize-scenes` naming it). Each scene row carries its\n\t * summary dot (none · running · review · done · failed) and *Summarize*\n\t * (`summarize-scenes` naming it) — 🚧 or, while its finished run waits\n\t * in `review` (§15 G8), *Ready to review* (`summarize` naming the scene:\n\t * the host opens that run's review); *Summarize all (N)* asks for every\n\t * scene with no summary yet. While a scene is open it asks again when a\n\t * line arrives, so its line count keeps up.\n\t *\n\t * 🚧 ★S2-1b: under Now, **Not yet compiled** — the session's scenes no\n\t * history entry holds yet, by day (*Undated* last), each row the same as a\n\t * Scenes row; 🚧 ★S6-1 each day's **Compile** (`compile-history-entry`).\n\t *\n\t * 🚧 A lorebook with no timeline (owner 2026-11-15, ★T-C6; `timeline`\n\t * false): no clock, no Now, no Earlier and no days — the session's scenes\n\t * (all of them, in played order) and its open scene stay, and a note says\n\t * why in the clock's place.\n\t *\n\t * The markup carries no look (STYLE-GUIDE §6.16): its elements carry\n\t * `chronicle.*` widget parts; a scene's colour rides on its swatch's\n\t * `data-swatch`, an entry that says nothing yet on `data-blank`. Earlier\n\t * folds in the host's accordion (`sp-accordion`), as the author's\n\t * note's Advanced does.\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { HistoryEntriesV1, StoryTime, WidgetRequests } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tchronicleClockDraft,\n\t\tchronicleClockFromDraft,\n\t\tchronicleView,\n\t\treadChronicleSettings,\n\t\ttype ChronicleClockDraft,\n\t\ttype ChronicleSceneView\n\t} from \"@serene-pub/core-catalog/chronicle\"\n\timport { useWidgetContext } from \"../context\"\n\n\t/** Whether to ask the page yet: false until the host has posted this instance's settings. */\n\tlet { ready = true }: { ready?: boolean } = $props()\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadChronicleSettings(widget?.current?.settings?.v1)\n\t)\n\t// Primitives, so a push that changes neither asks nothing again.\n\tconst earlierCount = $derived(settings.earlierCount)\n\tconst sessionId = $derived(widget?.current?.session?.v1?.id ?? null)\n\n\tlet answer = $state<HistoryEntriesV1 | null>(null)\n\t/** Why the page could not be read, or declined a press — this widget's own. */\n\tlet alert = $state<string | null>(null)\n\t/** A press in flight: its controls wait. */\n\tlet busy = $state<string | null>(null)\n\n\tconst timeless = $derived(answer?.timeline === false)\n\tconst view = $derived(chronicleView(answer, settings, widget?.current?.viewer?.v1, t))\n\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t// Which answer to show is this widget's: the latest ask's.\n\tlet asked = 0\n\tfunction ask() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tconst ticket = ++asked\n\t\tconst params: WidgetRequests[\"history-entries\"][\"params\"] = {\n\t\t\tearlierLimit: untrack(() => earlierCount)\n\t\t}\n\t\tctx.request(\"history-entries\", params).then(\n\t\t\t(res) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\tanswer = res\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\talert = t(\"Not read: {reason}\").replace(\"{reason}\", reason(e))\n\t\t\t}\n\t\t)\n\t}\n\n\t// The session, or how many earlier entries to show, moved: ask again.\n\t$effect(() => {\n\t\tif (!ready) return\n\t\tvoid sessionId\n\t\tvoid earlierCount\n\t\tuntrack(() => {\n\t\t\talert = null\n\t\t\task()\n\t\t})\n\t})\n\n\t// The story moved somewhere else (R81's shape): ask again, once per burst.\n\tlet timer: ReturnType<typeof setTimeout> | undefined\n\t$effect(() =>\n\t\tuntrack(() => {\n\t\t\tconst off = widget?.current?.on(\"story:moved\", () => {\n\t\t\t\tclearTimeout(timer)\n\t\t\t\ttimer = setTimeout(() => ready && ask(), 150)\n\t\t\t})\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(timer)\n\t\t\t\toff?.()\n\t\t\t}\n\t\t})\n\t)\n\n\t/** Press `kind` with `params`; the page's refusal is this widget's line. */\n\tasync function press<K extends keyof WidgetRequests>(\n\t\tname: string,\n\t\tkind: K,\n\t\tparams: WidgetRequests[K][\"params\"]\n\t): Promise<WidgetRequests[K][\"result\"] | undefined> {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx || busy) return undefined\n\t\tbusy = name\n\t\talert = null\n\t\ttry {\n\t\t\treturn await ctx.request(kind, params)\n\t\t} catch (e) {\n\t\t\talert = t(\"Not done: {reason}\").replace(\"{reason}\", reason(e))\n\t\t\treturn undefined\n\t\t} finally {\n\t\t\tbusy = null\n\t\t}\n\t}\n\n\t// A line arrived while a scene is open: its count moved. Asked again\n\t// once per burst, and only while the card is showing.\n\tlet lineTimer: ReturnType<typeof setTimeout> | undefined\n\t$effect(() =>\n\t\tuntrack(() => {\n\t\t\tconst off = widget?.current?.on(\"message:created\", () => {\n\t\t\t\tif (!answer?.openScene) return\n\t\t\t\tclearTimeout(lineTimer)\n\t\t\t\tlineTimer = setTimeout(() => ready && ask(), 800)\n\t\t\t})\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(lineTimer)\n\t\t\t\toff?.()\n\t\t\t}\n\t\t})\n\t)\n\n\t// ── the open scene and the summaries (live scenes §7) ──────────────────\n\t/** Close the open scene; with `summarize`, then summarize it in the background. */\n\tasync function closeOpenScene(sceneId: number, summarize: boolean) {\n\t\tconst closed = await press(summarize ? \"close-summarize\" : \"close\", \"scene-close\", { sceneId })\n\t\tif (!closed) return\n\t\tif (summarize) await press(\"summarize\", \"summarize-scenes\", { sceneIds: [sceneId] })\n\t\task()\n\t}\n\n\t/** Summarize `sceneIds` in the background — or, with none, every scene with no summary yet. */\n\tasync function summarizeScenes(sceneIds?: number[]) {\n\t\tconst done = await press(\"summarize\", \"summarize-scenes\", sceneIds ? { sceneIds } : {})\n\t\tif (done) ask()\n\t}\n\n\t/** 🚧 ★S6-1: compile one day's scenes not yet compiled (null = Undated); the run shows in the activity list. */\n\tasync function compileDay(date: StoryTime | null) {\n\t\tawait press(\"compile\", \"compile-history-entry\", { date })\n\t}\n\n\t// ── the clock ────────────────────────────────────────────────────────────\n\tlet moving = $state(false)\n\tlet draft = $state<ChronicleClockDraft>(chronicleClockDraft(null))\n\tlet formProblem = $state<string | null>(null)\n\n\tfunction openMove() {\n\t\tdraft = chronicleClockDraft(answer?.clock.present)\n\t\tformProblem = null\n\t\tmoving = !moving\n\t}\n\n\tasync function moveClock(params: WidgetRequests[\"set-story-clock\"][\"params\"], name: string) {\n\t\tconst clock = await press(name, \"set-story-clock\", params)\n\t\tif (!clock) return false\n\t\tif (answer) answer = { ...answer, clock }\n\t\task()\n\t\treturn true\n\t}\n\n\t/** Set the clock to the form's date (Set the clock, or Enter in a field). */\n\tasync function submitMove() {\n\t\t// A part not drawn stays in the draft but is not read.\n\t\tconst read = chronicleClockFromDraft({\n\t\t\t...draft,\n\t\t\tday: draft.month.trim() === \"\" ? \"\" : draft.day,\n\t\t\tminute: draft.hour.trim() === \"\" ? \"\" : draft.minute\n\t\t})\n\t\tif (read.problem !== undefined) {\n\t\t\tformProblem = t(read.problem)\n\t\t\treturn\n\t\t}\n\t\tformProblem = null\n\t\tif (await moveClock({ to: read.to }, \"move\")) moving = false\n\t}\n\n\tconst FIELDS: { key: keyof ChronicleClockDraft; label: string }[] = [\n\t\t{ key: \"year\", label: \"Year\" },\n\t\t{ key: \"month\", label: \"Month\" },\n\t\t{ key: \"day\", label: \"Day\" },\n\t\t{ key: \"hour\", label: \"Hour\" },\n\t\t{ key: \"minute\", label: \"Minute\" }\n\t]\n\n\t// ── the entries and scenes ───────────────────────────────────────────────\n\t/** The session's notes are the owner's: a guest reads the Chronicle and opens none of it. */\n\tconst canOpen = $derived(widget?.current?.viewer?.v1?.isGuest !== true)\n\n\tfunction openEntry(entryId?: number) {\n\t\tconst lorebookId = answer?.lorebookId ?? undefined\n\t\tvoid press(\"open\", \"open-lore\", {\n\t\t\t...(lorebookId != null ? { lorebookId } : {}),\n\t\t\tscope: \"history\",\n\t\t\t...(entryId != null ? { entryId } : {})\n\t\t})\n\t}\n\n\tfunction openScene(sceneId: number) {\n\t\tconst lorebookId = answer?.lorebookId ?? undefined\n\t\tvoid press(\"open\", \"open-lore\", {\n\t\t\t...(lorebookId != null ? { lorebookId } : {}),\n\t\t\tscope: \"scenes\",\n\t\t\tsceneId\n\t\t})\n\t}\n\n\tfunction openScenes() {\n\t\tconst lorebookId = answer?.lorebookId ?? undefined\n\t\tvoid press(\"open\", \"open-lore\", {\n\t\t\t...(lorebookId != null ? { lorebookId } : {}),\n\t\t\tscope: \"scenes\"\n\t\t})\n\t}\n\n\tasync function startEntry() {\n\t\tconst made = await press(\"start\", \"start-history-entry\", {})\n\t\tif (!made) return\n\t\task()\n\t\t// The new entry opens in the lorebook, ready to write — the pane's\n\t\t// old behaviour, and only for the press made here.\n\t\topenEntry(made.entryId)\n\t}\n</script>\n\n{#snippet sceneOpenBody(s: ChronicleSceneView)}\n\t<span data-widget-part=\"chronicle.scene-swatch\" data-swatch={s.swatch}></span>\n\t<span data-widget-part=\"chronicle.scene-name\">{s.name}</span>\n\t<span data-widget-part=\"chronicle.scene-span\">{s.span}</span>\n\t<span\n\t\tdata-widget-part=\"chronicle.scene-status\"\n\t\tdata-status={s.status}\n\t\trole=\"img\"\n\t\taria-label={s.statusLabel}\n\t\ttitle={s.statusLabel}\n\t></span>\n{/snippet}\n\n{#snippet earlierBody(e: (typeof view.earlier)[number])}\n\t<span data-widget-part=\"chronicle.entry-date\">{e.date}</span>\n\t<span data-widget-part=\"chronicle.entry-line\" data-blank={e.blank ? \"\" : undefined}>\n\t\t{e.firstLine}\n\t</span>\n\t<span data-widget-part=\"chronicle.entry-scenes\">{e.scenes}</span>\n{/snippet}\n\n{#snippet sceneRow(s: ChronicleSceneView)}\n\t<li\n\t\tdata-widget-part=\"chronicle.scene row\"\n\t\tdata-scene-id={s.id}\n\t\tdata-open={s.open ? \"\" : undefined}\n\t>\n\t\t{#if canOpen}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"chronicle.scene-open\"\n\t\t\t\ttitle={t(\"Open in lorebook\")}\n\t\t\t\tonclick={() => openScene(s.id)}\n\t\t\t>\n\t\t\t\t{@render sceneOpenBody(s)}\n\t\t\t</button>\n\t\t{:else}\n\t\t\t<span data-widget-part=\"chronicle.scene-open\">{@render sceneOpenBody(s)}</span>\n\t\t{/if}\n\t\t{#if s.canSummarize}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"chronicle.scene-summarize\"\n\t\t\t\ttitle={t(\"Summarize this scene in the background\")}\n\t\t\t\tdisabled={!!busy}\n\t\t\t\tonclick={() => summarizeScenes([s.id])}\n\t\t\t>\n\t\t\t\t{t(\"Summarize\")}\n\t\t\t</button>\n\t\t{:else if s.canReview}\n\t\t\t<!-- 🚧 §15 G8: the run finished; its review opens in the host. -->\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"chronicle.scene-summarize chronicle.scene-review\"\n\t\t\t\ttitle={t(\"Its summary is ready: open the review to apply or discard it\")}\n\t\t\t\tdisabled={!!busy}\n\t\t\t\tonclick={() => press(\"review\", \"summarize\", { kind: \"scene\", sceneId: s.id })}\n\t\t\t>\n\t\t\t\t{t(\"Ready to review\")}\n\t\t\t</button>\n\t\t{:else if s.status === \"running\"}\n\t\t\t<!-- The run in words where its Summarize was, as the conversation's\n\t\t\t divider says it: the dot alone is too small to notice. -->\n\t\t\t<span data-widget-part=\"chronicle.scene-running\" role=\"status\">{s.statusLabel}</span>\n\t\t{/if}\n\t\t{#if s.writtenFrom}\n\t\t\t<p data-widget-part=\"chronicle.scene-written-from\">{s.writtenFrom}</p>\n\t\t{/if}\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"chronicle.root\" data-widget=\"chronicle\" data-state={view.state}>\n\t{#if view.state !== \"no-book\"}\n\t\t{#if alert}\n\t\t\t<p data-widget-part=\"chronicle.alert\" role=\"alert\">{alert}</p>\n\t\t{/if}\n\n\t\t{#if timeless}\n\t\t\t<p data-widget-part=\"chronicle.note\">{t(\"This lorebook keeps no timeline, so there are no story dates here.\")}</p>\n\t\t{:else if view.clock}\n\t\t\t<section data-widget-part=\"chronicle.clock\" aria-label={t(\"Story clock\")}>\n\t\t\t\t<div data-widget-part=\"chronicle.clock-head\">\n\t\t\t\t\t<span data-widget-part=\"chronicle.clock-date\">{view.clock.date}</span>\n\t\t\t\t\t{#if view.clock.behind}\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.behind chip\" title={view.clock.behindTitle}>\n\t\t\t\t\t\t\t{view.clock.behind}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t\t<p data-widget-part=\"chronicle.clock-note\">{view.clock.note}</p>\n\t\t\t\t{#if view.clock.canMove}\n\t\t\t\t\t<div data-widget-part=\"chronicle.clock-controls toolbar\">\n\t\t\t\t\t\t{#if view.clock.step}\n\t\t\t\t\t\t\t{@const step = view.clock.step}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.step\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => moveClock({ by: step.by, unit: step.unit }, \"step\")}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<sp-icon name=\"chevron-right\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t{step.label}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{/if}\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=\"chronicle.move\"\n\t\t\t\t\t\t\taria-expanded={moving}\n\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\tonclick={openMove}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"calendar-clock\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t{t(\"Move the clock…\")}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{#if view.clock.canFollow}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.follow\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => moveClock({ follow: true }, \"follow\")}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(\"Follow the line's present\")}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\t\t\t\t\t{#if moving}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tid=\"{uid}-move\"\n\t\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\t\taria-label={t(\"Move the clock\")}\n\t\t\t\t\t\t\tdata-widget-part=\"chronicle.move-form\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.fields\">\n\t\t\t\t\t\t\t\t{#each FIELDS as f (f.key)}\n\t\t\t\t\t\t\t\t\t{#if (f.key !== \"day\" || draft.month.trim() !== \"\") && (f.key !== \"minute\" || draft.hour.trim() !== \"\")}\n\t\t\t\t\t\t\t\t\t\t{#if f.key === \"month\" && answer?.clock.months?.length}\n\t\t\t\t\t\t\t\t\t\t\t<!-- The combobox draws its own label. -->\n\t\t\t\t\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.field\">\n\t\t\t\t\t\t\t\t\t\t\t\t<sp-combobox\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.field-input\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={t(f.label)}\n\t\t\t\t\t\t\t\t\t\t\t\t\ttrigger-label={t(\"Choose a month\")}\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={draft.month}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonchange={(e: CustomEvent<{ value: string }>) => (draft = { ...draft, month: e.detail.value })}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<sp-option value=\"\">{t(\"No month\")}</sp-option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#each answer.clock.months as monthName, i (i)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<sp-option value={String(i + 1)}>{monthName}</sp-option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t\t\t\t\t</sp-combobox>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t<label data-widget-part=\"chronicle.field\">\n\t\t\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.field-label label\">{t(f.label)}</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.field-input\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tname={f.key}\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={draft[f.key]}\n\t\t\t\t\t\t\t\t\t\t\t\t\toninput={(e) => (draft = { ...draft, [f.key]: e.currentTarget.value })}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonkeydown={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (e.key === \"Enter\") {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvoid submitMove()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{#if formProblem}\n\t\t\t\t\t\t\t\t<p data-widget-part=\"chronicle.alert\" role=\"alert\">{formProblem}</p>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.form-actions toolbar\">\n\t\t\t\t\t\t\t\t<button type=\"button\" data-widget-part=\"chronicle.cancel\" onclick={() => (moving = false)}>\n\t\t\t\t\t\t\t\t\t{t(\"Cancel\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.save\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={submitMove}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{t(\"Set the clock\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t{/if}\n\t\t\t</section>\n\t\t{/if}\n\n\t\t{#if view.ownerOnly}\n\t\t\t<p data-widget-part=\"chronicle.note\">{view.ownerOnly}</p>\n\t\t{:else if view.state === \"ready\"}\n\t\t\t{#if view.openScene}\n\t\t\t\t{@const open = view.openScene}\n\t\t\t\t<section\n\t\t\t\t\tdata-widget-part=\"chronicle.open-scene card\"\n\t\t\t\t\tdata-scene-id={open.id}\n\t\t\t\t\taria-labelledby=\"{uid}-open-scene\"\n\t\t\t\t>\n\t\t\t\t\t<h3 id=\"{uid}-open-scene\" data-widget-part=\"chronicle.heading label\">{t(\"Open scene\")}</h3>\n\t\t\t\t\t<div data-widget-part=\"chronicle.open-scene-head\">\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.scene-swatch\" data-swatch={open.swatch}></span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.open-scene-name\">{open.name}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<p data-widget-part=\"chronicle.open-scene-meta\">\n\t\t\t\t\t\t{#if open.since}<span data-widget-part=\"chronicle.open-scene-since\">{open.since}</span>{/if}\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.scene-span\">{open.span}</span>\n\t\t\t\t\t</p>\n\t\t\t\t\t{#if open.cast.length}\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.cast list\" aria-label={t(\"Proposed cast\")}>\n\t\t\t\t\t\t\t{#each open.cast as member, i (i)}\n\t\t\t\t\t\t\t\t<!-- Why they're proposed is the name's tooltip, in words (2026-11-06);\n\t\t\t\t\t\t\t\t never printed beside the name. -->\n\t\t\t\t\t\t\t\t<li data-widget-part=\"chronicle.cast-member chip\" title={member.evidence || undefined}>\n\t\t\t\t\t\t\t\t\t{member.name}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if open.canClose}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.open-scene-actions toolbar\">\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.close\"\n\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\tonclick={() => closeOpenScene(open.id, false)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<sp-icon name=\"flag-off\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t{t(\"Close scene\")}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{#if open.canCloseAndSummarize}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.close-summarize\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => closeOpenScene(open.id, true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{t(\"Close and summarize\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if open.note}\n\t\t\t\t\t\t<p data-widget-part=\"chronicle.open-scene-note\">{open.note}</p>\n\t\t\t\t\t{/if}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if !timeless}\n\t\t\t<section data-widget-part=\"chronicle.now\" aria-labelledby=\"{uid}-now\">\n\t\t\t\t<h3 id=\"{uid}-now\" data-widget-part=\"chronicle.heading label\">{t(\"Now\")}</h3>\n\t\t\t\t{#if view.now}\n\t\t\t\t\t<div data-widget-part=\"chronicle.entry card\" data-entry-id={view.now.id}>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-date\">{view.now.date}</span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-line\" data-blank={view.now.blank ? \"\" : undefined}>\n\t\t\t\t\t\t\t{view.now.firstLine}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span data-widget-part=\"chronicle.entry-scenes\">{view.now.scenes}</span>\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t\t<div data-widget-part=\"chronicle.toolbar toolbar\">\n\t\t\t\t\t{#if canOpen}\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=\"chronicle.open\"\n\t\t\t\t\t\t\tonclick={() => openEntry(view.now?.id)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"external-link\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t{t(\"Open in lorebook\")}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if view.canWrite && view.now}\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=\"chronicle.start\"\n\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\tonclick={startEntry}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"plus\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t{t(\"Start new history entry\")}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if view.now || timeless}\n\t\t\t\t<section data-widget-part=\"chronicle.scenes\" aria-labelledby=\"{uid}-scenes\">\n\t\t\t\t\t<h3 id=\"{uid}-scenes\" data-widget-part=\"chronicle.heading label\">{t(\"Scenes\")}</h3>\n\t\t\t\t\t{#if view.scenes.length}\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.scene-list list\">\n\t\t\t\t\t\t\t{#each view.scenes as s (s.id)}\n\t\t\t\t\t\t\t\t{@render sceneRow(s)}\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{#if (timeless && canOpen) || view.canSummarize || view.extend || view.summarizeAll}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.scene-actions toolbar\">\n\t\t\t\t\t\t\t{#if timeless && canOpen}\n\t\t\t\t\t\t\t\t<button type=\"button\" data-widget-part=\"chronicle.open\" onclick={openScenes}>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"external-link\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{t(\"Open in lorebook\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{#if view.canSummarize}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.summarize\"\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => press(\"summarize\", \"summarize\", { kind: \"scene\" })}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{t(\"Summarize scene\")}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{#if view.summarizeAll}\n\t\t\t\t\t\t\t\t{@const all = view.summarizeAll}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.summarize-all\"\n\t\t\t\t\t\t\t\t\ttitle={all.title}\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => summarizeScenes()}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"film\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{all.label}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{#if view.extend}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.extend\"\n\t\t\t\t\t\t\t\t\ttitle={view.extend.title}\n\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\tonclick={() => press(\"extend\", \"extend-graph\", {})}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<sp-icon name=\"network\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t{view.extend.label}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if view.unfiled.length}\n\t\t\t\t<section data-widget-part=\"chronicle.unfiled\" aria-labelledby=\"{uid}-unfiled\">\n\t\t\t\t\t<h3 id=\"{uid}-unfiled\" data-widget-part=\"chronicle.heading label\">{t(\"Not yet compiled\")}</h3>\n\t\t\t\t\t{#each view.unfiled as day (day.key)}\n\t\t\t\t\t\t<div data-widget-part=\"chronicle.unfiled-day\" role=\"group\" aria-label={day.date}>\n\t\t\t\t\t\t\t<div data-widget-part=\"chronicle.unfiled-day-head\">\n\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.unfiled-date\">{day.date}</span>\n\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.unfiled-count\">{day.count}</span>\n\t\t\t\t\t\t\t\t{#if day.compile}\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.unfiled-compile\"\n\t\t\t\t\t\t\t\t\t\ttitle={day.compile.title}\n\t\t\t\t\t\t\t\t\t\tdisabled={!!busy}\n\t\t\t\t\t\t\t\t\t\tonclick={() => compileDay(day.compile!.date)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<sp-icon name=\"wand\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t\t\t\t\t{day.compile.label}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<ul data-widget-part=\"chronicle.scene-list list\">\n\t\t\t\t\t\t\t\t{#each day.scenes as s (s.id)}{@render sceneRow(s)}{/each}\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/each}\n\t\t\t\t</section>\n\t\t\t{/if}\n\n\t\t\t{#if view.earlierHead}\n\t\t\t\t<!-- Folded: the host's accordion, its trigger the head (*Earlier (N)*). -->\n\t\t\t\t<sp-accordion data-widget-part=\"chronicle.earlier\" value=\"\">\n\t\t\t\t\t<sp-accordion-item value=\"earlier\" heading={view.earlierHead} level=\"3\">\n\t\t\t\t\t\t<ul data-widget-part=\"chronicle.earlier-list list\">\n\t\t\t\t\t\t\t{#each view.earlier as e (e.id)}\n\t\t\t\t\t\t\t\t<li data-widget-part=\"chronicle.earlier-row row\" data-entry-id={e.id}>\n\t\t\t\t\t\t\t\t\t{#if canOpen}\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\tdata-widget-part=\"chronicle.earlier-entry\"\n\t\t\t\t\t\t\t\t\t\t\ttitle={t(\"Open in lorebook\")}\n\t\t\t\t\t\t\t\t\t\t\tonclick={() => openEntry(e.id)}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{@render earlierBody(e)}\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t<span data-widget-part=\"chronicle.earlier-entry\">{@render earlierBody(e)}</span>\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t{#if view.earlierMore}\n\t\t\t\t\t\t\t<p data-widget-part=\"chronicle.earlier-more\">{view.earlierMore}</p>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</sp-accordion-item>\n\t\t\t\t</sp-accordion>\n\t\t\t{/if}\n\t\t{/if}\n\t{/if}\n</div>\n","shared/chronicle/chronicle.ts":"/**\n * Core's `chronicle` component (PLAN-core-widgets W3): the session's story\n * clock, the history entry it reads now with this session's scenes under\n * it, and the entries before. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/chronicle.js`, the module the app\n * serves at `/core-ui/chronicle`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Chronicle from './Chronicle.svelte'\n\nexport default svelteComponent(Chronicle)\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/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":"7b72a296a92a8756c8b9374ec64244fbbb24fada3832d2d47e0e1d78c48a78a4","catalogVersion":"0.6.0-pr-9"}