logic-atlas 0.26.1 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +1 -1
- package/README.md +3 -3
- package/dist/case.js +1 -1
- package/dist/chunks/{CasePage-DJG6QgNd.js → CasePage-D9w8opn_.js} +3 -3
- package/dist/chunks/{CasePage-DJG6QgNd.js.map → CasePage-D9w8opn_.js.map} +1 -1
- package/dist/chunks/{CausalPlayground-C5z0OoUl.js → CausalPlayground-DAItu6zY.js} +3 -3
- package/dist/chunks/{CausalPlayground-C5z0OoUl.js.map → CausalPlayground-DAItu6zY.js.map} +1 -1
- package/dist/chunks/{CiteBlock-CcJunM8w.js → CiteBlock-CxIS70aQ.js} +2 -2
- package/dist/chunks/{CiteBlock-CcJunM8w.js.map → CiteBlock-CxIS70aQ.js.map} +1 -1
- package/dist/chunks/{ExportMenu-CJjRjah_.js → ExportMenu-Bku7BhiT.js} +3 -3
- package/dist/chunks/{ExportMenu-CJjRjah_.js.map → ExportMenu-Bku7BhiT.js.map} +1 -1
- package/dist/chunks/{GraphBox-CYl-fqqI.js → GraphBox-K7ziPIVx.js} +2 -2
- package/dist/chunks/{GraphBox-CYl-fqqI.js.map → GraphBox-K7ziPIVx.js.map} +1 -1
- package/dist/chunks/{IdentifyPanel-COhmqkTf.js → IdentifyPanel-DNFM0h2W.js} +2 -2
- package/dist/chunks/{IdentifyPanel-COhmqkTf.js.map → IdentifyPanel-DNFM0h2W.js.map} +1 -1
- package/dist/chunks/{ModelEditor-SE2V2SDo.js → ModelEditor-DskhGLjq.js} +2 -2
- package/dist/chunks/{ModelEditor-SE2V2SDo.js.map → ModelEditor-DskhGLjq.js.map} +1 -1
- package/dist/chunks/{ProbabilityPanel-6i6jU5dn.js → ProbabilityPanel-7YIOtAmh.js} +3 -3
- package/dist/chunks/{ProbabilityPanel-6i6jU5dn.js.map → ProbabilityPanel-7YIOtAmh.js.map} +1 -1
- package/dist/chunks/{RulesPanel-CIP-Qk_d.js → RulesPanel-BXh_JKrO.js} +2 -2
- package/dist/chunks/{RulesPanel-CIP-Qk_d.js.map → RulesPanel-BXh_JKrO.js.map} +1 -1
- package/dist/chunks/{WorldLanes-TpkLAJ-l.js → WorldLanes-C6xXmN-Y.js} +2 -2
- package/dist/chunks/{WorldLanes-TpkLAJ-l.js.map → WorldLanes-C6xXmN-Y.js.map} +1 -1
- package/dist/chunks/{cite-CRjIk0kq.js → cite-qX7YWepK.js} +2 -2
- package/dist/chunks/{cite-CRjIk0kq.js.map → cite-qX7YWepK.js.map} +1 -1
- package/dist/chunks/{export-image-t9gDilVa.js → export-image-DRX4_diW.js} +3 -3
- package/dist/chunks/{export-image-t9gDilVa.js.map → export-image-DRX4_diW.js.map} +1 -1
- package/dist/cite.js +1 -1
- package/dist/editor.js +1 -1
- package/dist/ground-cases.js +88 -75
- package/dist/ground-cases.js.map +1 -1
- package/dist/ground-chunks/download-graph-GJWXyNLP.js +35 -0
- package/dist/ground-chunks/download-graph-GJWXyNLP.js.map +1 -0
- package/dist/ground.css +1 -1
- package/dist/ground.js +2109 -1930
- package/dist/ground.js.map +1 -1
- package/dist/identify.js +1 -1
- package/dist/index.js +7 -7
- package/dist/lanes.js +1 -1
- package/dist/playground.js +1 -1
- package/dist/probability.js +1 -1
- package/dist/types/ground/components/DiscernibilityPanel.d.ts +3 -16
- package/dist/types/ground/components/PairDetails.d.ts +20 -0
- package/dist/types/ground/components/PropertyGrid.d.ts +9 -0
- package/dist/types/ground/components/StructureView.d.ts +6 -1
- package/dist/types/ground/components/download-graph.d.ts +1 -0
- package/dist/types/ground/components/figure-frame.d.ts +23 -0
- package/dist/types/ground/components/parts.d.ts +2 -1
- package/dist/types/ground/components/structure-layout.d.ts +0 -13
- package/dist/types/ground/data/schema.d.ts +25 -0
- package/dist/types/ground/i18n/zh.d.ts +39 -15
- package/dist/types/ground/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportMenu-CJjRjah_.js","names":["_Fragment","useMessages","LANGUAGE_NAMES","errorMessage","messagesFor","originSources","originCitations","DigitsScope","Segmented","bibtex","authorYearEn","authorYear","Fragment$1","renderDetached","container","root","createRoot","flushSync","node","graphExport","locale","page","onPage","view","LocaleProvider","draw","singleGraphSource","m","wrap","digits","svg","parts","c","loaded","loading","loadExportImage","error","withExportImage","run","pageTheme","el","LANGUAGES","value","ExportMenu","t","open","setOpen","useState","format","setFormat","style","setStyle","theme","setTheme","setLocale","setError","useRef","id","useId","o","CitationReminder","url","s","source","done","embedCode","CopyButton","copied","setCopied","text","label","line","origins"],"sources":["../../src/components/export/export-render.tsx","../../src/components/export/export-loader.ts","../../src/components/export/page-theme.ts","../../src/components/export/ExportMenu.tsx"],"sourcesContent":["import type { ReactNode, RefObject } from 'react'\nimport { flushSync } from 'react-dom'\nimport { createRoot } from 'react-dom/client'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { LocaleProvider, messagesFor } from '../i18n/messages.ts'\nimport { originCitations, originSources } from '../model/verdict-rows.ts'\nimport { DEFAULT_DIGITS, DigitsScope } from '../shared/digits.ts'\nimport type { ExportPanel, ExportSource } from './export-image.ts'\n\n/**\n * Render `node` synchronously into a hidden element on the page, so an export can draw a graph in\n * another language than the one on screen. Client only; call from an event handler, then dispose.\n */\nexport function renderDetached(node: ReactNode): { readonly container: HTMLElement; readonly dispose: () => void } {\n const container = document.createElement('div')\n container.setAttribute('aria-hidden', 'true')\n container.style.cssText = 'position:absolute;left:-100000px;top:0;visibility:hidden;pointer-events:none'\n document.body.append(container)\n const root = createRoot(container)\n flushSync(() => root.render(node))\n return {\n container,\n dispose: () => {\n root.unmount()\n container.remove()\n },\n }\n}\n\n/**\n * The export of one graph: the SVG on the page in the page's language, else the same graph drawn\n * off-screen in `locale`. `draw` returns the graph element (without handlers).\n */\nexport function graphExport(\n locale: Locale,\n page: Messages,\n onPage: () => SVGSVGElement | null | undefined,\n draw: () => ReactNode,\n digits = DEFAULT_DIGITS,\n): { readonly svg: SVGSVGElement | null; readonly dispose?: () => void } {\n if (locale === page.locale) return { svg: onPage() ?? null }\n const view = renderDetached(<LocaleProvider locale={locale}>\n <DigitsScope digits={digits}>{draw()}</DigitsScope>\n </LocaleProvider>)\n return { svg: view.container.querySelector<SVGSVGElement>('svg.ca-graph'), dispose: view.dispose }\n}\n\n/** What a single-graph panel puts into its export: the file name, its panels (the graph with its tags) and the legend. */\nexport interface GraphExportParts {\n readonly name: string\n readonly panels: readonly ExportPanel[]\n readonly legend: string\n}\n\n/**\n * The export of a panel that draws one graph (`svg.ca-graph` inside `wrap`): the graph on the page,\n * or drawn off-screen in `locale` (see {@link graphExport}), with the case's title and sources.\n * `draw` draws the graph in a language's messages (its probabilities written to `digits` decimals);\n * `parts` names the export and lays out its panels.\n * Undefined when there is no graph to export.\n */\nexport function singleGraphSource(\n c: LoadedCase,\n locale: Locale,\n page: Messages,\n wrap: RefObject<HTMLElement | null>,\n digits: number,\n draw: (m: Messages) => ReactNode,\n parts: (svg: SVGSVGElement, m: Messages) => GraphExportParts,\n): ExportSource | undefined {\n const m = messagesFor(locale)\n const { svg, dispose } = graphExport(locale, page, () => wrap.current?.querySelector<SVGSVGElement>('svg.ca-graph'), () => draw(m), digits)\n if (svg === null) {\n dispose?.()\n return undefined\n }\n const { name, panels, legend } = parts(svg, m)\n return { name, title: c.data.title[locale], panels, legend, origin: originSources(m, c), originCitations: originCitations(c), dispose }\n}\n","import type * as ExportImageModule from './export-image.ts'\n\n/**\n * The image export (SVG building, rasterizing, palettes) is its own chunk: a figure loads it when its\n * 「下載圖片」 menu opens, not with the page.\n */\nexport type ExportImage = typeof ExportImageModule\n\nlet loaded: ExportImage | undefined\nlet loading: Promise<ExportImage> | undefined\n\n/** Start loading the image export; resolves to the module (at once when already loaded). */\nexport function loadExportImage(): Promise<ExportImage> {\n loading ??= import('./export-image.ts').then(\n (m) => (loaded = m),\n (error: unknown) => {\n loading = undefined\n throw error\n },\n )\n return loading\n}\n\n/** Run `run` with the image export: synchronously when it is loaded, after loading otherwise. */\nexport function withExportImage<T>(run: (m: ExportImage) => T | Promise<T>): Promise<T> {\n if (loaded !== undefined) {\n try {\n return Promise.resolve(run(loaded))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n return loadExportImage().then(run)\n}\n","import type { ExportTheme } from './export-image.ts'\n\n/** The page's theme around `el`: the nearest `data-theme`, else light. */\nexport function pageTheme(el: Element | null): ExportTheme {\n const holder = el?.closest('[data-theme]') ?? (typeof document === 'undefined' ? null : document.documentElement)\n return holder?.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'\n}\n","import { useId, useRef, useState } from 'react'\nimport type { ExportFormat, ExportSource, ExportStyle, ExportTheme } from './export-image.ts'\nimport { loadExportImage, withExportImage } from './export-loader.ts'\nimport { pageTheme } from './page-theme.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { LANGUAGE_NAMES, errorMessage, messagesFor, useMessages } from '../i18n/messages.ts'\nimport { DEFAULT_URL, authorYear, authorYearEn, bibtex } from './cite.ts'\nimport { Segmented } from '../shared/parts.tsx'\n\nexport interface ExportMenuProps {\n /** Collects what to draw, in the chosen language, at click time; undefined when nothing is on screen. */\n readonly source: (locale: Locale) => ExportSource | undefined\n /** Link in the watermark. */\n readonly url?: string\n /** Full citations of the case's origin sources; the academic style's reminder lists them. */\n readonly origins?: readonly string[]\n /** Builds the embed code (iframe and citation) at click time; given, the menu offers to copy it. */\n readonly embedCode?: () => string\n}\n\nconst LANGUAGES = (Object.keys(LANGUAGE_NAMES) as Locale[]).map((value) => ({ value, label: LANGUAGE_NAMES[value] }))\n\n/**\n * 「下載圖片」: format, theme (default: the page's) and language (default: the component's), then\n * download. Client only on click.\n */\nexport function ExportMenu({ source, url, origins = [], embedCode }: ExportMenuProps) {\n const t = useMessages()\n const [open, setOpen] = useState(false)\n const [format, setFormat] = useState<ExportFormat>('png')\n const [style, setStyle] = useState<ExportStyle>('color')\n const [theme, setTheme] = useState<ExportTheme>('light')\n const [locale, setLocale] = useState<Locale>(t.locale)\n const [error, setError] = useState<string | undefined>(undefined)\n const root = useRef<HTMLDivElement>(null)\n const id = useId()\n\n const toggle = (): void => {\n if (!open) {\n // Fetch the image export while the reader picks the settings.\n loadExportImage().catch(() => undefined)\n setTheme(pageTheme(root.current))\n setLocale(t.locale)\n }\n setError(undefined)\n setOpen((o) => !o)\n }\n const download = (): void => {\n let s: ExportSource | undefined\n try {\n s = source(locale)\n } catch (e) {\n setError(t.export.failed(errorMessage(e, t)))\n return\n }\n if (s === undefined || s.panels.length === 0) {\n s?.dispose?.()\n setError(t.export.nothing)\n return\n }\n const done = s.dispose\n withExportImage((m) => m.exportImage(s, { style, theme, format, url, locale }))\n .catch((e: unknown) => setError(t.export.failed(errorMessage(e, t))))\n .finally(() => done?.())\n }\n\n return (\n <div className=\"ca-export\" ref={root}>\n <button type=\"button\" className=\"ca-link\" aria-expanded={open} aria-controls={id} onClick={toggle}>\n {t.export.open}\n </button>\n {open && (\n <div className=\"ca-export-menu\" id={id} role=\"group\" aria-label={t.export.settings}>\n <Segmented\n label={t.export.format}\n options={[\n { value: 'png', label: t.export.png },\n { value: 'svg', label: 'SVG' },\n ]}\n value={format}\n onChange={setFormat}\n />\n <Segmented\n label={t.export.style}\n options={[\n { value: 'color', label: t.export.styleColor },\n { value: 'academic', label: t.export.styleAcademic },\n ]}\n value={style}\n onChange={setStyle}\n />\n {style === 'color' && (\n <Segmented\n label={t.export.theme}\n options={[\n { value: 'light', label: t.export.light },\n { value: 'dark', label: t.export.dark },\n ]}\n value={theme}\n onChange={setTheme}\n />\n )}\n <Segmented label={t.export.language} options={LANGUAGES} value={locale} onChange={setLocale} />\n {style === 'academic' && <CitationReminder key={locale} locale={locale} url={url ?? DEFAULT_URL} origins={origins} />}\n <button type=\"button\" className=\"ca-btn ca-btn-primary ca-export-go\" onClick={download}>\n {t.export.download}\n </button>\n {error !== undefined && (\n <p className=\"ca-small ca-export-error\" role=\"alert\">\n {error}\n </p>\n )}\n {embedCode !== undefined && (\n <div className=\"ca-export-embed\" role=\"note\">\n <p className=\"ca-small\">{t.export.embedLead}</p>\n <div className=\"ca-export-copy\">\n <CopyButton text={embedCode} label={t.export.copyEmbed} />\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n )\n}\n\n/** Copies `text` (or what it builds at click time). */\nfunction CopyButton({ text, label }: { readonly text: string | (() => string); readonly label: string }) {\n const t = useMessages()\n const [copied, setCopied] = useState(false)\n const copy = (): void => {\n void navigator.clipboard?.writeText(typeof text === 'string' ? text : text()).then(() => setCopied(true))\n }\n return (\n <button type=\"button\" className=\"ca-btn ca-btn-outline\" onClick={copy}>\n {copied ? t.export.copied : label}\n </button>\n )\n}\n\n/**\n * What to cite when using the academic image: this project (author-year, BibTeX) and the case's own\n * sources. 「複製引用文字」 copies the project's line with every case source, one per line, so the\n * credit is never the project's alone.\n */\nfunction CitationReminder({ locale, url, origins }: { readonly locale: Locale; readonly url: string; readonly origins: readonly string[] }) {\n const m = messagesFor(locale).export\n const line = locale === 'en' ? authorYearEn(url) : authorYear(url)\n return (\n <div className=\"ca-export-cite\" role=\"note\" lang={locale}>\n <p className=\"ca-small\">{m.reminderHeading}</p>\n <p className=\"ca-cite-entry ca-small\">{line}</p>\n {origins.length > 0 && (\n <>\n <p className=\"ca-small\">{m.reminderOrigins}</p>\n <ul className=\"ca-small\">\n {origins.map((o) => (\n <li key={o}>{o}</li>\n ))}\n </ul>\n </>\n )}\n <div className=\"ca-export-copy\">\n <CopyButton text={[line, ...origins].join('\\n')} label={m.copyCitations} />\n <CopyButton text={bibtex(url)} label={messagesFor(locale).cite.copyBibtex} />\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgBa,EAAe,GAAoF;CACjH,IAAMC,IAAY,SAAS,cAAc,KAAK;CAG9C,AAFAA,EAAU,aAAa,eAAe,MAAM,GAC5C,EAAU,MAAM,UAAU,gFAC1B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AE;GAAmB,CAAA;GAC9C,kBAAC,KAAD;IAAG,WAAU;IAA0B,UAAA4C;GAAQ,CAAA;GAC9CC,EAAQ,SAAS,KAChB,kBAAAxE,GAAA,EAAA,UAAA,CACE,kBAAC,KAAD;IAAG,WAAU;IAAY,UAAA2B,EAAE;GAAmB,CAAA,GAC9C,kBAAC,MAAD;IAAI,WAAU;IACX,UAAA6C,EAAQ,KAAK,MACZ,kBAAC,MAAD,EAAA,UAAab,EAAM,GAAVA,CAAU,CACpB;GACC,CAAA,CACJ,EAAA,CAAA;GAEJ,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACO,GAAD;KAAY,MAAM,CAACK,GAAM,GAAGC,CAAO,CAAC,CAAC,KAAK,IAAI;KAAG,OAAO7C,EAAE;IAAgB,CAAA,GAC1E,kBAACuC,GAAD;KAAY,MAAMzD,EAAOoD,CAAG;KAAG,OAAOzD,EAAYgB,CAAM,CAAC,CAAC,KAAK;IAAa,CAAA,CACzE;;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"ExportMenu-Bku7BhiT.js","names":["_Fragment","useMessages","LANGUAGE_NAMES","errorMessage","messagesFor","originSources","originCitations","DigitsScope","Segmented","bibtex","authorYearEn","authorYear","Fragment$1","renderDetached","container","root","createRoot","flushSync","node","graphExport","locale","page","onPage","view","LocaleProvider","draw","singleGraphSource","m","wrap","digits","svg","parts","c","loaded","loading","loadExportImage","error","withExportImage","run","pageTheme","el","LANGUAGES","value","ExportMenu","t","open","setOpen","useState","format","setFormat","style","setStyle","theme","setTheme","setLocale","setError","useRef","id","useId","o","CitationReminder","url","s","source","done","embedCode","CopyButton","copied","setCopied","text","label","line","origins"],"sources":["../../src/components/export/export-render.tsx","../../src/components/export/export-loader.ts","../../src/components/export/page-theme.ts","../../src/components/export/ExportMenu.tsx"],"sourcesContent":["import type { ReactNode, RefObject } from 'react'\nimport { flushSync } from 'react-dom'\nimport { createRoot } from 'react-dom/client'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { LocaleProvider, messagesFor } from '../i18n/messages.ts'\nimport { originCitations, originSources } from '../model/verdict-rows.ts'\nimport { DEFAULT_DIGITS, DigitsScope } from '../shared/digits.ts'\nimport type { ExportPanel, ExportSource } from './export-image.ts'\n\n/**\n * Render `node` synchronously into a hidden element on the page, so an export can draw a graph in\n * another language than the one on screen. Client only; call from an event handler, then dispose.\n */\nexport function renderDetached(node: ReactNode): { readonly container: HTMLElement; readonly dispose: () => void } {\n const container = document.createElement('div')\n container.setAttribute('aria-hidden', 'true')\n container.style.cssText = 'position:absolute;left:-100000px;top:0;visibility:hidden;pointer-events:none'\n document.body.append(container)\n const root = createRoot(container)\n flushSync(() => root.render(node))\n return {\n container,\n dispose: () => {\n root.unmount()\n container.remove()\n },\n }\n}\n\n/**\n * The export of one graph: the SVG on the page in the page's language, else the same graph drawn\n * off-screen in `locale`. `draw` returns the graph element (without handlers).\n */\nexport function graphExport(\n locale: Locale,\n page: Messages,\n onPage: () => SVGSVGElement | null | undefined,\n draw: () => ReactNode,\n digits = DEFAULT_DIGITS,\n): { readonly svg: SVGSVGElement | null; readonly dispose?: () => void } {\n if (locale === page.locale) return { svg: onPage() ?? null }\n const view = renderDetached(<LocaleProvider locale={locale}>\n <DigitsScope digits={digits}>{draw()}</DigitsScope>\n </LocaleProvider>)\n return { svg: view.container.querySelector<SVGSVGElement>('svg.ca-graph'), dispose: view.dispose }\n}\n\n/** What a single-graph panel puts into its export: the file name, its panels (the graph with its tags) and the legend. */\nexport interface GraphExportParts {\n readonly name: string\n readonly panels: readonly ExportPanel[]\n readonly legend: string\n}\n\n/**\n * The export of a panel that draws one graph (`svg.ca-graph` inside `wrap`): the graph on the page,\n * or drawn off-screen in `locale` (see {@link graphExport}), with the case's title and sources.\n * `draw` draws the graph in a language's messages (its probabilities written to `digits` decimals);\n * `parts` names the export and lays out its panels.\n * Undefined when there is no graph to export.\n */\nexport function singleGraphSource(\n c: LoadedCase,\n locale: Locale,\n page: Messages,\n wrap: RefObject<HTMLElement | null>,\n digits: number,\n draw: (m: Messages) => ReactNode,\n parts: (svg: SVGSVGElement, m: Messages) => GraphExportParts,\n): ExportSource | undefined {\n const m = messagesFor(locale)\n const { svg, dispose } = graphExport(locale, page, () => wrap.current?.querySelector<SVGSVGElement>('svg.ca-graph'), () => draw(m), digits)\n if (svg === null) {\n dispose?.()\n return undefined\n }\n const { name, panels, legend } = parts(svg, m)\n return { name, title: c.data.title[locale], panels, legend, origin: originSources(m, c), originCitations: originCitations(c), dispose }\n}\n","import type * as ExportImageModule from './export-image.ts'\n\n/**\n * The image export (SVG building, rasterizing, palettes) is its own chunk: a figure loads it when its\n * 「下載圖片」 menu opens, not with the page.\n */\nexport type ExportImage = typeof ExportImageModule\n\nlet loaded: ExportImage | undefined\nlet loading: Promise<ExportImage> | undefined\n\n/** Start loading the image export; resolves to the module (at once when already loaded). */\nexport function loadExportImage(): Promise<ExportImage> {\n loading ??= import('./export-image.ts').then(\n (m) => (loaded = m),\n (error: unknown) => {\n loading = undefined\n throw error\n },\n )\n return loading\n}\n\n/** Run `run` with the image export: synchronously when it is loaded, after loading otherwise. */\nexport function withExportImage<T>(run: (m: ExportImage) => T | Promise<T>): Promise<T> {\n if (loaded !== undefined) {\n try {\n return Promise.resolve(run(loaded))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n return loadExportImage().then(run)\n}\n","import type { ExportTheme } from './export-image.ts'\n\n/** The page's theme around `el`: the nearest `data-theme`, else light. */\nexport function pageTheme(el: Element | null): ExportTheme {\n const holder = el?.closest('[data-theme]') ?? (typeof document === 'undefined' ? null : document.documentElement)\n return holder?.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'\n}\n","import { useId, useRef, useState } from 'react'\nimport type { ExportFormat, ExportSource, ExportStyle, ExportTheme } from './export-image.ts'\nimport { loadExportImage, withExportImage } from './export-loader.ts'\nimport { pageTheme } from './page-theme.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { LANGUAGE_NAMES, errorMessage, messagesFor, useMessages } from '../i18n/messages.ts'\nimport { DEFAULT_URL, authorYear, authorYearEn, bibtex } from './cite.ts'\nimport { Segmented } from '../shared/parts.tsx'\n\nexport interface ExportMenuProps {\n /** Collects what to draw, in the chosen language, at click time; undefined when nothing is on screen. */\n readonly source: (locale: Locale) => ExportSource | undefined\n /** Link in the watermark. */\n readonly url?: string\n /** Full citations of the case's origin sources; the academic style's reminder lists them. */\n readonly origins?: readonly string[]\n /** Builds the embed code (iframe and citation) at click time; given, the menu offers to copy it. */\n readonly embedCode?: () => string\n}\n\nconst LANGUAGES = (Object.keys(LANGUAGE_NAMES) as Locale[]).map((value) => ({ value, label: LANGUAGE_NAMES[value] }))\n\n/**\n * 「下載圖片」: format, theme (default: the page's) and language (default: the component's), then\n * download. Client only on click.\n */\nexport function ExportMenu({ source, url, origins = [], embedCode }: ExportMenuProps) {\n const t = useMessages()\n const [open, setOpen] = useState(false)\n const [format, setFormat] = useState<ExportFormat>('png')\n const [style, setStyle] = useState<ExportStyle>('color')\n const [theme, setTheme] = useState<ExportTheme>('light')\n const [locale, setLocale] = useState<Locale>(t.locale)\n const [error, setError] = useState<string | undefined>(undefined)\n const root = useRef<HTMLDivElement>(null)\n const id = useId()\n\n const toggle = (): void => {\n if (!open) {\n // Fetch the image export while the reader picks the settings.\n loadExportImage().catch(() => undefined)\n setTheme(pageTheme(root.current))\n setLocale(t.locale)\n }\n setError(undefined)\n setOpen((o) => !o)\n }\n const download = (): void => {\n let s: ExportSource | undefined\n try {\n s = source(locale)\n } catch (e) {\n setError(t.export.failed(errorMessage(e, t)))\n return\n }\n if (s === undefined || s.panels.length === 0) {\n s?.dispose?.()\n setError(t.export.nothing)\n return\n }\n const done = s.dispose\n withExportImage((m) => m.exportImage(s, { style, theme, format, url, locale }))\n .catch((e: unknown) => setError(t.export.failed(errorMessage(e, t))))\n .finally(() => done?.())\n }\n\n return (\n <div className=\"ca-export\" ref={root}>\n <button type=\"button\" className=\"ca-link\" aria-expanded={open} aria-controls={id} onClick={toggle}>\n {t.export.open}\n </button>\n {open && (\n <div className=\"ca-export-menu\" id={id} role=\"group\" aria-label={t.export.settings}>\n <Segmented\n label={t.export.format}\n options={[\n { value: 'png', label: t.export.png },\n { value: 'svg', label: 'SVG' },\n ]}\n value={format}\n onChange={setFormat}\n />\n <Segmented\n label={t.export.style}\n options={[\n { value: 'color', label: t.export.styleColor },\n { value: 'academic', label: t.export.styleAcademic },\n ]}\n value={style}\n onChange={setStyle}\n />\n {style === 'color' && (\n <Segmented\n label={t.export.theme}\n options={[\n { value: 'light', label: t.export.light },\n { value: 'dark', label: t.export.dark },\n ]}\n value={theme}\n onChange={setTheme}\n />\n )}\n <Segmented label={t.export.language} options={LANGUAGES} value={locale} onChange={setLocale} />\n {style === 'academic' && <CitationReminder key={locale} locale={locale} url={url ?? DEFAULT_URL} origins={origins} />}\n <button type=\"button\" className=\"ca-btn ca-btn-primary ca-export-go\" onClick={download}>\n {t.export.download}\n </button>\n {error !== undefined && (\n <p className=\"ca-small ca-export-error\" role=\"alert\">\n {error}\n </p>\n )}\n {embedCode !== undefined && (\n <div className=\"ca-export-embed\" role=\"note\">\n <p className=\"ca-small\">{t.export.embedLead}</p>\n <div className=\"ca-export-copy\">\n <CopyButton text={embedCode} label={t.export.copyEmbed} />\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n )\n}\n\n/** Copies `text` (or what it builds at click time). */\nfunction CopyButton({ text, label }: { readonly text: string | (() => string); readonly label: string }) {\n const t = useMessages()\n const [copied, setCopied] = useState(false)\n const copy = (): void => {\n void navigator.clipboard?.writeText(typeof text === 'string' ? text : text()).then(() => setCopied(true))\n }\n return (\n <button type=\"button\" className=\"ca-btn ca-btn-outline\" onClick={copy}>\n {copied ? t.export.copied : label}\n </button>\n )\n}\n\n/**\n * What to cite when using the academic image: this project (author-year, BibTeX) and the case's own\n * sources. 「複製引用文字」 copies the project's line with every case source, one per line, so the\n * credit is never the project's alone.\n */\nfunction CitationReminder({ locale, url, origins }: { readonly locale: Locale; readonly url: string; readonly origins: readonly string[] }) {\n const m = messagesFor(locale).export\n const line = locale === 'en' ? authorYearEn(url) : authorYear(url)\n return (\n <div className=\"ca-export-cite\" role=\"note\" lang={locale}>\n <p className=\"ca-small\">{m.reminderHeading}</p>\n <p className=\"ca-cite-entry ca-small\">{line}</p>\n {origins.length > 0 && (\n <>\n <p className=\"ca-small\">{m.reminderOrigins}</p>\n <ul className=\"ca-small\">\n {origins.map((o) => (\n <li key={o}>{o}</li>\n ))}\n </ul>\n </>\n )}\n <div className=\"ca-export-copy\">\n <CopyButton text={[line, ...origins].join('\\n')} label={m.copyCitations} />\n <CopyButton text={bibtex(url)} label={messagesFor(locale).cite.copyBibtex} />\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgBa,EAAe,GAAoF;CACjH,IAAMC,IAAY,SAAS,cAAc,KAAK;CAG9C,AAFAA,EAAU,aAAa,eAAe,MAAM,GAC5C,EAAU,MAAM,UAAU,gFAC1B,SAAS,KAAK,OAAOA,CAAS;CAC9B,IAAMC,IAAOC,EAAWF,CAAS;CAEjC,OADAG,QAAgBF,EAAK,OAAOG,CAAI,CAAC,GAC1B;EACL;EACA,eAAe;GAEb,AADAH,EAAK,QAAQ,GACbD,EAAU,OAAO;EACnB;CACF;AACF;AAMA,SAAgBK,EACd,GACA,GACA,GACA,GACA,IAAA,GACuE;CACvE,IAAIC,MAAWC,EAAK,QAAQ,OAAO,EAAE,KAAKC,EAAO,KAAK,KAAK;CAC3D,IAAMC,IAAOV,EAAe,kBAACW,GAAD;EAAwB;EAChD,UAAA,kBAACjB,GAAD;GAAqB;GAAS,UAAAkB,EAAK;EAAe,CAAA;CACpC,CAAA,CAAC;CACnB,OAAO;EAAE,KAAKF,EAAK,UAAU,cAA6B,cAAc;EAAG,SAASA,EAAK;CAAQ;AACnG;AAgBA,SAAgBG,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GAC0B;CAC1B,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,KAAK;IAAa,CAAA,CACzE;;EACF;;AAET"}
|
|
@@ -4,7 +4,7 @@ import { P as i, V as a, W as o, Y as s, Z as c, at as l, ft as u, rt as d } fro
|
|
|
4
4
|
import { a as f, c as p, i as m, n as ee, r as te, s as ne, t as re } from "./use-node-menu-DJISBUAm.js";
|
|
5
5
|
import { l as h, u as ie } from "./parts-8cUsl2jJ.js";
|
|
6
6
|
import { a as g, o as _, s as v, t as ae } from "./FigureTabs-Dl3RgQQa.js";
|
|
7
|
-
import { i as oe, t as se } from "./ExportMenu-
|
|
7
|
+
import { i as oe, t as se } from "./ExportMenu-Bku7BhiT.js";
|
|
8
8
|
import { t as ce } from "./SignalGraph-CWPf_sG8.js";
|
|
9
9
|
import { useEffect as le, useLayoutEffect as ue, useMemo as y, useRef as de, useState as b } from "react";
|
|
10
10
|
import { Fragment as fe, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
@@ -336,4 +336,4 @@ function E({ c: h, world: g, interventions: _, stochastic: v = pe, onDo: C, obse
|
|
|
336
336
|
}
|
|
337
337
|
export { T as n, w as r, E as t };
|
|
338
338
|
|
|
339
|
-
//# sourceMappingURL=GraphBox-
|
|
339
|
+
//# sourceMappingURL=GraphBox-K7ziPIVx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphBox-CYl-fqqI.js","names":["NONE","_Fragment","getVariable","formatValue","valuesEqual","useMessages","originCitations","Formula","Rich","assignmentText","changeNotes","readingText","useDigits","probLegend","solve","withValue","useNarrow","NodeMenu","placeTip","withProbability","useNodeMenu","Segmented","Tag","notations","CopyLatex","Equations","FigureTabs","singleGraphSource","ExportMenu","SignalGraph","Fragment$1","NONE$1","EquationPanel","counterfactual","reading","world","eq","t","notation","onNotation","EquationBox","props","NONE","NO_OBSERVATION","withoutDo","interventions","state","stochastic","id","withoutKey","next","a","GraphBox","digits","notice","setNotice","useState","hasDo","hasObs","observed","hasSet","prob","cf","isReset","witness","grouped","holdNotes","chipText","entries","m","part","group","label","setNow","wrap","useRef","narrow","observes","onObserve","editable","onDo","menu","menuStyle","closeMenu","toggleMenu","tip","setTip","tipStyle","setTipStyle","relative","box","r","el","useLayoutEffect","place","at","p","useEffect","outside","target","escape","legendFor","c","headTag","commit","nextObserved","doing","clearAll","onReset","prior","useMemo","twoValued","abduced","probNotes","out","v","notes","visible","marks","markLegend","from","to","graph","interactive","lit","onHover","title","onMove","exportSource","locale","tags","observe","value","intervene","actions","moved","exportUrl","paths","menuExtra","menuHelp","legend","foot","blocks","initialBlock"],"sources":["../../src/components/panels/EquationBox.tsx","../../src/components/panels/GraphBox.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Prior } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport type { ModelWorld, Reading } from '../model/model-state.ts'\nimport { CopyLatex, Equations } from './Equations.tsx'\nimport type { UiNotation } from '../model/notation.ts'\nimport { notations } from '../model/notation.ts'\nimport { Segmented } from '../shared/parts.tsx'\nimport type { Stochastic } from '../model/assignments.ts'\n\nconst NONE: Stochastic = {}\n\nexport interface EquationPanelProps {\n readonly c: LoadedCase\n readonly world: ModelWorld\n readonly interventions: Assignment\n readonly stochastic?: Stochastic\n readonly notation: UiNotation\n readonly onNotation: (n: UiNotation) => void\n /** Default values: 預設 v beside each equation that has one. */\n readonly defaults?: Assignment\n /** Observations: the causal notation lists only the rows that can hold given them. */\n readonly observed?: Assignment\n /** How the observations are read (see `Reading`). */\n readonly reading?: Reading\n /** The prior when the caller changes it (sliders); default the case's. */\n readonly prior?: Prior\n}\n\n/** The equations with the notation switch and the LaTeX copy above them: the block behind a figure's 式子 tab. */\nexport function EquationPanel({ c, world, interventions, stochastic = NONE, notation, onNotation, defaults, observed, reading, prior }: EquationPanelProps) {\n const counterfactual = reading === 'counterfactual' && world.probs !== undefined\n const eq = { c, shown: world.shown, notation, values: world.values, interventions, stochastic, observed, prior, counterfactual }\n const t = useMessages()\n return (\n <div className=\"ca-eq-panel\">\n <div className=\"ca-eq-head\">\n <Segmented label={t.notationLabel} options={notations(t)} value={notation} onChange={onNotation} />\n <CopyLatex {...eq} />\n </div>\n <Equations {...eq} defaults={defaults} />\n </div>\n )\n}\n\n/** The equations in a box of their own, always open: the editor's, where they are the thing being edited. */\nexport function EquationBox(props: EquationPanelProps) {\n const t = useMessages()\n const { c, world, interventions, stochastic = NONE, notation, onNotation, defaults, observed, reading, prior } = props\n const counterfactual = reading === 'counterfactual' && world.probs !== undefined\n const eq = { c, shown: world.shown, notation, values: world.values, interventions, stochastic, observed, prior, counterfactual }\n return (\n <div className=\"ca-box ca-eq-box\">\n <div className=\"ca-eq-head\">\n <h3 className=\"ca-h3\">{t.equations}</h3>\n <Segmented label={t.notationLabel} options={notations(t)} value={notation} onChange={onNotation} />\n <CopyLatex {...eq} />\n </div>\n <Equations {...eq} defaults={defaults} />\n </div>\n )\n}\n","import type { CSSProperties, ReactNode } from 'react'\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Value } from '../../engine/index.ts'\nimport { formatValue, getVariable, valuesEqual } from '../../engine/index.ts'\nimport { singleGraphSource } from '../export/export-render.tsx'\nimport type { ExportSource, ExportTag } from '../export/export-image.ts'\nimport { ExportMenu } from '../export/ExportMenu.tsx'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { useDigits } from '../shared/digits.ts'\nimport type { PathMarks } from '../model/dsep-view.ts'\nimport type { DoState, ModelWorld, Reading } from '../model/model-state.ts'\nimport { solve, withProbability, withValue } from '../model/model-state.ts'\nimport type { FigureBlock } from '../shared/FigureTabs.tsx'\nimport { FigureTabs } from '../shared/FigureTabs.tsx'\nimport { useNarrow } from '../shared/use-narrow.ts'\nimport { Tag } from '../shared/parts.tsx'\nimport type { EdgeTip } from '../graph/SignalGraph.tsx'\nimport { SignalGraph } from '../graph/SignalGraph.tsx'\nimport type { Rect } from './menu-place.ts'\nimport { placeTip } from './menu-place.ts'\nimport { NodeMenu } from './NodeMenu.tsx'\nimport { useNodeMenu } from './use-node-menu.ts'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport { originCitations } from '../model/verdict-rows.ts'\nimport type { Stochastic } from '../model/assignments.ts'\nimport { assignmentText, changeNotes, probLegend, readingText } from '../model/wording.ts'\n\nexport interface GraphBoxProps {\n readonly c: LoadedCase\n readonly world: ModelWorld\n readonly interventions: Assignment\n /** Stochastic interventions, P*(X=1) per boolean node (probability mode only). */\n readonly stochastic?: Stochastic\n /** A click on a node: the new do() state. */\n readonly onDo?: (next: DoState) => void\n /** Observations the probabilities are conditioned on (probability mode only). */\n readonly observed?: Assignment\n /**\n * The new observations, chosen in a node's menu. Given in probability mode, the menu observes\n * as well as intervenes.\n */\n readonly onObserve?: (next: Assignment) => void\n /** Under the actions of a node's menu: the node's own probability sliders, if any. */\n readonly menuExtra?: (id: string) => ReactNode\n /** Nodes drawn with a soft halo (the ones a hovered slider moves). */\n readonly lit?: readonly string[]\n /** A node is hovered or keyboard-focused, or left (undefined). */\n readonly onHover?: (id: string | undefined) => void\n readonly witness?: Assignment\n /** Held variables show their held and actual values instead of the hull's 見證 tag (see SignalGraph). */\n readonly holdNotes?: boolean\n readonly legend?: boolean\n readonly menuHelp?: string\n readonly title?: string\n /** Link in the exported image's watermark. */\n readonly exportUrl?: string\n /** Node drag in the editor: grid offset in columns and rows. */\n readonly onMove?: (id: string, dCol: number, dRow: number) => void\n /** Builds the embed code (iframe and citation) for the figure as it stands; the export menu offers it when given. */\n readonly embedCode?: () => string\n /** Drawn inside the graph's frame under the legend (the playground's hint and step buttons); not exported. */\n readonly foot?: ReactNode\n /** The blocks under the graph (verdicts, a table, the equations), behind one row of tab buttons (see `FigureTabs`). */\n readonly blocks?: readonly FigureBlock[]\n /** The block open at first, one of `blocks`' ids; none by default. */\n readonly initialBlock?: string\n /** Called when the reader asks for the prior or actual world back (「回到原本」 or the chip's ×). */\n readonly onReset?: () => void\n /** Something `onReset` puts back moved besides what is set on the graph (the playground's sliders): the reset shows. */\n readonly moved?: boolean\n /** Notes under nodes that replace the 原本 v notes of a probability graph. */\n readonly notes?: Readonly<Record<string, string>>\n /**\n * How a probability graph reads what is set (see `Reading`). `counterfactual`: the menu's\n * observations are evidence about the actual world and its do() the hypothetical action; a node\n * may be both; evidence nodes read 實際 v instead of a tag.\n */\n readonly reading?: Reading\n /** Controls in the head, before 「回到原本」 (the playground's reading switch). */\n readonly actions?: ReactNode\n /** Default values: deviant nodes say 偏離(預設 v) (graphs with values). */\n readonly defaults?: Assignment\n /** d-separation marks for a pair (the playground's `dsep`). */\n readonly paths?: PathMarks\n}\n\nconst NONE: Stochastic = {}\n\nconst NO_OBSERVATION: Assignment = {}\n\n/** `do` without `id`, hard or stochastic. */\nfunction withoutDo(state: DoState, id: string): DoState {\n const interventions: Record<string, Assignment[string]> = { ...state.interventions }\n const stochastic: Record<string, number> = { ...state.stochastic }\n delete interventions[id]\n delete stochastic[id]\n return { interventions, stochastic }\n}\n\nfunction withoutKey(a: Assignment, id: string): Assignment {\n const next: Record<string, Assignment[string]> = { ...a }\n delete next[id]\n return next\n}\n\n/**\n * The graph with its world tags. A click on a node opens its menu beside it: do() at each value or\n * release (with a slider for P*(X=1) on a probability graph), and with `onObserve` observing at each\n * value; an observation that cannot happen under what is set is refused with a note. Marked edges\n * (on a d-separation path, cut by do()) explain themselves on hover, focus or a tap.\n */\nexport function GraphBox({\n c,\n world,\n interventions,\n stochastic = NONE,\n onDo,\n observed = NO_OBSERVATION,\n onObserve,\n witness,\n holdNotes,\n legend,\n title,\n exportUrl,\n onMove,\n embedCode,\n foot,\n blocks,\n initialBlock,\n onReset,\n moved = false,\n notes,\n reading = 'interventional',\n actions,\n defaults,\n paths,\n menuExtra,\n menuHelp,\n lit,\n onHover,\n}: GraphBoxProps) {\n const t = useMessages()\n const digits = useDigits()\n const [notice, setNotice] = useState<string | undefined>(undefined)\n const hasDo = Object.keys(interventions).length > 0 || Object.keys(stochastic).length > 0\n const hasObs = Object.keys(observed).length > 0\n const hasSet = hasDo || hasObs\n const state: DoState = { interventions, stochastic }\n const prob = world.probs !== undefined\n const cf = reading === 'counterfactual' && prob\n const isReset = (id: string): boolean => world.original?.[id] !== undefined && id in interventions && valuesEqual(world.original[id], interventions[id]) && witness?.[id] === undefined\n const grouped = holdNotes && !prob && Object.keys(interventions).some((id) => witness?.[id] !== undefined || isReset(id))\n const chipText = (m: Messages): string => {\n const entries = Object.entries(interventions)\n if (!grouped) return readingText(m, cf, interventions, stochastic, observed)\n return m.witness.groupLabels.flatMap((label, group) => {\n const part = entries.filter(([id]) => (witness?.[id] !== undefined ? 1 : isReset(id) ? 2 : 0) === group)\n return part.length ? [`${label}: ${assignmentText(Object.fromEntries(part))}`] : []\n }).join(' | ')\n }\n const setNow = chipText(t)\n const wrap = useRef<HTMLDivElement>(null)\n const narrow = useNarrow(wrap, 560)\n const observes = prob && onObserve !== undefined\n const editable = onDo !== undefined || onObserve !== undefined\n const { anchor: menu, menuRef, style: menuStyle, close: closeMenu, toggle: toggleMenu } = useNodeMenu(wrap, world.shown, world, narrow)\n const [tip, setTip] = useState<EdgeTip | undefined>(undefined)\n const [tipStyle, setTipStyle] = useState<CSSProperties>({ visibility: 'hidden' })\n /** `el`'s box relative to the wrapper. */\n const relative = (el: Element | null | undefined): Rect | undefined => {\n const box = wrap.current?.getBoundingClientRect()\n const r = el?.getBoundingClientRect()\n if (box === undefined || r === undefined) return undefined\n return { left: r.left - box.left, top: r.top - box.top, right: r.right - box.left, bottom: r.bottom - box.top }\n }\n // The edge tip sits above its edge, measured once drawn (and again on resize).\n useLayoutEffect(() => {\n if (tip === undefined) return\n const place = (): void => {\n const at = relative(wrap.current?.querySelector(`[data-edge=\"${tip.key}\"]`))\n setTipStyle(at === undefined ? {} : (() => {\n const p = placeTip(at, wrap.current?.clientWidth ?? 0)\n return { left: p.left, top: p.top, width: p.width }\n })())\n }\n place()\n window.addEventListener('resize', place)\n return () => window.removeEventListener('resize', place)\n }, [menu, tip, world, narrow])\n useEffect(() => {\n if (tip === undefined) return\n const outside = (e: Event): void => {\n const target = e.target\n if (target instanceof Element && !(wrap.current?.contains(target) === true && target.closest('[data-edge]') !== null)) setTip(undefined)\n }\n const escape = (e: globalThis.KeyboardEvent): void => {\n if (e.key === 'Escape') setTip(undefined)\n }\n document.addEventListener('pointerdown', outside)\n document.addEventListener('keydown', escape)\n return () => {\n document.removeEventListener('pointerdown', outside)\n document.removeEventListener('keydown', escape)\n }\n }, [tip])\n const legendFor = (m: Messages): string => (world.probs !== undefined ? probLegend(m, c.model, world.shown) : m.valueLegend)\n const headTag = (m: Messages): string => (cf && hasDo ? m.cf.kicker : hasDo && hasObs ? m.afterDoObserve : hasObs ? m.afterObserve : m.afterDo)\n /** Commit do() and observations together, unless the observations cannot happen under that do(). */\n const commit = (next: DoState, nextObserved: Assignment): void => {\n if (Object.keys(nextObserved).length > 0 && prob) {\n // Counterfactual evidence is about the actual world: it must be possible without the do().\n const evidence = (cf ? solve(c, {}, {}, nextObserved) : solve(c, next.interventions, next.stochastic, nextObserved)).evidence ?? 1\n if (!(evidence > 0)) {\n setNotice(t.observeImpossible(assignmentText(nextObserved)))\n return\n }\n }\n setNotice(undefined)\n if (nextObserved !== observed) onObserve?.(nextObserved)\n if (next.interventions !== interventions || next.stochastic !== stochastic) onDo?.(next)\n }\n // A do() on a node first drops its observation: the node keeps the value, now set by intervention.\n // Read as a counterfactual, the observation stays: what happened, and what is supposed instead.\n const doing = (next: DoState, id: string): void => commit(next, !cf && id in observed ? withoutKey(observed, id) : observed)\n const clearAll = (): void => {\n commit({ interventions: {}, stochastic: NONE }, NO_OBSERVATION)\n onReset?.()\n }\n // A probability graph keeps 原本 v under each 0/1 node whose number moved from the prior.\n const prior = useMemo(() => (prob ? solve(c, {}).probs : undefined), [c, prob])\n const twoValued = world.shown.filter((id) => getVariable(c.model, id).domain.kind === 'boolean')\n // Read as a counterfactual: 實際 v under each evidence node, and under each other node whose\n // number moved from the actual world's (the abduced one).\n const abduced = useMemo(() => (cf ? solve(c, {}, {}, observed).probs : undefined), [c, cf, observed])\n const cfNotes = (m: Messages): Record<string, string> => {\n if (abduced === undefined || world.probs === undefined) return {}\n const out: Record<string, string> = { ...changeNotes(m, abduced, world.probs, twoValued, m.actually, digits) }\n for (const [id, v] of Object.entries(observed)) out[id] = m.actually(formatValue(v))\n return out\n }\n const probNotes =\n prior === undefined || world.probs === undefined\n ? undefined\n : { ...(cf ? cfNotes(t) : changeNotes(t, prior, world.probs, twoValued, undefined, digits)), ...notes }\n const visible = world.shown\n const marks = t.witness.marks\n const markLegend = holdNotes ? [\n visible.some((id) => (id in interventions || id in stochastic) && witness?.[id] === undefined && !isReset(id)) && marks.clamp,\n visible.some(isReset) && marks.reset,\n world.removedEdges.some(({ from, to }) => visible.includes(from) && visible.includes(to)) && marks.cut,\n visible.some((id) => witness?.[id] !== undefined) && marks.hold,\n visible.some((id) => witness?.[id] === undefined && (prob\n ? !cf && probNotes?.[id] !== undefined && !(id in interventions) && !(id in observed)\n : world.original?.[id] !== undefined && world.values?.[id] !== undefined && !valuesEqual(world.original[id], world.values[id]))) && marks.was,\n ].filter(Boolean).join(' · ') : ''\n const graph = (m: Messages, interactive: boolean) => (\n <SignalGraph\n compact={narrow}\n c={c}\n shown={world.shown}\n values={world.values}\n original={world.original}\n probs={world.probs}\n dists={world.dists}\n probNotes={probNotes}\n observed={Object.keys(observed)}\n observedValues={observed}\n evidence={cf}\n interventions={interventions}\n stochastic={stochastic}\n removedEdges={world.removedEdges}\n witness={witness}\n holdNotes={holdNotes}\n defaults={defaults}\n paths={paths}\n onOpen={interactive && editable ? toggleMenu : undefined}\n observable={observes}\n open={interactive ? menu : undefined}\n lit={interactive ? lit : undefined}\n onHover={interactive ? onHover : undefined}\n edgeTip={interactive ? tip?.key : undefined}\n onEdgeTip={interactive ? setTip : undefined}\n title={title ?? m.graphTitle(c.data.title[m.locale])}\n onMove={interactive ? onMove : undefined}\n />\n )\n const exportSource = (locale: Locale): ExportSource | undefined =>\n singleGraphSource(c, locale, t, wrap, digits, (m) => graph(m, false), (svg, m) => {\n const tags: ExportTag[] = hasSet\n ? [\n { text: headTag(m), tone: 'slate' },\n { text: chipText(m), tone: 'accent', mono: true },\n ]\n : [{ text: world.probs !== undefined ? m.probability : m.actualWorld, tone: 'fg' }]\n return {\n name: `${c.data.id}-graph`,\n panels: [{ svg, tags, tint: hasSet }],\n legend: legendFor(m),\n }\n })\n /** The menu's observation of `id` at `value` (undefined: no longer observed). */\n const observe = (id: string, value: Value | undefined): void => {\n if (value === undefined) commit(state, withoutKey(observed, id))\n // Observing an intervened node: the value is now observed instead of set.\n else if (!cf && (id in interventions || id in stochastic)) commit(withoutDo(state, id), { ...observed, [id]: value })\n else commit(state, { ...observed, [id]: value })\n }\n /** The menu's do() of `id` at `value` (undefined: released). */\n const intervene = (id: string, value: Value | undefined): void => {\n if (prob && getVariable(c.model, id).domain.kind === 'boolean') doing(withProbability(state, id, value === undefined ? undefined : value === true || value === 1 ? 1 : 0), id)\n else doing({ stochastic, interventions: withValue(interventions, id, value) }, id)\n }\n return (\n <div className={`ca-box ca-graph-box${hasSet ? ' is-cf' : ''}`} data-world={cf && hasDo ? 'counterfactual' : hasDo ? 'do' : hasObs ? 'observed' : 'actual'}>\n <div className=\"ca-box-head\">\n <div className=\"ca-tags\">\n {hasSet ? (\n <>\n <Tag tone=\"slate\">{headTag(t)}</Tag>\n <span className=\"ca-do-chip ca-mono\" data-text={setNow}>\n {grouped ? setNow : cf ? <Rich text={setNow} ids={c.model.byId} /> : <Formula text={setNow} />}\n {editable && (\n <button type=\"button\" className=\"ca-do-clear\" aria-label={hasObs ? t.clearSettings(setNow) : t.removeDo(setNow)} onClick={clearAll}>\n ×\n </button>\n )}\n </span>\n </>\n ) : (\n <Tag tone=\"fg\">{world.probs !== undefined ? t.probability : t.actualWorld}</Tag>\n )}\n </div>\n <div className=\"ca-box-actions\">\n {actions}\n {(hasSet || moved) && editable && (\n <button type=\"button\" className=\"ca-link\" onClick={clearAll}>\n {prob ? t.backToPrior : t.backToActual}\n </button>\n )}\n <ExportMenu source={exportSource} url={exportUrl} origins={originCitations(c)} embedCode={embedCode} />\n </div>\n </div>\n <div className=\"ca-graph-wrap\" ref={wrap}>\n {graph(t, true)}\n {menu !== undefined && (\n <NodeMenu\n c={c}\n id={menu}\n world={world}\n interventions={interventions}\n stochastic={stochastic}\n observed={observed}\n observes={observes}\n intervenes={onDo !== undefined}\n counterfactual={cf}\n pair={paths?.ends}\n extra={menuExtra?.(menu)}\n help={menuHelp}\n interventionNote={holdNotes && witness?.[menu] !== undefined ? marks.hold : holdNotes && isReset(menu) ? marks.reset : undefined}\n onObserve={(v) => observe(menu, v)}\n onDo={(v) => intervene(menu, v)}\n onDoProbability={(p) => doing(withProbability(state, menu, p), menu)}\n onClose={closeMenu}\n style={menuStyle}\n menuRef={menuRef}\n />\n )}\n {tip !== undefined && (\n <div className=\"ca-edge-tip\" role=\"tooltip\" data-edge-tip={tip.key} style={tipStyle}>\n <Rich text={tip.text} ids={c.model.byId} />\n </div>\n )}\n </div>\n {notice !== undefined && (\n <p className=\"ca-notice\" role=\"status\">\n <Rich text={notice} ids={c.model.byId} />\n </p>\n )}\n {legend === true && <p className=\"ca-legend\">{legendFor(t)}</p>}\n {markLegend && <p className=\"ca-legend\" data-mark-legend=\"\">{markLegend}</p>}\n {foot}\n {blocks !== undefined && <FigureTabs blocks={blocks} initial={initialBlock} />}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAUA,IAAMA,IAAmB,CAAC;AAoB1B,SAAgBgC,EAAc,EAAE,MAAG,UAAO,kBAAe,gBAAahC,GAAM,aAAU,eAAY,aAAU,aAAU,YAAS,YAA6B;CAC1J,IAAMiC,IAAiBC,MAAY,oBAAoBC,EAAM,UAAU,KAAA,GACjEC,IAAK;EAAE;EAAG,OAAOD,EAAM;EAAO;EAAU,QAAQA,EAAM;EAAQ;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","valuesEqual","useMessages","originCitations","Formula","Rich","assignmentText","changeNotes","readingText","useDigits","probLegend","solve","withValue","useNarrow","NodeMenu","placeTip","withProbability","useNodeMenu","Segmented","Tag","notations","CopyLatex","Equations","FigureTabs","singleGraphSource","ExportMenu","SignalGraph","Fragment$1","NONE$1","EquationPanel","counterfactual","reading","world","eq","t","notation","onNotation","EquationBox","props","NONE","NO_OBSERVATION","withoutDo","interventions","state","stochastic","id","withoutKey","next","a","GraphBox","digits","notice","setNotice","useState","hasDo","hasObs","observed","hasSet","prob","cf","isReset","witness","grouped","holdNotes","chipText","entries","m","part","group","label","setNow","wrap","useRef","narrow","observes","onObserve","editable","onDo","menu","menuStyle","closeMenu","toggleMenu","tip","setTip","tipStyle","setTipStyle","relative","box","r","el","useLayoutEffect","place","at","p","useEffect","outside","target","escape","legendFor","c","headTag","commit","nextObserved","doing","clearAll","onReset","prior","useMemo","twoValued","abduced","probNotes","out","v","notes","visible","marks","markLegend","from","to","graph","interactive","lit","onHover","title","onMove","exportSource","locale","tags","observe","value","intervene","actions","moved","exportUrl","paths","menuExtra","menuHelp","legend","foot","blocks","initialBlock"],"sources":["../../src/components/panels/EquationBox.tsx","../../src/components/panels/GraphBox.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Prior } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport type { ModelWorld, Reading } from '../model/model-state.ts'\nimport { CopyLatex, Equations } from './Equations.tsx'\nimport type { UiNotation } from '../model/notation.ts'\nimport { notations } from '../model/notation.ts'\nimport { Segmented } from '../shared/parts.tsx'\nimport type { Stochastic } from '../model/assignments.ts'\n\nconst NONE: Stochastic = {}\n\nexport interface EquationPanelProps {\n readonly c: LoadedCase\n readonly world: ModelWorld\n readonly interventions: Assignment\n readonly stochastic?: Stochastic\n readonly notation: UiNotation\n readonly onNotation: (n: UiNotation) => void\n /** Default values: 預設 v beside each equation that has one. */\n readonly defaults?: Assignment\n /** Observations: the causal notation lists only the rows that can hold given them. */\n readonly observed?: Assignment\n /** How the observations are read (see `Reading`). */\n readonly reading?: Reading\n /** The prior when the caller changes it (sliders); default the case's. */\n readonly prior?: Prior\n}\n\n/** The equations with the notation switch and the LaTeX copy above them: the block behind a figure's 式子 tab. */\nexport function EquationPanel({ c, world, interventions, stochastic = NONE, notation, onNotation, defaults, observed, reading, prior }: EquationPanelProps) {\n const counterfactual = reading === 'counterfactual' && world.probs !== undefined\n const eq = { c, shown: world.shown, notation, values: world.values, interventions, stochastic, observed, prior, counterfactual }\n const t = useMessages()\n return (\n <div className=\"ca-eq-panel\">\n <div className=\"ca-eq-head\">\n <Segmented label={t.notationLabel} options={notations(t)} value={notation} onChange={onNotation} />\n <CopyLatex {...eq} />\n </div>\n <Equations {...eq} defaults={defaults} />\n </div>\n )\n}\n\n/** The equations in a box of their own, always open: the editor's, where they are the thing being edited. */\nexport function EquationBox(props: EquationPanelProps) {\n const t = useMessages()\n const { c, world, interventions, stochastic = NONE, notation, onNotation, defaults, observed, reading, prior } = props\n const counterfactual = reading === 'counterfactual' && world.probs !== undefined\n const eq = { c, shown: world.shown, notation, values: world.values, interventions, stochastic, observed, prior, counterfactual }\n return (\n <div className=\"ca-box ca-eq-box\">\n <div className=\"ca-eq-head\">\n <h3 className=\"ca-h3\">{t.equations}</h3>\n <Segmented label={t.notationLabel} options={notations(t)} value={notation} onChange={onNotation} />\n <CopyLatex {...eq} />\n </div>\n <Equations {...eq} defaults={defaults} />\n </div>\n )\n}\n","import type { CSSProperties, ReactNode } from 'react'\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Value } from '../../engine/index.ts'\nimport { formatValue, getVariable, valuesEqual } from '../../engine/index.ts'\nimport { singleGraphSource } from '../export/export-render.tsx'\nimport type { ExportSource, ExportTag } from '../export/export-image.ts'\nimport { ExportMenu } from '../export/ExportMenu.tsx'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { useDigits } from '../shared/digits.ts'\nimport type { PathMarks } from '../model/dsep-view.ts'\nimport type { DoState, ModelWorld, Reading } from '../model/model-state.ts'\nimport { solve, withProbability, withValue } from '../model/model-state.ts'\nimport type { FigureBlock } from '../shared/FigureTabs.tsx'\nimport { FigureTabs } from '../shared/FigureTabs.tsx'\nimport { useNarrow } from '../shared/use-narrow.ts'\nimport { Tag } from '../shared/parts.tsx'\nimport type { EdgeTip } from '../graph/SignalGraph.tsx'\nimport { SignalGraph } from '../graph/SignalGraph.tsx'\nimport type { Rect } from './menu-place.ts'\nimport { placeTip } from './menu-place.ts'\nimport { NodeMenu } from './NodeMenu.tsx'\nimport { useNodeMenu } from './use-node-menu.ts'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport { originCitations } from '../model/verdict-rows.ts'\nimport type { Stochastic } from '../model/assignments.ts'\nimport { assignmentText, changeNotes, probLegend, readingText } from '../model/wording.ts'\n\nexport interface GraphBoxProps {\n readonly c: LoadedCase\n readonly world: ModelWorld\n readonly interventions: Assignment\n /** Stochastic interventions, P*(X=1) per boolean node (probability mode only). */\n readonly stochastic?: Stochastic\n /** A click on a node: the new do() state. */\n readonly onDo?: (next: DoState) => void\n /** Observations the probabilities are conditioned on (probability mode only). */\n readonly observed?: Assignment\n /**\n * The new observations, chosen in a node's menu. Given in probability mode, the menu observes\n * as well as intervenes.\n */\n readonly onObserve?: (next: Assignment) => void\n /** Under the actions of a node's menu: the node's own probability sliders, if any. */\n readonly menuExtra?: (id: string) => ReactNode\n /** Nodes drawn with a soft halo (the ones a hovered slider moves). */\n readonly lit?: readonly string[]\n /** A node is hovered or keyboard-focused, or left (undefined). */\n readonly onHover?: (id: string | undefined) => void\n readonly witness?: Assignment\n /** Held variables show their held and actual values instead of the hull's 見證 tag (see SignalGraph). */\n readonly holdNotes?: boolean\n readonly legend?: boolean\n readonly menuHelp?: string\n readonly title?: string\n /** Link in the exported image's watermark. */\n readonly exportUrl?: string\n /** Node drag in the editor: grid offset in columns and rows. */\n readonly onMove?: (id: string, dCol: number, dRow: number) => void\n /** Builds the embed code (iframe and citation) for the figure as it stands; the export menu offers it when given. */\n readonly embedCode?: () => string\n /** Drawn inside the graph's frame under the legend (the playground's hint and step buttons); not exported. */\n readonly foot?: ReactNode\n /** The blocks under the graph (verdicts, a table, the equations), behind one row of tab buttons (see `FigureTabs`). */\n readonly blocks?: readonly FigureBlock[]\n /** The block open at first, one of `blocks`' ids; none by default. */\n readonly initialBlock?: string\n /** Called when the reader asks for the prior or actual world back (「回到原本」 or the chip's ×). */\n readonly onReset?: () => void\n /** Something `onReset` puts back moved besides what is set on the graph (the playground's sliders): the reset shows. */\n readonly moved?: boolean\n /** Notes under nodes that replace the 原本 v notes of a probability graph. */\n readonly notes?: Readonly<Record<string, string>>\n /**\n * How a probability graph reads what is set (see `Reading`). `counterfactual`: the menu's\n * observations are evidence about the actual world and its do() the hypothetical action; a node\n * may be both; evidence nodes read 實際 v instead of a tag.\n */\n readonly reading?: Reading\n /** Controls in the head, before 「回到原本」 (the playground's reading switch). */\n readonly actions?: ReactNode\n /** Default values: deviant nodes say 偏離(預設 v) (graphs with values). */\n readonly defaults?: Assignment\n /** d-separation marks for a pair (the playground's `dsep`). */\n readonly paths?: PathMarks\n}\n\nconst NONE: Stochastic = {}\n\nconst NO_OBSERVATION: Assignment = {}\n\n/** `do` without `id`, hard or stochastic. */\nfunction withoutDo(state: DoState, id: string): DoState {\n const interventions: Record<string, Assignment[string]> = { ...state.interventions }\n const stochastic: Record<string, number> = { ...state.stochastic }\n delete interventions[id]\n delete stochastic[id]\n return { interventions, stochastic }\n}\n\nfunction withoutKey(a: Assignment, id: string): Assignment {\n const next: Record<string, Assignment[string]> = { ...a }\n delete next[id]\n return next\n}\n\n/**\n * The graph with its world tags. A click on a node opens its menu beside it: do() at each value or\n * release (with a slider for P*(X=1) on a probability graph), and with `onObserve` observing at each\n * value; an observation that cannot happen under what is set is refused with a note. Marked edges\n * (on a d-separation path, cut by do()) explain themselves on hover, focus or a tap.\n */\nexport function GraphBox({\n c,\n world,\n interventions,\n stochastic = NONE,\n onDo,\n observed = NO_OBSERVATION,\n onObserve,\n witness,\n holdNotes,\n legend,\n title,\n exportUrl,\n onMove,\n embedCode,\n foot,\n blocks,\n initialBlock,\n onReset,\n moved = false,\n notes,\n reading = 'interventional',\n actions,\n defaults,\n paths,\n menuExtra,\n menuHelp,\n lit,\n onHover,\n}: GraphBoxProps) {\n const t = useMessages()\n const digits = useDigits()\n const [notice, setNotice] = useState<string | undefined>(undefined)\n const hasDo = Object.keys(interventions).length > 0 || Object.keys(stochastic).length > 0\n const hasObs = Object.keys(observed).length > 0\n const hasSet = hasDo || hasObs\n const state: DoState = { interventions, stochastic }\n const prob = world.probs !== undefined\n const cf = reading === 'counterfactual' && prob\n const isReset = (id: string): boolean => world.original?.[id] !== undefined && id in interventions && valuesEqual(world.original[id], interventions[id]) && witness?.[id] === undefined\n const grouped = holdNotes && !prob && Object.keys(interventions).some((id) => witness?.[id] !== undefined || isReset(id))\n const chipText = (m: Messages): string => {\n const entries = Object.entries(interventions)\n if (!grouped) return readingText(m, cf, interventions, stochastic, observed)\n return m.witness.groupLabels.flatMap((label, group) => {\n const part = entries.filter(([id]) => (witness?.[id] !== undefined ? 1 : isReset(id) ? 2 : 0) === group)\n return part.length ? [`${label}: ${assignmentText(Object.fromEntries(part))}`] : []\n }).join(' | ')\n }\n const setNow = chipText(t)\n const wrap = useRef<HTMLDivElement>(null)\n const narrow = useNarrow(wrap, 560)\n const observes = prob && onObserve !== undefined\n const editable = onDo !== undefined || onObserve !== undefined\n const { anchor: menu, menuRef, style: menuStyle, close: closeMenu, toggle: toggleMenu } = useNodeMenu(wrap, world.shown, world, narrow)\n const [tip, setTip] = useState<EdgeTip | undefined>(undefined)\n const [tipStyle, setTipStyle] = useState<CSSProperties>({ visibility: 'hidden' })\n /** `el`'s box relative to the wrapper. */\n const relative = (el: Element | null | undefined): Rect | undefined => {\n const box = wrap.current?.getBoundingClientRect()\n const r = el?.getBoundingClientRect()\n if (box === undefined || r === undefined) return undefined\n return { left: r.left - box.left, top: r.top - box.top, right: r.right - box.left, bottom: r.bottom - box.top }\n }\n // The edge tip sits above its edge, measured once drawn (and again on resize).\n useLayoutEffect(() => {\n if (tip === undefined) return\n const place = (): void => {\n const at = relative(wrap.current?.querySelector(`[data-edge=\"${tip.key}\"]`))\n setTipStyle(at === undefined ? {} : (() => {\n const p = placeTip(at, wrap.current?.clientWidth ?? 0)\n return { left: p.left, top: p.top, width: p.width }\n })())\n }\n place()\n window.addEventListener('resize', place)\n return () => window.removeEventListener('resize', place)\n }, [menu, tip, world, narrow])\n useEffect(() => {\n if (tip === undefined) return\n const outside = (e: Event): void => {\n const target = e.target\n if (target instanceof Element && !(wrap.current?.contains(target) === true && target.closest('[data-edge]') !== null)) setTip(undefined)\n }\n const escape = (e: globalThis.KeyboardEvent): void => {\n if (e.key === 'Escape') setTip(undefined)\n }\n document.addEventListener('pointerdown', outside)\n document.addEventListener('keydown', escape)\n return () => {\n document.removeEventListener('pointerdown', outside)\n document.removeEventListener('keydown', escape)\n }\n }, [tip])\n const legendFor = (m: Messages): string => (world.probs !== undefined ? probLegend(m, c.model, world.shown) : m.valueLegend)\n const headTag = (m: Messages): string => (cf && hasDo ? m.cf.kicker : hasDo && hasObs ? m.afterDoObserve : hasObs ? m.afterObserve : m.afterDo)\n /** Commit do() and observations together, unless the observations cannot happen under that do(). */\n const commit = (next: DoState, nextObserved: Assignment): void => {\n if (Object.keys(nextObserved).length > 0 && prob) {\n // Counterfactual evidence is about the actual world: it must be possible without the do().\n const evidence = (cf ? solve(c, {}, {}, nextObserved) : solve(c, next.interventions, next.stochastic, nextObserved)).evidence ?? 1\n if (!(evidence > 0)) {\n setNotice(t.observeImpossible(assignmentText(nextObserved)))\n return\n }\n }\n setNotice(undefined)\n if (nextObserved !== observed) onObserve?.(nextObserved)\n if (next.interventions !== interventions || next.stochastic !== stochastic) onDo?.(next)\n }\n // A do() on a node first drops its observation: the node keeps the value, now set by intervention.\n // Read as a counterfactual, the observation stays: what happened, and what is supposed instead.\n const doing = (next: DoState, id: string): void => commit(next, !cf && id in observed ? withoutKey(observed, id) : observed)\n const clearAll = (): void => {\n commit({ interventions: {}, stochastic: NONE }, NO_OBSERVATION)\n onReset?.()\n }\n // A probability graph keeps 原本 v under each 0/1 node whose number moved from the prior.\n const prior = useMemo(() => (prob ? solve(c, {}).probs : undefined), [c, prob])\n const twoValued = world.shown.filter((id) => getVariable(c.model, id).domain.kind === 'boolean')\n // Read as a counterfactual: 實際 v under each evidence node, and under each other node whose\n // number moved from the actual world's (the abduced one).\n const abduced = useMemo(() => (cf ? solve(c, {}, {}, observed).probs : undefined), [c, cf, observed])\n const cfNotes = (m: Messages): Record<string, string> => {\n if (abduced === undefined || world.probs === undefined) return {}\n const out: Record<string, string> = { ...changeNotes(m, abduced, world.probs, twoValued, m.actually, digits) }\n for (const [id, v] of Object.entries(observed)) out[id] = m.actually(formatValue(v))\n return out\n }\n const probNotes =\n prior === undefined || world.probs === undefined\n ? undefined\n : { ...(cf ? cfNotes(t) : changeNotes(t, prior, world.probs, twoValued, undefined, digits)), ...notes }\n const visible = world.shown\n const marks = t.witness.marks\n const markLegend = holdNotes ? [\n visible.some((id) => (id in interventions || id in stochastic) && witness?.[id] === undefined && !isReset(id)) && marks.clamp,\n visible.some(isReset) && marks.reset,\n world.removedEdges.some(({ from, to }) => visible.includes(from) && visible.includes(to)) && marks.cut,\n visible.some((id) => witness?.[id] !== undefined) && marks.hold,\n visible.some((id) => witness?.[id] === undefined && (prob\n ? !cf && probNotes?.[id] !== undefined && !(id in interventions) && !(id in observed)\n : world.original?.[id] !== undefined && world.values?.[id] !== undefined && !valuesEqual(world.original[id], world.values[id]))) && marks.was,\n ].filter(Boolean).join(' · ') : ''\n const graph = (m: Messages, interactive: boolean) => (\n <SignalGraph\n compact={narrow}\n c={c}\n shown={world.shown}\n values={world.values}\n original={world.original}\n probs={world.probs}\n dists={world.dists}\n probNotes={probNotes}\n observed={Object.keys(observed)}\n observedValues={observed}\n evidence={cf}\n interventions={interventions}\n stochastic={stochastic}\n removedEdges={world.removedEdges}\n witness={witness}\n holdNotes={holdNotes}\n defaults={defaults}\n paths={paths}\n onOpen={interactive && editable ? toggleMenu : undefined}\n observable={observes}\n open={interactive ? menu : undefined}\n lit={interactive ? lit : undefined}\n onHover={interactive ? onHover : undefined}\n edgeTip={interactive ? tip?.key : undefined}\n onEdgeTip={interactive ? setTip : undefined}\n title={title ?? m.graphTitle(c.data.title[m.locale])}\n onMove={interactive ? onMove : undefined}\n />\n )\n const exportSource = (locale: Locale): ExportSource | undefined =>\n singleGraphSource(c, locale, t, wrap, digits, (m) => graph(m, false), (svg, m) => {\n const tags: ExportTag[] = hasSet\n ? [\n { text: headTag(m), tone: 'slate' },\n { text: chipText(m), tone: 'accent', mono: true },\n ]\n : [{ text: world.probs !== undefined ? m.probability : m.actualWorld, tone: 'fg' }]\n return {\n name: `${c.data.id}-graph`,\n panels: [{ svg, tags, tint: hasSet }],\n legend: legendFor(m),\n }\n })\n /** The menu's observation of `id` at `value` (undefined: no longer observed). */\n const observe = (id: string, value: Value | undefined): void => {\n if (value === undefined) commit(state, withoutKey(observed, id))\n // Observing an intervened node: the value is now observed instead of set.\n else if (!cf && (id in interventions || id in stochastic)) commit(withoutDo(state, id), { ...observed, [id]: value })\n else commit(state, { ...observed, [id]: value })\n }\n /** The menu's do() of `id` at `value` (undefined: released). */\n const intervene = (id: string, value: Value | undefined): void => {\n if (prob && getVariable(c.model, id).domain.kind === 'boolean') doing(withProbability(state, id, value === undefined ? undefined : value === true || value === 1 ? 1 : 0), id)\n else doing({ stochastic, interventions: withValue(interventions, id, value) }, id)\n }\n return (\n <div className={`ca-box ca-graph-box${hasSet ? ' is-cf' : ''}`} data-world={cf && hasDo ? 'counterfactual' : hasDo ? 'do' : hasObs ? 'observed' : 'actual'}>\n <div className=\"ca-box-head\">\n <div className=\"ca-tags\">\n {hasSet ? (\n <>\n <Tag tone=\"slate\">{headTag(t)}</Tag>\n <span className=\"ca-do-chip ca-mono\" data-text={setNow}>\n {grouped ? setNow : cf ? <Rich text={setNow} ids={c.model.byId} /> : <Formula text={setNow} />}\n {editable && (\n <button type=\"button\" className=\"ca-do-clear\" aria-label={hasObs ? t.clearSettings(setNow) : t.removeDo(setNow)} onClick={clearAll}>\n ×\n </button>\n )}\n </span>\n </>\n ) : (\n <Tag tone=\"fg\">{world.probs !== undefined ? t.probability : t.actualWorld}</Tag>\n )}\n </div>\n <div className=\"ca-box-actions\">\n {actions}\n {(hasSet || moved) && editable && (\n <button type=\"button\" className=\"ca-link\" onClick={clearAll}>\n {prob ? t.backToPrior : t.backToActual}\n </button>\n )}\n <ExportMenu source={exportSource} url={exportUrl} origins={originCitations(c)} embedCode={embedCode} />\n </div>\n </div>\n <div className=\"ca-graph-wrap\" ref={wrap}>\n {graph(t, true)}\n {menu !== undefined && (\n <NodeMenu\n c={c}\n id={menu}\n world={world}\n interventions={interventions}\n stochastic={stochastic}\n observed={observed}\n observes={observes}\n intervenes={onDo !== undefined}\n counterfactual={cf}\n pair={paths?.ends}\n extra={menuExtra?.(menu)}\n help={menuHelp}\n interventionNote={holdNotes && witness?.[menu] !== undefined ? marks.hold : holdNotes && isReset(menu) ? marks.reset : undefined}\n onObserve={(v) => observe(menu, v)}\n onDo={(v) => intervene(menu, v)}\n onDoProbability={(p) => doing(withProbability(state, menu, p), menu)}\n onClose={closeMenu}\n style={menuStyle}\n menuRef={menuRef}\n />\n )}\n {tip !== undefined && (\n <div className=\"ca-edge-tip\" role=\"tooltip\" data-edge-tip={tip.key} style={tipStyle}>\n <Rich text={tip.text} ids={c.model.byId} />\n </div>\n )}\n </div>\n {notice !== undefined && (\n <p className=\"ca-notice\" role=\"status\">\n <Rich text={notice} ids={c.model.byId} />\n </p>\n )}\n {legend === true && <p className=\"ca-legend\">{legendFor(t)}</p>}\n {markLegend && <p className=\"ca-legend\" data-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AE,MAAM;IAAO,CAAA;GACvC,CAAA;GAEJsC,OAAW,MAAQ,kBAAC,KAAD;IAAG,WAAU;IAAa,UAAAvC,GAAUhE,CAAC;GAAK,CAAA;GAC7DkF,MAAc,kBAAC,KAAD;IAAG,WAAU;IAAY,oBAAiB;IAAI,UAAAA;GAAc,CAAA;GAC1EsB;GACAC,MAAW,KAAA,KAAa,kBAACpH,IAAD;IAAoB;IAAQ,SAASqH;GAAe,CAAA;EAC1E;;AAET"}
|
|
@@ -5,7 +5,7 @@ import { i as m, l as h } from "./messages-ZiFmPfDY.js";
|
|
|
5
5
|
import { n as g, t as _ } from "./cases-of-DpCMbUyl.js";
|
|
6
6
|
import { et as v, ot as y, q as b, r as x } from "./doc-case-YauWsu0F.js";
|
|
7
7
|
import { r as S } from "./parts-8cUsl2jJ.js";
|
|
8
|
-
import { i as C, n as w, r as T, t as E } from "./RulesPanel-
|
|
8
|
+
import { i as C, n as w, r as T, t as E } from "./RulesPanel-BXh_JKrO.js";
|
|
9
9
|
import { m as D } from "./use-node-menu-DJISBUAm.js";
|
|
10
10
|
import { useId as O, useMemo as k, useRef as A, useState as j } from "react";
|
|
11
11
|
import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
@@ -615,4 +615,4 @@ function te({ c: e, graph: t, g: n, query: { x: r, y: i, w: a }, edited: s }) {
|
|
|
615
615
|
}
|
|
616
616
|
export { G as t };
|
|
617
617
|
|
|
618
|
-
//# sourceMappingURL=IdentifyPanel-
|
|
618
|
+
//# sourceMappingURL=IdentifyPanel-DNFM0h2W.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifyPanel-COhmqkTf.js","names":["_Fragment","admgForPrior","getVariable","probExprLatex","formatValue","identify","admgOf","derive","checkIdentification","probExprText","buildModel","DerivationError","valuesEqual","problemOf","SignalGraph","LocaleScope","useMessages","CaseGate","casesOf","idWithName","shortLabel","Tex","useCaseOrDoc","DocProblems","isCalculus","SIDE_TOLERANCE","derivationSteps","RulesPanel","targetValue","Fragment$1","asList","ids","querySets","x","w","toggleMember","id","v","order","a","b","matches","y","kind","hasEdge","g","edge","pair","toggleEdge","edges","sameEdges","wouldCycle","from","to","seen","pending","graphCase","domain","variables","c","used","parents","i","latent","equations","p","model","edited","modelComparison","at","row","error","IdentifyPanel","props","IdentifyFor","IdentifyFromSource","resolved","caseId","doc","base","useMemo","t","query","initial","Experiment","m","uid","useId","verdictHeading","useRef","setQuery","useState","draft","setDraft","graph","isOpen","setOpen","outcome","problem","result","hedge","expr","options","lhs","lhsText","focusVerdict","label","EdgeEditor","next","VariableSet","VariableSelect","Numbers","Derivation","HedgeResult","title","onChange","none","checked","value","keep","onToggle","setPair","start","cyclic","has","disabled","onRestore","jump","assignment","same","stepDescription","step","steps","source","earlier","moved","test","head","leftDo","left","rightDo","right","fixed","given","context","removesAction","action","selected","select","origin","d","term"],"sources":["../../src/components/probability/identify-view.ts","../../src/components/probability/IdentifyPanel.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Admg, Expr, IdentificationRow, Value, Variable } from '../../engine/index.ts'\nimport { buildModel, checkIdentification, getVariable, problemOf, valuesEqual } from '../../engine/index.ts'\nimport { targetValue } from '../model/probability-view.ts'\n\n/** A treatment and condition may each be one variable ID or a set of them: `{ x: ['X', 'Z'], y: 'Y' }`. */\nexport interface IdentifyQuery {\n readonly x: string | readonly string[]\n readonly y: string\n readonly w?: string | readonly string[]\n}\n\n/** The panel's working query: treatment and condition as ID lists (x non-empty, w possibly empty). */\nexport interface QuerySets {\n readonly x: readonly string[]\n readonly y: string\n readonly w: readonly string[]\n}\n\nfunction asList(ids: string | readonly string[] | undefined): readonly string[] {\n return ids === undefined ? [] : typeof ids === 'string' ? [ids] : [...new Set(ids)]\n}\n\nexport function querySets({ x, y, w }: IdentifyQuery): QuerySets {\n return { x: asList(x), y, w: asList(w) }\n}\n\n/** Toggle one ID in a set, keeping the graph's node order so formulas read the same however they were picked. */\nexport function toggleMember(ids: readonly string[], id: string, order: readonly string[]): readonly string[] {\n const next = ids.includes(id) ? ids.filter((v) => v !== id) : [...ids, id]\n return [...next].sort((a, b) => order.indexOf(a) - order.indexOf(b))\n}\n\ntype EdgeKind = 'directed' | 'bidirected'\ntype Pair = readonly [string, string]\n\nfunction matches([a, b]: Pair, [x, y]: Pair, kind: EdgeKind): boolean {\n return (a === x && b === y) || (kind === 'bidirected' && a === y && b === x)\n}\n\nexport function hasEdge(g: Admg, kind: EdgeKind, pair: Pair): boolean {\n return g[kind].some((edge) => matches(edge, pair, kind))\n}\n\nexport function toggleEdge(g: Admg, kind: EdgeKind, pair: Pair): Admg {\n const edges = g[kind]\n return { ...g, [kind]: hasEdge(g, kind, pair) ? edges.filter((edge) => !matches(edge, pair, kind)) : [...edges, pair] }\n}\n\nexport function sameEdges(a: Admg, b: Admg): boolean {\n return (['directed', 'bidirected'] as const).every((kind) => a[kind].length === b[kind].length && a[kind].every((pair) => hasEdge(b, kind, pair)))\n}\n\n/** Adding from → to forms a directed cycle exactly when from is already a descendant of to. */\nexport function wouldCycle(g: Admg, [from, to]: Pair): boolean {\n const seen = new Set<string>()\n const pending = [to]\n while (pending.length > 0) {\n const v = pending.pop() as string\n if (v === from) return true\n if (seen.has(v)) continue\n seen.add(v)\n for (const [a, b] of g.directed) if (a === v) pending.push(b)\n }\n return false\n}\n\n/**\n * Lift each bidirected arc to a private latent parent so the existing signal layout and d-separation\n * view can read the ADMG. The Boolean equations only encode adjacency. This case has no prior or\n * context; never use it to evaluate a probability. Numerical comparisons use the original SCM.\n */\nexport function graphCase(c: LoadedCase, g: Admg, edited: boolean): LoadedCase {\n const domain = { kind: 'boolean' } as const\n const variables: Variable[] = g.nodes.map((id) => ({ ...getVariable(c.model, id), domain }))\n const used = new Set(g.nodes)\n const parents = new Map(g.nodes.map((id) => [id, [] as string[]]))\n for (const [from, to] of g.directed) parents.get(to)?.push(from)\n let i = 0\n const latent = g.bidirected.map(([a, b]) => {\n let id: string\n do id = `U_${++i}`; while (used.has(id))\n used.add(id)\n variables.push({ id, kind: 'exogenous', domain, label: { 'zh-TW': id, en: id } })\n parents.get(a)?.push(id)\n parents.get(b)?.push(id)\n return id\n })\n const equations = Object.fromEntries([...parents].map(([id, p]) => {\n const expr: Expr = p.length === 0 ? { op: 'const', value: false } : { op: 'or', args: p.map((name) => ({ op: 'var', name })) }\n return [id, expr]\n }))\n const model = buildModel({ variables, equations })\n return { data: { ...c.data, layout: edited ? undefined : c.data.layout, latent_as_arcs: latent }, model }\n}\n\n/** Use the same readout convention as the other panels: 1 for Booleans, first value for finite domains. */\nexport function modelComparison(c: LoadedCase, edited: boolean, { x, y, w }: QuerySets): IdentificationRow | 'editedNoModel' | 'noModel' | 'noValues' | 'checkBudget' {\n if (edited) return 'editedNoModel'\n if (c.prior === undefined) return 'noModel'\n const ids = [...x, y, ...w]\n const at = ids.map((id) => [id, targetValue(getVariable(c.model, id))] as const)\n try {\n const check = checkIdentification(c.model, c.prior, { x, y: [y], w })\n return check.rows.find((row) => at.every(([id, v]) => valuesEqual(row.at[id] as Value, v))) ?? 'noValues'\n } catch (error) {\n if (problemOf(error)?.code === 'identify-budget') return 'checkBudget'\n throw error\n }\n}\n","import { useId, useMemo, useRef, useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Admg, DerivationStep, DeriveResult, DoAtom, Hedge } from '../../engine/index.ts'\nimport { DerivationError, admgForPrior, admgOf, derive, formatValue, identify, probExprLatex, probExprText, problemOf } from '../../engine/index.ts'\nimport { SignalGraph } from '../graph/SignalGraph.tsx'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { LocaleScope, useMessages } from '../i18n/messages.ts'\nimport { CaseGate } from '../model/CaseGate.tsx'\nimport { casesOf } from '../model/cases-of.ts'\nimport { useCaseOrDoc } from '../model/doc-case.ts'\nimport { idWithName, shortLabel } from '../model/wording.ts'\nimport { DocProblems } from '../shared/parts.tsx'\nimport { Tex } from '../text/Tex.tsx'\nimport type { ProbabilitySource } from './ProbabilityPanel.tsx'\nimport { RulesPanel } from './RulesPanel.tsx'\nimport type { IdentifyQuery, QuerySets } from './identify-view.ts'\nimport { graphCase, hasEdge, modelComparison, querySets, sameEdges, toggleEdge, toggleMember, wouldCycle } from './identify-view.ts'\nimport { SIDE_TOLERANCE, derivationSteps, isCalculus } from './rules-view.ts'\n\nexport type IdentifyPanelProps = (ProbabilitySource | { readonly c: LoadedCase; readonly caseId?: never; readonly doc?: never }) & {\n /** The initial disjoint treatment, outcome and optional observed condition; `x` and `w` take one ID or a set. */\n readonly query?: IdentifyQuery\n readonly locale?: Locale\n}\n\n/** Identify and derive an effect on an editable copy of the model's observed graph. */\nexport function IdentifyPanel({ locale, ...props }: IdentifyPanelProps) {\n return (\n <LocaleScope locale={locale}>\n {'c' in props ? (\n <IdentifyFor c={props.c} query={props.query} />\n ) : (\n <CaseGate ids={casesOf(props.caseId, [props.doc])}>\n <IdentifyFromSource {...props} />\n </CaseGate>\n )}\n </LocaleScope>\n )\n}\n\nfunction IdentifyFromSource({ caseId, doc, query }: ProbabilitySource & { readonly query?: IdentifyQuery }) {\n const resolved = useCaseOrDoc(caseId, doc)\n if (!resolved.ok) return <DocProblems problems={resolved.problems} />\n return <IdentifyFor c={resolved.c} query={query} />\n}\n\nfunction IdentifyFor({ c, query }: { readonly c: LoadedCase; readonly query?: IdentifyQuery }) {\n const base = useMemo(() => c.prior?.kind === 'joint' ? admgForPrior(c.model, c.prior) : admgOf(c.model), [c])\n const t = useMessages()\n if (query === undefined && base.nodes.length < 2) {\n return <p className=\"ca-root not-prose ca-panel ca-id-limit\" lang={t.locale} role=\"status\">{t.identify.needsVariables}</p>\n }\n const initial = querySets(query ?? { x: base.nodes[0], y: base.nodes[1] })\n return <Experiment key={JSON.stringify([c.data.id, base.nodes, initial.x, initial.y, initial.w])} c={c} base={base} initial={initial} />\n}\n\nfunction Experiment({ c, base, initial }: { readonly c: LoadedCase; readonly base: Admg; readonly initial: QuerySets }) {\n const t = useMessages()\n const m = t.identify\n const uid = useId()\n const verdictHeading = useRef<HTMLHeadingElement>(null)\n const [query, setQuery] = useState(initial)\n const [draft, setDraft] = useState<{ readonly base: Admg; readonly graph: Admg }>()\n const g = draft?.base === base ? draft.graph : base\n const edited = !sameEdges(g, base)\n const graph = useMemo(() => graphCase(c, edited ? g : base, edited), [c, base, g, edited])\n const [isOpen, setOpen] = useState(false)\n const { x, y, w } = query\n const outcome = useMemo(() => {\n try {\n return { result: identify(g, [y], x, w) }\n } catch (error) {\n const problem = problemOf(error)\n if (problem === undefined) throw error\n return { problem }\n }\n }, [g, x, y, w])\n if (outcome.problem !== undefined && outcome.problem.code !== 'identify-budget') return <DocProblems problems={[outcome.problem]} />\n const result = outcome.result\n const hedge = result?.identifiable === false ? result.hedge : undefined\n const expr: DoAtom = { kind: 'p', vars: [y], do: x, given: w }\n const options = { names: g.nodes }\n const lhs = probExprLatex(expr, options)\n const lhsText = probExprText(expr, options)\n const focusVerdict = () => {\n verdictHeading.current?.focus({ preventScroll: true })\n verdictHeading.current?.scrollIntoView({ block: 'start' })\n }\n const label = (id: string): string => idWithName(id, shortLabel(c.model, id, t.locale))\n return (\n <section className=\"ca-root not-prose ca-panel ca-identify\" data-case={c.data.id} data-view=\"identify\" lang={t.locale} aria-labelledby={`${uid}-title`}>\n <header className=\"ca-id-header\"><h2 id={`${uid}-title`}>{m.title}</h2></header>\n <section className=\"ca-id-graph\" aria-labelledby={`${uid}-graph`}>\n <div className=\"ca-id-head\">\n <h3 id={`${uid}-graph`}>{m.graph}</h3>\n <button className=\"ca-btn ca-btn-outline\" type=\"button\" aria-expanded={isOpen} aria-controls={`${uid}-editor`} onClick={() => setOpen(!isOpen)}>{isOpen ? m.collapse : m.edit}</button>\n </div>\n <div className=\"ca-id-svg\">\n <SignalGraph c={graph} shown={g.nodes} structural compact hedge={hedge} interventions={{}} removedEdges={[]} title={m.graph} />\n </div>\n <div className=\"ca-id-key\">\n <span className=\"ca-id-directed\">{m.directed}</span><span className=\"ca-id-arc\">{m.arc}</span>\n </div>\n <div id={`${uid}-editor`} hidden={!isOpen}>\n {isOpen && <EdgeEditor g={g} start={[x[0], y]} label={label} edited={edited} onChange={(next) => setDraft({ base, graph: next })} onRestore={() => setDraft(undefined)} jump={focusVerdict} />}\n </div>\n </section>\n <section className=\"ca-id-result\" aria-labelledby={`${uid}-result`}>\n <div className=\"ca-id-head\">\n <h3 id={`${uid}-result`} ref={verdictHeading} tabIndex={-1}>{m.result}</h3>\n {edited && <span className=\"ca-id-muted\">{m.edited}</span>}\n </div>\n <div className=\"ca-id-fields\">\n <VariableSet title={m.x} name={`${uid}-x`} value={x} ids={g.nodes.filter((id) => id !== y && !w.includes(id))} keep label={label} onToggle={(id) => setQuery({ ...query, x: toggleMember(x, id, g.nodes) })} />\n <VariableSelect title={m.y} value={y} ids={g.nodes.filter((id) => !w.includes(id))} label={label} onChange={(id) => setQuery({ ...query, y: id, x: x.includes(id) ? toggleMember(toggleMember(x, id, g.nodes), y, g.nodes) : x })} />\n <VariableSet title={m.w} name={`${uid}-w`} value={w} ids={g.nodes.filter((id) => id !== y && !x.includes(id))} label={label} onToggle={(id) => setQuery({ ...query, w: toggleMember(w, id, g.nodes) })} />\n </div>\n {result === undefined ? <DocProblems problems={outcome.problem === undefined ? [] : [outcome.problem]} /> : (\n <>\n <div className=\"ca-id-verdict\" data-identification={result.identifiable ? 'identified' : 'hedge'} role=\"status\">\n <strong>{result.identifiable ? `✓ ${m.yes}` : m.no}</strong><span data-query={lhsText}><Tex tex={lhs} text={lhsText} /></span>\n </div>\n {result.identifiable ? (\n <>\n <div className=\"ca-id-formula\" data-observational-formula=\"\">\n <p className=\"ca-id-muted\">{m.formula}</p>\n <div className=\"ca-id-math\"><Tex tex={lhs} text={lhsText} /> <Tex tex={`= ${result.latex}`} text={`= ${result.text}`} /></div>\n </div>\n <Numbers c={c} edited={edited} query={query} />\n <Derivation key={JSON.stringify([g.directed, g.bidirected, x, y, w])} c={c} graph={graph} g={g} query={query} edited={edited} />\n </>\n ) : <><HedgeResult hedge={result.hedge} />{edited && <p className=\"ca-id-muted ca-id-limit\">{m.editedNoModel}</p>}</>}\n </>\n )}\n </section>\n </section>\n )\n}\n\nfunction VariableSelect({ title, ids, value, none, label, onChange }: {\n readonly title: string; readonly ids: readonly string[]; readonly value: string; readonly none?: string\n readonly label: (id: string) => string; readonly onChange: (id: string) => void\n}) {\n return <label className=\"ca-id-select\"><span>{title}</span><select value={value} onChange={(e) => onChange(e.currentTarget.value)}>\n {none !== undefined && <option value=\"\">{none}</option>}\n {ids.map((id) => <option key={id} value={id}>{label(id)}</option>)}\n </select></label>\n}\n\n/** A set of IDs as checkboxes; `keep` stops the last checked one being cleared (the treatment is never empty). */\nfunction VariableSet({ title, name, ids, value, keep = false, label, onToggle }: {\n readonly title: string; readonly name: string; readonly ids: readonly string[]; readonly value: readonly string[]; readonly keep?: boolean\n readonly label: (id: string) => string; readonly onToggle: (id: string) => void\n}) {\n return <fieldset className=\"ca-id-select ca-id-set\"><legend>{title}</legend><div className=\"ca-id-checks\">\n {ids.map((id) => {\n const checked = value.includes(id)\n return <label key={id}><input type=\"checkbox\" name={name} value={id} checked={checked} disabled={keep && checked && value.length === 1} onChange={() => onToggle(id)} />{label(id)}</label>\n })}\n </div></fieldset>\n}\n\nfunction EdgeEditor({ g, start, label, edited, onChange, onRestore, jump }: {\n readonly g: Admg; readonly start: readonly [string, string]; readonly label: (id: string) => string\n readonly edited: boolean; readonly onChange: (g: Admg) => void; readonly onRestore: () => void; readonly jump: () => void\n}) {\n const m = useMessages().identify\n const [pair, setPair] = useState(start)\n const [a, b] = pair\n const uid = useId()\n const cyclic = !hasEdge(g, 'directed', pair) && wouldCycle(g, pair)\n return (\n <div className=\"ca-id-editor\">\n <h4>{m.edges}</h4>\n <p className=\"ca-id-muted\">{m.edgeHint}</p>\n <div className=\"ca-id-edgedesc\">\n <div className=\"ca-id-fields ca-id-endpoints\">\n <VariableSelect title={m.from} ids={g.nodes} value={a} label={label} onChange={(id) => setPair([id, id === b ? a : b])} />\n <VariableSelect title={m.to} ids={g.nodes} value={b} label={label} onChange={(id) => setPair([id === a ? b : a, id])} />\n </div>\n <div className=\"ca-id-buttons\">\n {(['directed', 'bidirected'] as const).map((kind) => {\n const has = hasEdge(g, kind, pair)\n const edge = `${a} ${kind === 'directed' ? '→' : '↔'} ${b}`\n const disabled = kind === 'directed' && cyclic\n return <button key={kind} type=\"button\" className=\"ca-btn ca-btn-outline\" disabled={disabled} aria-describedby={disabled ? uid : undefined} onClick={() => onChange(toggleEdge(g, kind, pair))}>{(has ? m.remove : m.add)(edge)}</button>\n })}\n <button type=\"button\" className=\"ca-btn ca-btn-outline\" disabled={!edited} onClick={onRestore}>{m.restore}</button>\n </div>\n </div>\n {cyclic && <p id={uid} className=\"ca-id-muted\">{m.cycle}</p>}\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-id-jump\" onClick={jump}>{m.jump}</button>\n </div>\n )\n}\n\nfunction Numbers({ c, edited, query }: { readonly c: LoadedCase; readonly edited: boolean; readonly query: QuerySets }) {\n const m = useMessages().identify\n const row = useMemo(() => modelComparison(c, edited, query), [c, edited, query])\n if (typeof row === 'string') return <p className=\"ca-id-muted ca-id-limit\">{m[row]}</p>\n const assignment = Object.entries(row.at).map(([id, v]) => `${id}=${formatValue(v)}`).join(', ')\n const same = Math.abs(row.formulaValue - row.doValue) < SIDE_TOLERANCE\n return <div className=\"ca-id-check\">\n <p className=\"ca-id-muted\">{m.at(assignment)}</p>\n <dl className=\"ca-id-numbers\">\n <div><dt>{m.formulaValue}</dt><dd className=\"ca-mono\">{row.formulaValue.toFixed(3)}</dd></div>\n <div><dt>{m.doValue}</dt><dd className=\"ca-mono\">{row.doValue.toFixed(3)}</dd></div>\n </dl>\n <p className={same ? 'ca-adj-ok' : 'ca-adj-no'}>{same ? '✓' : '✗'} {same ? m.same : m.different}</p>\n </div>\n}\n\nfunction HedgeResult({ hedge }: { readonly hedge: Hedge }) {\n const m = useMessages().identify\n return <>\n <p className=\"ca-id-why\">{m.why}</p>\n <ul className=\"ca-id-forest\">\n <li><strong>F</strong>{` = {${hedge.f.join(', ')}} · ${m.f}`}</li>\n <li><strong>F′</strong>{` = {${hedge.fPrime.join(', ')}} · ${m.fPrime}`}</li>\n </ul>\n </>\n}\n\nfunction stepDescription(steps: readonly DerivationStep[], i: number, m: Messages['identify']['steps']): string {\n const step = steps[i]\n if (step.kind === 'expand') return step.right.kind === 'sum' ? m.sum(step.right.over.join(', ')) : m.expand\n if (step.kind === 'substitute') {\n const source = steps.slice(0, i).findLastIndex((earlier) => earlier.right === step.right)\n return source < 0 ? m.substitute : m.substituteStep(source + 1)\n }\n if (step.kind !== 'rule') return m[step.kind]\n\n // Use the same graph IDs as the graph and the mockup, and distinguish fixed do() context\n // from observations using the actual two sides, not the graph's combined known set.\n const { left, right, test } = step\n const moved = test.moved.join(', ')\n const head = test.head.join(', ')\n const leftDo = left.do ?? []\n const rightDo = right.do ?? []\n const fixed = leftDo.filter((id) => rightDo.includes(id)).join(', ')\n const given = left.given.filter((id) => right.given.includes(id)).join(', ')\n const context = [fixed && `do(${fixed})`, given].filter(Boolean).join(', ')\n const removesAction = test.moved.some((id) => leftDo.includes(id))\n if (step.rule === 1) {\n return m.context(left.given.some((id) => test.moved.includes(id)) ? m.removeObservation(moved) : m.addObservation(moved), head, context)\n }\n if (step.rule === 2) {\n const action = removesAction ? m.toObservation(moved) : m.toIntervention(moved)\n return fixed === '' && given !== '' ? m.given(given, action) : m.context(action, head, context)\n }\n if (!removesAction) return m.context(m.addIntervention(moved), head, context)\n if (fixed !== '' && given === '') return m.keepIntervention(fixed, moved)\n if (context === '') return m.removeIrrelevantIntervention(moved, head)\n return m.context(m.removeIntervention(moved), head, context)\n}\n\nfunction Derivation({ c, graph, g, query: { x, y, w }, edited }: { readonly c: LoadedCase; readonly graph: LoadedCase; readonly g: Admg; readonly query: QuerySets; readonly edited: boolean }) {\n const t = useMessages()\n const [selected, select] = useState<number>()\n const uid = useId()\n const origin = useMemo(() => {\n let d: DeriveResult\n try {\n d = derive(g, [y], x, w)\n } catch (error) {\n if (error instanceof DerivationError || problemOf(error)?.code === 'identify-budget') return undefined\n throw error\n }\n return d.identifiable ? { steps: derivationSteps(d.steps), descriptions: d.steps.map((_, i) => stepDescription(d.steps, i, t.identify.steps)), matches: d.matches } : undefined\n }, [g, x, y, w, t.identify.steps])\n const options = { names: g.nodes }\n return <section className=\"ca-id-derivation\" aria-labelledby={`${uid}-heading`}>\n <h4 id={`${uid}-heading`}>{t.identify.derivation}</h4>\n {origin === undefined ? <p className=\"ca-id-muted\">{t.identify.derivationUnavailable}</p> : <>\n {!origin.matches && <p className=\"ca-id-muted\">{t.identify.equivalent}</p>}\n {origin.steps.length > 0 && <ol className=\"ca-id-steps\">\n {origin.steps.map((step, i) => <li key={step.label}>\n <button type=\"button\" aria-expanded={selected === i} className=\"ca-id-step\" onClick={() => select(selected === i ? undefined : i)}>\n <span className=\"ca-id-muted\">{step.label}</span>\n <span className=\"ca-id-step-kind\">{isCalculus(step) ? t.rules.calculusTag : t.rules.rule(step.rule)}</span>\n <span className=\"ca-id-step-summary\">{origin.descriptions[i]}</span>\n <span aria-hidden=\"true\" className=\"ca-id-step-open\">{selected === i ? '↑' : '↗'}</span>\n <code className=\"ca-id-muted\">{step.symbolic?.map((term) => probExprText(term, options)).join(' = ')}</code>\n </button>\n </li>)}\n </ol>}\n {selected !== undefined && <RulesPanel key={selected} c={graph} shown={g.nodes} prior={edited ? undefined : c.prior} comparisonModel={c.model} steps={origin.steps} startAt={selected} />}\n </>}\n </section>\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAS8B,EAAO,GAAgE;CAC9E,OAAOC,MAAQ,KAAA,IAAY,CAAC,IAAI,OAAOA,KAAQ,WAAW,CAACA,CAAG,IAAI,CAAC,GAAG,IAAI,IAAIA,CAAG,CAAC;AACpF;AAEA,SAAgBC,EAAU,EAAE,MAAG,MAAG,QAA+B;CAC/D,OAAO;E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,WAAU;OAAe,UAAAqE,EAAK;MAAY,CAAA;MAChD,kBAAC,QAAD;OAAM,WAAU;OAAmB,UAAA3G,EAAW2G,CAAI,IAAIlD,EAAE,MAAM,cAAcA,EAAE,MAAM,KAAKkD,EAAK,IAAI;MAAQ,CAAA;MAC1G,kBAAC,QAAD;OAAM,WAAU;OAAsB,UAAAkB,EAAO,aAAavF;MAAS,CAAA;MACnE,kBAAC,QAAD;OAAM,eAAY;OAAO,WAAU;OAAmB,UAAAqF,MAAarF,IAAI,MAAM;MAAU,CAAA;MACvF,kBAAC,QAAD;OAAM,WAAU;OAAe,UAAAqE,EAAK,UAAU,KAAK,MAAS1H,EAAa8I,GAAMjD,CAAO,CAAC,CAAC,CAAC,KAAK,KAAK;MAAQ,CAAA;KACrG;IACN,CAAA,EAAA,GARoC6B,EAAK,KAQzC,CAAC;GACH,CAAA;GACHgB,MAAa,KAAA,KAAa,kBAACxH,GAAD;IAA2B,GAAGmE;IAAO,OAAOjD,EAAE;IAAO,OAAOsB,IAAS,KAAA,IAAYR,EAAE;IAAO,iBAAiBA,EAAE;IAAO,OAAO0F,EAAO;IAAO,SAASF;GAAW,GAA5IA,CAA4I;EACxL,EAAA,CAAA,CACK;;AACX"}
|
|
1
|
+
{"version":3,"file":"IdentifyPanel-DNFM0h2W.js","names":["_Fragment","admgForPrior","getVariable","probExprLatex","formatValue","identify","admgOf","derive","checkIdentification","probExprText","buildModel","DerivationError","valuesEqual","problemOf","SignalGraph","LocaleScope","useMessages","CaseGate","casesOf","idWithName","shortLabel","Tex","useCaseOrDoc","DocProblems","isCalculus","SIDE_TOLERANCE","derivationSteps","RulesPanel","targetValue","Fragment$1","asList","ids","querySets","x","w","toggleMember","id","v","order","a","b","matches","y","kind","hasEdge","g","edge","pair","toggleEdge","edges","sameEdges","wouldCycle","from","to","seen","pending","graphCase","domain","variables","c","used","parents","i","latent","equations","p","model","edited","modelComparison","at","row","error","IdentifyPanel","props","IdentifyFor","IdentifyFromSource","resolved","caseId","doc","base","useMemo","t","query","initial","Experiment","m","uid","useId","verdictHeading","useRef","setQuery","useState","draft","setDraft","graph","isOpen","setOpen","outcome","problem","result","hedge","expr","options","lhs","lhsText","focusVerdict","label","EdgeEditor","next","VariableSet","VariableSelect","Numbers","Derivation","HedgeResult","title","onChange","none","checked","value","keep","onToggle","setPair","start","cyclic","has","disabled","onRestore","jump","assignment","same","stepDescription","step","steps","source","earlier","moved","test","head","leftDo","left","rightDo","right","fixed","given","context","removesAction","action","selected","select","origin","d","term"],"sources":["../../src/components/probability/identify-view.ts","../../src/components/probability/IdentifyPanel.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Admg, Expr, IdentificationRow, Value, Variable } from '../../engine/index.ts'\nimport { buildModel, checkIdentification, getVariable, problemOf, valuesEqual } from '../../engine/index.ts'\nimport { targetValue } from '../model/probability-view.ts'\n\n/** A treatment and condition may each be one variable ID or a set of them: `{ x: ['X', 'Z'], y: 'Y' }`. */\nexport interface IdentifyQuery {\n readonly x: string | readonly string[]\n readonly y: string\n readonly w?: string | readonly string[]\n}\n\n/** The panel's working query: treatment and condition as ID lists (x non-empty, w possibly empty). */\nexport interface QuerySets {\n readonly x: readonly string[]\n readonly y: string\n readonly w: readonly string[]\n}\n\nfunction asList(ids: string | readonly string[] | undefined): readonly string[] {\n return ids === undefined ? [] : typeof ids === 'string' ? [ids] : [...new Set(ids)]\n}\n\nexport function querySets({ x, y, w }: IdentifyQuery): QuerySets {\n return { x: asList(x), y, w: asList(w) }\n}\n\n/** Toggle one ID in a set, keeping the graph's node order so formulas read the same however they were picked. */\nexport function toggleMember(ids: readonly string[], id: string, order: readonly string[]): readonly string[] {\n const next = ids.includes(id) ? ids.filter((v) => v !== id) : [...ids, id]\n return [...next].sort((a, b) => order.indexOf(a) - order.indexOf(b))\n}\n\ntype EdgeKind = 'directed' | 'bidirected'\ntype Pair = readonly [string, string]\n\nfunction matches([a, b]: Pair, [x, y]: Pair, kind: EdgeKind): boolean {\n return (a === x && b === y) || (kind === 'bidirected' && a === y && b === x)\n}\n\nexport function hasEdge(g: Admg, kind: EdgeKind, pair: Pair): boolean {\n return g[kind].some((edge) => matches(edge, pair, kind))\n}\n\nexport function toggleEdge(g: Admg, kind: EdgeKind, pair: Pair): Admg {\n const edges = g[kind]\n return { ...g, [kind]: hasEdge(g, kind, pair) ? edges.filter((edge) => !matches(edge, pair, kind)) : [...edges, pair] }\n}\n\nexport function sameEdges(a: Admg, b: Admg): boolean {\n return (['directed', 'bidirected'] as const).every((kind) => a[kind].length === b[kind].length && a[kind].every((pair) => hasEdge(b, kind, pair)))\n}\n\n/** Adding from → to forms a directed cycle exactly when from is already a descendant of to. */\nexport function wouldCycle(g: Admg, [from, to]: Pair): boolean {\n const seen = new Set<string>()\n const pending = [to]\n while (pending.length > 0) {\n const v = pending.pop() as string\n if (v === from) return true\n if (seen.has(v)) continue\n seen.add(v)\n for (const [a, b] of g.directed) if (a === v) pending.push(b)\n }\n return false\n}\n\n/**\n * Lift each bidirected arc to a private latent parent so the existing signal layout and d-separation\n * view can read the ADMG. The Boolean equations only encode adjacency. This case has no prior or\n * context; never use it to evaluate a probability. Numerical comparisons use the original SCM.\n */\nexport function graphCase(c: LoadedCase, g: Admg, edited: boolean): LoadedCase {\n const domain = { kind: 'boolean' } as const\n const variables: Variable[] = g.nodes.map((id) => ({ ...getVariable(c.model, id), domain }))\n const used = new Set(g.nodes)\n const parents = new Map(g.nodes.map((id) => [id, [] as string[]]))\n for (const [from, to] of g.directed) parents.get(to)?.push(from)\n let i = 0\n const latent = g.bidirected.map(([a, b]) => {\n let id: string\n do id = `U_${++i}`; while (used.has(id))\n used.add(id)\n variables.push({ id, kind: 'exogenous', domain, label: { 'zh-TW': id, en: id } })\n parents.get(a)?.push(id)\n parents.get(b)?.push(id)\n return id\n })\n const equations = Object.fromEntries([...parents].map(([id, p]) => {\n const expr: Expr = p.length === 0 ? { op: 'const', value: false } : { op: 'or', args: p.map((name) => ({ op: 'var', name })) }\n return [id, expr]\n }))\n const model = buildModel({ variables, equations })\n return { data: { ...c.data, layout: edited ? undefined : c.data.layout, latent_as_arcs: latent }, model }\n}\n\n/** Use the same readout convention as the other panels: 1 for Booleans, first value for finite domains. */\nexport function modelComparison(c: LoadedCase, edited: boolean, { x, y, w }: QuerySets): IdentificationRow | 'editedNoModel' | 'noModel' | 'noValues' | 'checkBudget' {\n if (edited) return 'editedNoModel'\n if (c.prior === undefined) return 'noModel'\n const ids = [...x, y, ...w]\n const at = ids.map((id) => [id, targetValue(getVariable(c.model, id))] as const)\n try {\n const check = checkIdentification(c.model, c.prior, { x, y: [y], w })\n return check.rows.find((row) => at.every(([id, v]) => valuesEqual(row.at[id] as Value, v))) ?? 'noValues'\n } catch (error) {\n if (problemOf(error)?.code === 'identify-budget') return 'checkBudget'\n throw error\n }\n}\n","import { useId, useMemo, useRef, useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Admg, DerivationStep, DeriveResult, DoAtom, Hedge } from '../../engine/index.ts'\nimport { DerivationError, admgForPrior, admgOf, derive, formatValue, identify, probExprLatex, probExprText, problemOf } from '../../engine/index.ts'\nimport { SignalGraph } from '../graph/SignalGraph.tsx'\nimport type { Locale, Messages } from '../i18n/messages.ts'\nimport { LocaleScope, useMessages } from '../i18n/messages.ts'\nimport { CaseGate } from '../model/CaseGate.tsx'\nimport { casesOf } from '../model/cases-of.ts'\nimport { useCaseOrDoc } from '../model/doc-case.ts'\nimport { idWithName, shortLabel } from '../model/wording.ts'\nimport { DocProblems } from '../shared/parts.tsx'\nimport { Tex } from '../text/Tex.tsx'\nimport type { ProbabilitySource } from './ProbabilityPanel.tsx'\nimport { RulesPanel } from './RulesPanel.tsx'\nimport type { IdentifyQuery, QuerySets } from './identify-view.ts'\nimport { graphCase, hasEdge, modelComparison, querySets, sameEdges, toggleEdge, toggleMember, wouldCycle } from './identify-view.ts'\nimport { SIDE_TOLERANCE, derivationSteps, isCalculus } from './rules-view.ts'\n\nexport type IdentifyPanelProps = (ProbabilitySource | { readonly c: LoadedCase; readonly caseId?: never; readonly doc?: never }) & {\n /** The initial disjoint treatment, outcome and optional observed condition; `x` and `w` take one ID or a set. */\n readonly query?: IdentifyQuery\n readonly locale?: Locale\n}\n\n/** Identify and derive an effect on an editable copy of the model's observed graph. */\nexport function IdentifyPanel({ locale, ...props }: IdentifyPanelProps) {\n return (\n <LocaleScope locale={locale}>\n {'c' in props ? (\n <IdentifyFor c={props.c} query={props.query} />\n ) : (\n <CaseGate ids={casesOf(props.caseId, [props.doc])}>\n <IdentifyFromSource {...props} />\n </CaseGate>\n )}\n </LocaleScope>\n )\n}\n\nfunction IdentifyFromSource({ caseId, doc, query }: ProbabilitySource & { readonly query?: IdentifyQuery }) {\n const resolved = useCaseOrDoc(caseId, doc)\n if (!resolved.ok) return <DocProblems problems={resolved.problems} />\n return <IdentifyFor c={resolved.c} query={query} />\n}\n\nfunction IdentifyFor({ c, query }: { readonly c: LoadedCase; readonly query?: IdentifyQuery }) {\n const base = useMemo(() => c.prior?.kind === 'joint' ? admgForPrior(c.model, c.prior) : admgOf(c.model), [c])\n const t = useMessages()\n if (query === undefined && base.nodes.length < 2) {\n return <p className=\"ca-root not-prose ca-panel ca-id-limit\" lang={t.locale} role=\"status\">{t.identify.needsVariables}</p>\n }\n const initial = querySets(query ?? { x: base.nodes[0], y: base.nodes[1] })\n return <Experiment key={JSON.stringify([c.data.id, base.nodes, initial.x, initial.y, initial.w])} c={c} base={base} initial={initial} />\n}\n\nfunction Experiment({ c, base, initial }: { readonly c: LoadedCase; readonly base: Admg; readonly initial: QuerySets }) {\n const t = useMessages()\n const m = t.identify\n const uid = useId()\n const verdictHeading = useRef<HTMLHeadingElement>(null)\n const [query, setQuery] = useState(initial)\n const [draft, setDraft] = useState<{ readonly base: Admg; readonly graph: Admg }>()\n const g = draft?.base === base ? draft.graph : base\n const edited = !sameEdges(g, base)\n const graph = useMemo(() => graphCase(c, edited ? g : base, edited), [c, base, g, edited])\n const [isOpen, setOpen] = useState(false)\n const { x, y, w } = query\n const outcome = useMemo(() => {\n try {\n return { result: identify(g, [y], x, w) }\n } catch (error) {\n const problem = problemOf(error)\n if (problem === undefined) throw error\n return { problem }\n }\n }, [g, x, y, w])\n if (outcome.problem !== undefined && outcome.problem.code !== 'identify-budget') return <DocProblems problems={[outcome.problem]} />\n const result = outcome.result\n const hedge = result?.identifiable === false ? result.hedge : undefined\n const expr: DoAtom = { kind: 'p', vars: [y], do: x, given: w }\n const options = { names: g.nodes }\n const lhs = probExprLatex(expr, options)\n const lhsText = probExprText(expr, options)\n const focusVerdict = () => {\n verdictHeading.current?.focus({ preventScroll: true })\n verdictHeading.current?.scrollIntoView({ block: 'start' })\n }\n const label = (id: string): string => idWithName(id, shortLabel(c.model, id, t.locale))\n return (\n <section className=\"ca-root not-prose ca-panel ca-identify\" data-case={c.data.id} data-view=\"identify\" lang={t.locale} aria-labelledby={`${uid}-title`}>\n <header className=\"ca-id-header\"><h2 id={`${uid}-title`}>{m.title}</h2></header>\n <section className=\"ca-id-graph\" aria-labelledby={`${uid}-graph`}>\n <div className=\"ca-id-head\">\n <h3 id={`${uid}-graph`}>{m.graph}</h3>\n <button className=\"ca-btn ca-btn-outline\" type=\"button\" aria-expanded={isOpen} aria-controls={`${uid}-editor`} onClick={() => setOpen(!isOpen)}>{isOpen ? m.collapse : m.edit}</button>\n </div>\n <div className=\"ca-id-svg\">\n <SignalGraph c={graph} shown={g.nodes} structural compact hedge={hedge} interventions={{}} removedEdges={[]} title={m.graph} />\n </div>\n <div className=\"ca-id-key\">\n <span className=\"ca-id-directed\">{m.directed}</span><span className=\"ca-id-arc\">{m.arc}</span>\n </div>\n <div id={`${uid}-editor`} hidden={!isOpen}>\n {isOpen && <EdgeEditor g={g} start={[x[0], y]} label={label} edited={edited} onChange={(next) => setDraft({ base, graph: next })} onRestore={() => setDraft(undefined)} jump={focusVerdict} />}\n </div>\n </section>\n <section className=\"ca-id-result\" aria-labelledby={`${uid}-result`}>\n <div className=\"ca-id-head\">\n <h3 id={`${uid}-result`} ref={verdictHeading} tabIndex={-1}>{m.result}</h3>\n {edited && <span className=\"ca-id-muted\">{m.edited}</span>}\n </div>\n <div className=\"ca-id-fields\">\n <VariableSet title={m.x} name={`${uid}-x`} value={x} ids={g.nodes.filter((id) => id !== y && !w.includes(id))} keep label={label} onToggle={(id) => setQuery({ ...query, x: toggleMember(x, id, g.nodes) })} />\n <VariableSelect title={m.y} value={y} ids={g.nodes.filter((id) => !w.includes(id))} label={label} onChange={(id) => setQuery({ ...query, y: id, x: x.includes(id) ? toggleMember(toggleMember(x, id, g.nodes), y, g.nodes) : x })} />\n <VariableSet title={m.w} name={`${uid}-w`} value={w} ids={g.nodes.filter((id) => id !== y && !x.includes(id))} label={label} onToggle={(id) => setQuery({ ...query, w: toggleMember(w, id, g.nodes) })} />\n </div>\n {result === undefined ? <DocProblems problems={outcome.problem === undefined ? [] : [outcome.problem]} /> : (\n <>\n <div className=\"ca-id-verdict\" data-identification={result.identifiable ? 'identified' : 'hedge'} role=\"status\">\n <strong>{result.identifiable ? `✓ ${m.yes}` : m.no}</strong><span data-query={lhsText}><Tex tex={lhs} text={lhsText} /></span>\n </div>\n {result.identifiable ? (\n <>\n <div className=\"ca-id-formula\" data-observational-formula=\"\">\n <p className=\"ca-id-muted\">{m.formula}</p>\n <div className=\"ca-id-math\"><Tex tex={lhs} text={lhsText} /> <Tex tex={`= ${result.latex}`} text={`= ${result.text}`} /></div>\n </div>\n <Numbers c={c} edited={edited} query={query} />\n <Derivation key={JSON.stringify([g.directed, g.bidirected, x, y, w])} c={c} graph={graph} g={g} query={query} edited={edited} />\n </>\n ) : <><HedgeResult hedge={result.hedge} />{edited && <p className=\"ca-id-muted ca-id-limit\">{m.editedNoModel}</p>}</>}\n </>\n )}\n </section>\n </section>\n )\n}\n\nfunction VariableSelect({ title, ids, value, none, label, onChange }: {\n readonly title: string; readonly ids: readonly string[]; readonly value: string; readonly none?: string\n readonly label: (id: string) => string; readonly onChange: (id: string) => void\n}) {\n return <label className=\"ca-id-select\"><span>{title}</span><select value={value} onChange={(e) => onChange(e.currentTarget.value)}>\n {none !== undefined && <option value=\"\">{none}</option>}\n {ids.map((id) => <option key={id} value={id}>{label(id)}</option>)}\n </select></label>\n}\n\n/** A set of IDs as checkboxes; `keep` stops the last checked one being cleared (the treatment is never empty). */\nfunction VariableSet({ title, name, ids, value, keep = false, label, onToggle }: {\n readonly title: string; readonly name: string; readonly ids: readonly string[]; readonly value: readonly string[]; readonly keep?: boolean\n readonly label: (id: string) => string; readonly onToggle: (id: string) => void\n}) {\n return <fieldset className=\"ca-id-select ca-id-set\"><legend>{title}</legend><div className=\"ca-id-checks\">\n {ids.map((id) => {\n const checked = value.includes(id)\n return <label key={id}><input type=\"checkbox\" name={name} value={id} checked={checked} disabled={keep && checked && value.length === 1} onChange={() => onToggle(id)} />{label(id)}</label>\n })}\n </div></fieldset>\n}\n\nfunction EdgeEditor({ g, start, label, edited, onChange, onRestore, jump }: {\n readonly g: Admg; readonly start: readonly [string, string]; readonly label: (id: string) => string\n readonly edited: boolean; readonly onChange: (g: Admg) => void; readonly onRestore: () => void; readonly jump: () => void\n}) {\n const m = useMessages().identify\n const [pair, setPair] = useState(start)\n const [a, b] = pair\n const uid = useId()\n const cyclic = !hasEdge(g, 'directed', pair) && wouldCycle(g, pair)\n return (\n <div className=\"ca-id-editor\">\n <h4>{m.edges}</h4>\n <p className=\"ca-id-muted\">{m.edgeHint}</p>\n <div className=\"ca-id-edgedesc\">\n <div className=\"ca-id-fields ca-id-endpoints\">\n <VariableSelect title={m.from} ids={g.nodes} value={a} label={label} onChange={(id) => setPair([id, id === b ? a : b])} />\n <VariableSelect title={m.to} ids={g.nodes} value={b} label={label} onChange={(id) => setPair([id === a ? b : a, id])} />\n </div>\n <div className=\"ca-id-buttons\">\n {(['directed', 'bidirected'] as const).map((kind) => {\n const has = hasEdge(g, kind, pair)\n const edge = `${a} ${kind === 'directed' ? '→' : '↔'} ${b}`\n const disabled = kind === 'directed' && cyclic\n return <button key={kind} type=\"button\" className=\"ca-btn ca-btn-outline\" disabled={disabled} aria-describedby={disabled ? uid : undefined} onClick={() => onChange(toggleEdge(g, kind, pair))}>{(has ? m.remove : m.add)(edge)}</button>\n })}\n <button type=\"button\" className=\"ca-btn ca-btn-outline\" disabled={!edited} onClick={onRestore}>{m.restore}</button>\n </div>\n </div>\n {cyclic && <p id={uid} className=\"ca-id-muted\">{m.cycle}</p>}\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-id-jump\" onClick={jump}>{m.jump}</button>\n </div>\n )\n}\n\nfunction Numbers({ c, edited, query }: { readonly c: LoadedCase; readonly edited: boolean; readonly query: QuerySets }) {\n const m = useMessages().identify\n const row = useMemo(() => modelComparison(c, edited, query), [c, edited, query])\n if (typeof row === 'string') return <p className=\"ca-id-muted ca-id-limit\">{m[row]}</p>\n const assignment = Object.entries(row.at).map(([id, v]) => `${id}=${formatValue(v)}`).join(', ')\n const same = Math.abs(row.formulaValue - row.doValue) < SIDE_TOLERANCE\n return <div className=\"ca-id-check\">\n <p className=\"ca-id-muted\">{m.at(assignment)}</p>\n <dl className=\"ca-id-numbers\">\n <div><dt>{m.formulaValue}</dt><dd className=\"ca-mono\">{row.formulaValue.toFixed(3)}</dd></div>\n <div><dt>{m.doValue}</dt><dd className=\"ca-mono\">{row.doValue.toFixed(3)}</dd></div>\n </dl>\n <p className={same ? 'ca-adj-ok' : 'ca-adj-no'}>{same ? '✓' : '✗'} {same ? m.same : m.different}</p>\n </div>\n}\n\nfunction HedgeResult({ hedge }: { readonly hedge: Hedge }) {\n const m = useMessages().identify\n return <>\n <p className=\"ca-id-why\">{m.why}</p>\n <ul className=\"ca-id-forest\">\n <li><strong>F</strong>{` = {${hedge.f.join(', ')}} · ${m.f}`}</li>\n <li><strong>F′</strong>{` = {${hedge.fPrime.join(', ')}} · ${m.fPrime}`}</li>\n </ul>\n </>\n}\n\nfunction stepDescription(steps: readonly DerivationStep[], i: number, m: Messages['identify']['steps']): string {\n const step = steps[i]\n if (step.kind === 'expand') return step.right.kind === 'sum' ? m.sum(step.right.over.join(', ')) : m.expand\n if (step.kind === 'substitute') {\n const source = steps.slice(0, i).findLastIndex((earlier) => earlier.right === step.right)\n return source < 0 ? m.substitute : m.substituteStep(source + 1)\n }\n if (step.kind !== 'rule') return m[step.kind]\n\n // Use the same graph IDs as the graph and the mockup, and distinguish fixed do() context\n // from observations using the actual two sides, not the graph's combined known set.\n const { left, right, test } = step\n const moved = test.moved.join(', ')\n const head = test.head.join(', ')\n const leftDo = left.do ?? []\n const rightDo = right.do ?? []\n const fixed = leftDo.filter((id) => rightDo.includes(id)).join(', ')\n const given = left.given.filter((id) => right.given.includes(id)).join(', ')\n const context = [fixed && `do(${fixed})`, given].filter(Boolean).join(', ')\n const removesAction = test.moved.some((id) => leftDo.includes(id))\n if (step.rule === 1) {\n return m.context(left.given.some((id) => test.moved.includes(id)) ? m.removeObservation(moved) : m.addObservation(moved), head, context)\n }\n if (step.rule === 2) {\n const action = removesAction ? m.toObservation(moved) : m.toIntervention(moved)\n return fixed === '' && given !== '' ? m.given(given, action) : m.context(action, head, context)\n }\n if (!removesAction) return m.context(m.addIntervention(moved), head, context)\n if (fixed !== '' && given === '') return m.keepIntervention(fixed, moved)\n if (context === '') return m.removeIrrelevantIntervention(moved, head)\n return m.context(m.removeIntervention(moved), head, context)\n}\n\nfunction Derivation({ c, graph, g, query: { x, y, w }, edited }: { readonly c: LoadedCase; readonly graph: LoadedCase; readonly g: Admg; readonly query: QuerySets; readonly edited: boolean }) {\n const t = useMessages()\n const [selected, select] = useState<number>()\n const uid = useId()\n const origin = useMemo(() => {\n let d: DeriveResult\n try {\n d = derive(g, [y], x, w)\n } catch (error) {\n if (error instanceof DerivationError || problemOf(error)?.code === 'identify-budget') return undefined\n throw error\n }\n return d.identifiable ? { steps: derivationSteps(d.steps), descriptions: d.steps.map((_, i) => stepDescription(d.steps, i, t.identify.steps)), matches: d.matches } : undefined\n }, [g, x, y, w, t.identify.steps])\n const options = { names: g.nodes }\n return <section className=\"ca-id-derivation\" aria-labelledby={`${uid}-heading`}>\n <h4 id={`${uid}-heading`}>{t.identify.derivation}</h4>\n {origin === undefined ? <p className=\"ca-id-muted\">{t.identify.derivationUnavailable}</p> : <>\n {!origin.matches && <p className=\"ca-id-muted\">{t.identify.equivalent}</p>}\n {origin.steps.length > 0 && <ol className=\"ca-id-steps\">\n {origin.steps.map((step, i) => <li key={step.label}>\n <button type=\"button\" aria-expanded={selected === i} className=\"ca-id-step\" onClick={() => select(selected === i ? undefined : i)}>\n <span className=\"ca-id-muted\">{step.label}</span>\n <span className=\"ca-id-step-kind\">{isCalculus(step) ? t.rules.calculusTag : t.rules.rule(step.rule)}</span>\n <span className=\"ca-id-step-summary\">{origin.descriptions[i]}</span>\n <span aria-hidden=\"true\" className=\"ca-id-step-open\">{selected === i ? '↑' : '↗'}</span>\n <code className=\"ca-id-muted\">{step.symbolic?.map((term) => probExprText(term, options)).join(' = ')}</code>\n </button>\n </li>)}\n </ol>}\n {selected !== undefined && <RulesPanel key={selected} c={graph} shown={g.nodes} prior={edited ? undefined : c.prior} comparisonModel={c.model} steps={origin.steps} startAt={selected} />}\n </>}\n </section>\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAS8B,EAAO,GAAgE;CAC9E,OAAOC,MAAQ,KAAA,IAAY,CAAC,IAAI,OAAOA,KAAQ,WAAW,CAACA,CAAG,IAAI,CAAC,GAAG,IAAI,IAAIA,CAAG,CAAC;AACpF;AAEA,SAAgBC,EAAU,EAAE,MAAG,MAAG,QAA+B;CAC/D,OAAO;EAAE,GAAGF,EAAOG,CAAC;EAAG;EAAG,GAAGH,EAAOI,CAAC;CAAE;AACzC;AAGA,SAAgBC,EAAa,GAAwB,GAAY,GAA6C;CAE5G,OAAO,CAAC,GADKJ,EAAI,SAASK,CAAE,IAAIL,EAAI,QAAQ,MAAMM,MAAMD,CAAE,IAAI,CAAC,GAAGL,GAAKK,CAAE,CAC1D,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MAAS,CAAA;MACnE,kBAAC,QAAD;OAAM,eAAY;OAAO,WAAU;OAAmB,UAAAqF,MAAarF,IAAI,MAAM;MAAU,CAAA;MACvF,kBAAC,QAAD;OAAM,WAAU;OAAe,UAAAqE,EAAK,UAAU,KAAK,MAAS1H,EAAa8I,GAAMjD,CAAO,CAAC,CAAC,CAAC,KAAK,KAAK;MAAQ,CAAA;KACrG;IACN,CAAA,EAAA,GARoC6B,EAAK,KAQzC,CAAC;GACH,CAAA;GACHgB,MAAa,KAAA,KAAa,kBAACxH,GAAD;IAA2B,GAAGmE;IAAO,OAAOjD,EAAE;IAAO,OAAOsB,IAAS,KAAA,IAAYR,EAAE;IAAO,iBAAiBA,EAAE;IAAO,OAAO0F,EAAO;IAAO,SAASF;GAAW,GAA5IA,CAA4I;EACxL,EAAA,CAAA,CACK;;AACX"}
|
|
@@ -5,7 +5,7 @@ import { a as _, i as v, l as y, n as b, r as x, u as S } from "./parts-8cUsl2jJ
|
|
|
5
5
|
import { t as C } from "./Story-BaEwzLZ9.js";
|
|
6
6
|
import { G as w, H as T, R as E, V as D, W as O, dt as k, j as A, l as j, t as ee, ut as M } from "./doc-case-YauWsu0F.js";
|
|
7
7
|
import { a as te } from "./use-node-menu-DJISBUAm.js";
|
|
8
|
-
import { n as ne, t as re } from "./GraphBox-
|
|
8
|
+
import { n as ne, t as re } from "./GraphBox-K7ziPIVx.js";
|
|
9
9
|
import { E as ie, _t as ae, at as oe, gt as N, ht as se, it as ce, lt as P, nt as le, ot as ue, pt as F, st as I, ut as de, vt as fe } from "./engine-CO00-1sC.js";
|
|
10
10
|
import { i as L } from "./errors-BIaMWtNv.js";
|
|
11
11
|
import { t as pe } from "./download-CPDtyW_P.js";
|
|
@@ -1955,4 +1955,4 @@ function wt({ initial: n = "rock-throwing", initialDoc: r, hash: i, shareHref: a
|
|
|
1955
1955
|
}
|
|
1956
1956
|
export { St as t };
|
|
1957
1957
|
|
|
1958
|
-
//# sourceMappingURL=ModelEditor-
|
|
1958
|
+
//# sourceMappingURL=ModelEditor-DskhGLjq.js.map
|