@dxos/react-ui-rdf 0.0.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/FactViewer.tsx", "../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useMemo, useState } from 'react';\n\nimport { type RDF, buildFactGraph, factSourceFromFacts } from '@dxos/pipeline-rdf';\nimport { Icon, IconButton, Input, Panel, ScrollArea, Tag, type ThemedClassName, Toolbar } from '@dxos/react-ui';\nimport { Tree } from '@dxos/react-ui-graph';\nimport { Empty, Listbox } from '@dxos/react-ui-list';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Group, factualityColor, formatDate, formatTerm, graphToTreeNode, groupFacts, termKey } from './types';\n\ntype View = 'list' | 'graph';\n\nexport type FactViewerProps = ThemedClassName<{\n facts: RDF.Fact[];\n /** Context entity id; scopes the list and roots the graph. */\n context?: string;\n /** Predicate filter; when set, only facts with this predicate are shown. */\n predicate?: string;\n}>;\n\n/**\n * Viewer for extracted semantic facts with two views: a grouped **list** (by subject entity, with\n * conflicts highlighted) and a **graph** (tidy tree rooted at the context entity, exploring the fact\n * graph). A `context` entity scopes the list and roots the graph; a `predicate` further filters the\n * list. Pure/presentational.\n */\nexport const FactViewer = ({ classNames, facts, context, predicate }: FactViewerProps) => {\n const [filter, setFilter] = useState('');\n const [view, setView] = useState<View>('list');\n const scoped = useMemo(\n () =>\n facts.filter(\n (fact) =>\n (context == null ||\n termKey(fact.assertion.subject) === context ||\n termKey(fact.assertion.object) === context) &&\n (predicate == null || fact.assertion.predicate === predicate),\n ),\n [facts, context, predicate],\n );\n const groups = useMemo(() => groupFacts(scoped, filter), [scoped, filter]);\n const graph = useMemo(\n () => (context == null ? undefined : graphToTreeNode(buildFactGraph(context, factSourceFromFacts(facts)), context)),\n [facts, context],\n );\n\n return (\n <Panel.Root classNames={classNames}>\n <Panel.Toolbar asChild>\n <Toolbar.Root>\n <Input.Root>\n <Input.Label srOnly>Filter facts</Input.Label>\n <Input.TextInput\n placeholder='Filter by entity or predicate…'\n value={filter}\n onChange={(event) => setFilter(event.target.value)}\n />\n </Input.Root>\n <div role='none' className='grow' />\n <IconButton\n icon='ph--list--regular'\n iconOnly\n label='List view'\n variant={view === 'list' ? 'primary' : 'default'}\n onClick={() => setView('list')}\n />\n <IconButton\n icon='ph--graph--regular'\n iconOnly\n label='Graph view'\n variant={view === 'graph' ? 'primary' : 'default'}\n onClick={() => setView('graph')}\n />\n </Toolbar.Root>\n </Panel.Toolbar>\n {view === 'list' ? (\n <Panel.Content asChild>\n <ScrollArea.Root padding>\n <ScrollArea.Viewport classNames='flex flex-col gap-2 py-1'>\n {groups.length === 0 && <Empty label='No facts.' />}\n {groups.map((group) => (\n <SubjectGroup key={group.subject} group={group} />\n ))}\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n </Panel.Content>\n ) : (\n <Panel.Content classNames='overflow-hidden'>\n {graph ? (\n <Tree data={graph} variant='tidy' margin={80} classNames='w-full h-full' />\n ) : (\n <Empty icon='ph--graph--regular' label='Select an entity to root the graph.' />\n )}\n </Panel.Content>\n )}\n </Panel.Root>\n );\n};\n\nconst SubjectGroup = ({ group }: { group: Group }) => (\n <div className='shrink-0 flex flex-col bg-card-surface border border-subdued-separator rounded-sm overflow-hidden'>\n <div className='flex px-3 py-1 items-center justify-between'>\n <h3>{group.subject}</h3>\n {group.conflicted && (\n <Tag hue='warning'>\n <span className='flex items-center gap-1'>\n <Icon icon='ph--warning--regular' size={3} />\n conflict\n </span>\n </Tag>\n )}\n </div>\n <Listbox.Root>\n <Listbox.Content aria-label={group.subject}>\n {group.facts.map((fact) => (\n <FactRow key={fact.id} fact={fact} conflicting={group.conflictedIds.has(fact.id)} />\n ))}\n </Listbox.Content>\n </Listbox.Root>\n </div>\n);\n\nconst cellClassNames =\n 'bg-input-surface border border-subdued-separator rounded-sm px-2 py-0.5 font-medium whitespace-nowrap truncate';\n\nconst FactRow = ({ fact, conflicting }: { fact: RDF.Fact; conflicting: boolean }) => {\n const { assertion, factuality, attribution } = fact;\n return (\n <Listbox.Item\n id={fact.id}\n classNames={mx('flex flex-col items-stretch gap-2 px-3 py-1', conflicting && 'border-is-2 border-warning-border')}\n >\n {assertion.quote && <div className='text-sm text-description italic'>\"{assertion.quote}\"</div>}\n\n <div className='grid grid-cols-[1fr_5rem] items-center justify-between gap-2'>\n <div className='w-full grid grid-cols-[1fr_1rem_1fr_1rem_1fr] items-center flex-wrap'>\n <span className={mx(cellClassNames, 'text-right')}>{formatTerm(assertion.subject)}</span>\n <span className='border border-subdued-separator'></span>\n <span className={mx(cellClassNames, 'text-center text-description')}>{assertion.predicate}</span>\n <span className='border border-subdued-separator'></span>\n <span className={mx(cellClassNames)}>{formatTerm(assertion.object)}</span>\n </div>\n\n <div className='flex items-center justify-end gap-2 shrink-0'>\n {factuality.confidence != null && (\n <span className='text-xs text-subdued'>{Math.round(factuality.confidence * 100)}%</span>\n )}\n <Tag hue={factualityColor(factuality.value)}>{factuality.value}</Tag>\n </div>\n </div>\n\n <div className='text-xs text-subdued text-right'>\n {[attribution.agent, attribution.source, formatDate(attribution.generatedAtTime)].filter(Boolean).join(' · ')}\n </div>\n </Listbox.Item>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type FactGraph, type RDF } from '@dxos/pipeline-rdf';\nimport { type TreeNode } from '@dxos/react-ui-graph';\nimport { type ChromaticPalette, type MessageValence, type NeutralPalette } from '@dxos/ui-types';\n\nexport type Group = {\n subject: string;\n facts: RDF.Fact[];\n conflicted: boolean;\n conflictedIds: Set<string>;\n};\n\n/** Group facts by subject entity and flag predicate-level conflicts within each group. */\nexport const groupFacts = (facts: RDF.Fact[], filter: string): Group[] => {\n const needle = filter.trim().toLowerCase();\n const filtered = needle\n ? facts.filter((fact) => {\n const { subject, predicate, object } = fact.assertion;\n return [formatTerm(subject), predicate, formatTerm(object)].some((value) =>\n value.toLowerCase().includes(needle),\n );\n })\n : facts;\n\n // Group by the entity slug (so `DXOS`/`dxos` collapse) but remember a display label for the header.\n const bySubject = new Map<string, RDF.Fact[]>();\n const labelByKey = new Map<string, string>();\n for (const fact of filtered) {\n const key = termKey(fact.assertion.subject);\n const list = bySubject.get(key) ?? [];\n list.push(fact);\n bySubject.set(key, list);\n if (!labelByKey.has(key)) {\n labelByKey.set(key, formatTerm(fact.assertion.subject));\n }\n }\n\n return [...bySubject.entries()].map(([key, groupFactsList]) => {\n const subject = labelByKey.get(key) ?? key;\n const byPredicate = new Map<string, RDF.Fact[]>();\n for (const fact of groupFactsList) {\n const list = byPredicate.get(fact.assertion.predicate) ?? [];\n list.push(fact);\n byPredicate.set(fact.assertion.predicate, list);\n }\n\n const conflictedIds = new Set<string>();\n for (const list of byPredicate.values()) {\n const objects = new Set(list.map((fact) => termKey(fact.assertion.object)));\n if (objects.size > 1) {\n for (const fact of list) {\n conflictedIds.add(fact.id);\n }\n }\n }\n\n return {\n subject,\n facts: groupFactsList,\n conflicted: conflictedIds.size > 0,\n conflictedIds,\n };\n });\n};\n\n/** The join/grouping key: the entity slug (or literal). Casing variants collapse to one key. */\nexport const termKey = (term: RDF.Term): string => ('entity' in term ? term.entity : term.literal);\n\n/** Display form: the preserved surface label, else a prettified slug; literals render verbatim. */\nexport const formatTerm = (term: RDF.Term): string =>\n 'entity' in term ? (term.label ?? humanize(term.entity)) : term.literal;\n\n/**\n * Convert a {@link FactGraph} into a rooted {@link TreeNode} hierarchy for the tidy-tree renderer.\n * A fact graph is a general (cyclic) graph; the tidy tree needs a hierarchy, so this takes the BFS\n * spanning tree from `rootId` over the undirected edges (each node appears once). Returns `undefined`\n * if the root isn't in the graph.\n */\nexport const graphToTreeNode = (graph: FactGraph, rootId: string): TreeNode | undefined => {\n const nodeById = new Map(graph.nodes.map((node) => [node.id, node]));\n if (!nodeById.has(rootId)) {\n return undefined;\n }\n const adjacency = new Map<string, string[]>();\n const link = (from: string, to: string) => {\n const list = adjacency.get(from) ?? [];\n list.push(to);\n adjacency.set(from, list);\n };\n for (const edge of graph.edges) {\n link(edge.source, edge.target);\n link(edge.target, edge.source);\n }\n\n const visited = new Set<string>([rootId]);\n const build = (id: string): TreeNode => {\n const children: TreeNode[] = [];\n for (const neighbour of adjacency.get(id) ?? []) {\n if (!visited.has(neighbour)) {\n visited.add(neighbour);\n children.push(build(neighbour));\n }\n }\n return { id, label: nodeById.get(id)?.label ?? id, ...(children.length > 0 ? { children } : {}) };\n };\n return build(rootId);\n};\n\n/** Render ids like `q3-board-meeting` as `Q3 Board Meeting`. */\nexport const humanize = (value: string): string =>\n value.replace(/[-_]/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase());\n\nexport const formatDate = (iso: string): string => iso.slice(0, 10);\n\n/** Map FactBank factuality to a real react-ui palette member. */\nexport const factualityColor = (\n factuality: RDF.FactualityValue,\n): NeutralPalette | ChromaticPalette | MessageValence => {\n switch (factuality) {\n case 'CT+':\n return 'emerald';\n case 'PR+':\n return 'amber';\n case 'PS+':\n return 'sky';\n case 'CT-':\n case 'PR-':\n case 'PS-':\n return 'red';\n case 'CTu':\n case 'Uu':\n default:\n return 'neutral';\n }\n};\n"],
5
+ "mappings": ";;;AAIA,OAAOA,SAASC,SAASC,gBAAgB;AAEzC,SAAmBC,gBAAgBC,2BAA2B;AAC9D,SAASC,MAAMC,YAAYC,OAAOC,OAAOC,YAAYC,KAA2BC,eAAe;AAC/F,SAASC,YAAY;AACrB,SAASC,OAAOC,eAAe;AAC/B,SAASC,UAAU;;;ACMZ,IAAMC,aAAa,CAACC,OAAmBC,WAAAA;AAC5C,QAAMC,SAASD,OAAOE,KAAI,EAAGC,YAAW;AACxC,QAAMC,WAAWH,SACbF,MAAMC,OAAO,CAACK,SAAAA;AACZ,UAAM,EAAEC,SAASC,WAAWC,OAAM,IAAKH,KAAKI;AAC5C,WAAO;MAACC,WAAWJ,OAAAA;MAAUC;MAAWG,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AACnB,KAAAA;IAAIC,KAAKqB,gBAAgBT,WAAWzC,KAAK;KAAIyC,WAAWzC,KAAK,CAAA,CAAA,GAIlE,sBAAA,cAACI,OAAAA;IAAIE,WAAU;KACZ;IAACoC,YAAYS;IAAOT,YAAYU;IAAQC,WAAWX,YAAYY,eAAe;IAAGlF,OAAOmF,OAAAA,EAASC,KAAK,QAAA,CAAA,CAAA;AAI/G;",
6
+ "names": ["React", "useMemo", "useState", "buildFactGraph", "factSourceFromFacts", "Icon", "IconButton", "Input", "Panel", "ScrollArea", "Tag", "Toolbar", "Tree", "Empty", "Listbox", "mx", "groupFacts", "facts", "filter", "needle", "trim", "toLowerCase", "filtered", "fact", "subject", "predicate", "object", "assertion", "formatTerm", "some", "value", "includes", "bySubject", "Map", "labelByKey", "key", "termKey", "list", "get", "push", "set", "has", "entries", "map", "groupFactsList", "byPredicate", "conflictedIds", "Set", "values", "objects", "size", "add", "id", "conflicted", "term", "entity", "literal", "label", "humanize", "graphToTreeNode", "graph", "rootId", "nodeById", "nodes", "node", "undefined", "adjacency", "link", "from", "to", "edge", "edges", "source", "target", "visited", "build", "children", "neighbour", "length", "replace", "char", "toUpperCase", "formatDate", "iso", "slice", "factualityColor", "factuality", "FactViewer", "classNames", "facts", "context", "predicate", "filter", "setFilter", "useState", "view", "setView", "scoped", "useMemo", "fact", "termKey", "assertion", "subject", "object", "groups", "groupFacts", "graph", "undefined", "graphToTreeNode", "buildFactGraph", "factSourceFromFacts", "Panel", "Root", "Toolbar", "asChild", "Input", "Label", "srOnly", "TextInput", "placeholder", "value", "onChange", "event", "target", "div", "role", "className", "IconButton", "icon", "iconOnly", "label", "variant", "onClick", "Content", "ScrollArea", "padding", "Viewport", "length", "Empty", "map", "group", "SubjectGroup", "key", "Tree", "data", "margin", "h3", "conflicted", "Tag", "hue", "span", "Icon", "size", "Listbox", "aria-label", "FactRow", "id", "conflicting", "conflictedIds", "has", "cellClassNames", "factuality", "attribution", "Item", "mx", "quote", "formatTerm", "confidence", "Math", "round", "factualityColor", "agent", "source", "formatDate", "generatedAtTime", "Boolean", "join"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/types.ts":{"bytes":15625,"imports":[],"format":"esm"},"src/FactViewer.tsx":{"bytes":21156,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/pipeline-rdf","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-graph","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/index.ts":{"bytes":463,"imports":[{"path":"src/FactViewer.tsx","kind":"import-statement","original":"./FactViewer"},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":19170},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/pipeline-rdf","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-graph","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["FactViewer","factualityColor","formatDate","formatTerm","graphToTreeNode","groupFacts","humanize","termKey"],"entryPoint":"src/index.ts","inputs":{"src/FactViewer.tsx":{"bytesInOutput":5991},"src/types.ts":{"bytesInOutput":3107},"src/index.ts":{"bytesInOutput":0}},"bytes":9416}}}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { type RDF } from '@dxos/pipeline-rdf';
3
+ import { type ThemedClassName } from '@dxos/react-ui';
4
+ export type FactViewerProps = ThemedClassName<{
5
+ facts: RDF.Fact[];
6
+ /** Context entity id; scopes the list and roots the graph. */
7
+ context?: string;
8
+ /** Predicate filter; when set, only facts with this predicate are shown. */
9
+ predicate?: string;
10
+ }>;
11
+ /**
12
+ * Viewer for extracted semantic facts with two views: a grouped **list** (by subject entity, with
13
+ * conflicts highlighted) and a **graph** (tidy tree rooted at the context entity, exploring the fact
14
+ * graph). A `context` entity scopes the list and roots the graph; a `predicate` further filters the
15
+ * list. Pure/presentational.
16
+ */
17
+ export declare const FactViewer: ({ classNames, facts, context, predicate }: FactViewerProps) => React.JSX.Element;
18
+ //# sourceMappingURL=FactViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FactViewer.d.ts","sourceRoot":"","sources":["../../../src/FactViewer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,KAAK,GAAG,EAAuC,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAmD,KAAK,eAAe,EAAW,MAAM,gBAAgB,CAAC;AAShH,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;IAC5C,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;IAClB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,UAAU,8CAA+C,eAAe,sBAuEpF,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Read-only viewer for extracted semantic facts, rendered against static fixtures (no engine/AI).
3
+ *
4
+ * - `Default` passes `DEMO_FACTS` (includes an Alice→Paris/Rome conflict and a coherent Q3-meeting pair).
5
+ * - `Empty` passes `[]` to show the empty state.
6
+ * - Renders `FactViewer`, which groups facts by subject, flags predicate-level conflicts, and filters.
7
+ * - Minimal decorators (`withTheme` + `withLayout`); purely presentational.
8
+ */
9
+ import { type StoryObj } from '@storybook/react-vite';
10
+ import React from 'react';
11
+ import { type FactViewerProps } from './FactViewer';
12
+ declare const meta: {
13
+ title: string;
14
+ render: (props: FactViewerProps) => React.JSX.Element;
15
+ decorators: import("@storybook/react").Decorator[];
16
+ };
17
+ export default meta;
18
+ type Story = StoryObj<typeof meta>;
19
+ export declare const Default: Story;
20
+ export declare const Empty: Story;
21
+ //# sourceMappingURL=FactViewer.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FactViewer.stories.d.ts","sourceRoot":"","sources":["../../../src/FactViewer.stories.tsx"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAyEhE,QAAA,MAAM,IAAI;;oBAFmB,eAAe;;CAMP,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAInB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './FactViewer';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type FactGraph, type RDF } from '@dxos/pipeline-rdf';
2
+ import { type TreeNode } from '@dxos/react-ui-graph';
3
+ import { type ChromaticPalette, type MessageValence, type NeutralPalette } from '@dxos/ui-types';
4
+ export type Group = {
5
+ subject: string;
6
+ facts: RDF.Fact[];
7
+ conflicted: boolean;
8
+ conflictedIds: Set<string>;
9
+ };
10
+ /** Group facts by subject entity and flag predicate-level conflicts within each group. */
11
+ export declare const groupFacts: (facts: RDF.Fact[], filter: string) => Group[];
12
+ /** The join/grouping key: the entity slug (or literal). Casing variants collapse to one key. */
13
+ export declare const termKey: (term: RDF.Term) => string;
14
+ /** Display form: the preserved surface label, else a prettified slug; literals render verbatim. */
15
+ export declare const formatTerm: (term: RDF.Term) => string;
16
+ /**
17
+ * Convert a {@link FactGraph} into a rooted {@link TreeNode} hierarchy for the tidy-tree renderer.
18
+ * A fact graph is a general (cyclic) graph; the tidy tree needs a hierarchy, so this takes the BFS
19
+ * spanning tree from `rootId` over the undirected edges (each node appears once). Returns `undefined`
20
+ * if the root isn't in the graph.
21
+ */
22
+ export declare const graphToTreeNode: (graph: FactGraph, rootId: string) => TreeNode | undefined;
23
+ /** Render ids like `q3-board-meeting` as `Q3 Board Meeting`. */
24
+ export declare const humanize: (value: string) => string;
25
+ export declare const formatDate: (iso: string) => string;
26
+ /** Map FactBank factuality to a real react-ui palette member. */
27
+ export declare const factualityColor: (factuality: RDF.FactualityValue) => NeutralPalette | ChromaticPalette | MessageValence;
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjG,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,UAAU,UAAW,GAAG,CAAC,IAAI,EAAE,UAAU,MAAM,KAAG,KAAK,EAkDnE,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,OAAO,SAAU,GAAG,CAAC,IAAI,KAAG,MAAyD,CAAC;AAEnG,mGAAmG;AACnG,eAAO,MAAM,UAAU,SAAU,GAAG,CAAC,IAAI,KAAG,MAC6B,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,SAAS,UAAU,MAAM,KAAG,QAAQ,GAAG,SA4B7E,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,MACmC,CAAC;AAE7E,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAA0B,CAAC;AAEpE,iEAAiE;AACjE,eAAO,MAAM,eAAe,eACd,GAAG,CAAC,eAAe,KAC9B,cAAc,GAAG,gBAAgB,GAAG,cAiBtC,CAAC"}