@react-x11/components 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +6 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/qml/containers.d.ts +3 -0
  7. package/dist/qml/containers.d.ts.map +1 -0
  8. package/dist/qml/containers.js +331 -0
  9. package/dist/qml/containers.js.map +1 -0
  10. package/dist/qml/controls.d.ts +12 -0
  11. package/dist/qml/controls.d.ts.map +1 -0
  12. package/dist/qml/controls.js +21 -0
  13. package/dist/qml/controls.js.map +1 -0
  14. package/dist/qml/globals.d.ts +6 -0
  15. package/dist/qml/globals.d.ts.map +1 -0
  16. package/dist/qml/globals.js +25 -0
  17. package/dist/qml/globals.js.map +1 -0
  18. package/dist/qml/index.d.ts +15 -0
  19. package/dist/qml/index.d.ts.map +1 -0
  20. package/dist/qml/index.js +25 -0
  21. package/dist/qml/index.js.map +1 -0
  22. package/dist/qml/interaction.d.ts +12 -0
  23. package/dist/qml/interaction.d.ts.map +1 -0
  24. package/dist/qml/interaction.js +246 -0
  25. package/dist/qml/interaction.js.map +1 -0
  26. package/dist/qml/ir.d.ts +106 -0
  27. package/dist/qml/ir.d.ts.map +1 -0
  28. package/dist/qml/ir.js +7 -0
  29. package/dist/qml/ir.js.map +1 -0
  30. package/dist/qml/layouts.d.ts +3 -0
  31. package/dist/qml/layouts.d.ts.map +1 -0
  32. package/dist/qml/layouts.js +122 -0
  33. package/dist/qml/layouts.js.map +1 -0
  34. package/dist/qml/models.d.ts +14 -0
  35. package/dist/qml/models.d.ts.map +1 -0
  36. package/dist/qml/models.js +80 -0
  37. package/dist/qml/models.js.map +1 -0
  38. package/dist/qml/objects.d.ts +228 -0
  39. package/dist/qml/objects.d.ts.map +1 -0
  40. package/dist/qml/objects.js +1103 -0
  41. package/dist/qml/objects.js.map +1 -0
  42. package/dist/qml/parse.d.ts +10 -0
  43. package/dist/qml/parse.d.ts.map +1 -0
  44. package/dist/qml/parse.js +607 -0
  45. package/dist/qml/parse.js.map +1 -0
  46. package/dist/qml/qtquick.d.ts +7 -0
  47. package/dist/qml/qtquick.d.ts.map +1 -0
  48. package/dist/qml/qtquick.js +347 -0
  49. package/dist/qml/qtquick.js.map +1 -0
  50. package/dist/qml/react.d.ts +83 -0
  51. package/dist/qml/react.d.ts.map +1 -0
  52. package/dist/qml/react.js +323 -0
  53. package/dist/qml/react.js.map +1 -0
  54. package/dist/qml/resolver.d.ts +38 -0
  55. package/dist/qml/resolver.d.ts.map +1 -0
  56. package/dist/qml/resolver.js +64 -0
  57. package/dist/qml/resolver.js.map +1 -0
  58. package/dist/qml/slots.d.ts +65 -0
  59. package/dist/qml/slots.d.ts.map +1 -0
  60. package/dist/qml/slots.js +230 -0
  61. package/dist/qml/slots.js.map +1 -0
  62. package/dist/qml/states.d.ts +5 -0
  63. package/dist/qml/states.d.ts.map +1 -0
  64. package/dist/qml/states.js +276 -0
  65. package/dist/qml/states.js.map +1 -0
  66. package/dist/qml/view-utils.d.ts +42 -0
  67. package/dist/qml/view-utils.d.ts.map +1 -0
  68. package/dist/qml/view-utils.js +121 -0
  69. package/dist/qml/view-utils.js.map +1 -0
  70. package/dist/tabs/hx.d.ts +18 -0
  71. package/dist/tabs/hx.d.ts.map +1 -0
  72. package/dist/tabs/hx.js +10 -0
  73. package/dist/tabs/hx.js.map +1 -0
  74. package/dist/tabs/index.d.ts +143 -0
  75. package/dist/tabs/index.d.ts.map +1 -0
  76. package/dist/tabs/index.js +602 -0
  77. package/dist/tabs/index.js.map +1 -0
  78. package/dist/terminal/vt/index.d.ts +1 -1
  79. package/dist/terminal/vt/index.d.ts.map +1 -1
  80. package/dist/terminal/vt/index.js +3 -3
  81. package/dist/terminal/vt/index.js.map +1 -1
  82. package/dist/terminal/vt/pty.d.ts +16 -0
  83. package/dist/terminal/vt/pty.d.ts.map +1 -1
  84. package/dist/terminal/vt/pty.js +186 -0
  85. package/dist/terminal/vt/pty.js.map +1 -1
  86. package/package.json +11 -1
  87. package/src/index.ts +44 -0
  88. package/src/qml/containers.tsx +380 -0
  89. package/src/qml/controls.tsx +47 -0
  90. package/src/qml/globals.ts +33 -0
  91. package/src/qml/index.ts +67 -0
  92. package/src/qml/interaction.tsx +317 -0
  93. package/src/qml/ir.ts +80 -0
  94. package/src/qml/layouts.tsx +141 -0
  95. package/src/qml/models.ts +101 -0
  96. package/src/qml/objects.ts +1431 -0
  97. package/src/qml/parse.ts +624 -0
  98. package/src/qml/qtquick.tsx +413 -0
  99. package/src/qml/react.tsx +454 -0
  100. package/src/qml/resolver.ts +99 -0
  101. package/src/qml/slots.ts +249 -0
  102. package/src/qml/states.ts +318 -0
  103. package/src/qml/view-utils.ts +140 -0
  104. package/src/tabs/hx.ts +31 -0
  105. package/src/tabs/index.ts +850 -0
  106. package/src/terminal/vt/index.ts +4 -2
  107. package/src/terminal/vt/pty.ts +243 -0
@@ -0,0 +1,121 @@
1
+ // Helpers every QtQuick view shares: colour conversion, the geometry →
2
+ // style mapping, and the motion merge (Behavior / state transitions /
3
+ // looping animations lowered onto react-x11's own `transition` and
4
+ // `animation` style engines).
5
+ import { QmlInstance } from './objects.js';
6
+ import { geometryStyle } from './react.js';
7
+ import { setupStates } from './states.js';
8
+ export const num = (v) => typeof v === 'number' && Number.isFinite(v) ? v : 0;
9
+ export const str = (v) => (v == null ? '' : String(v));
10
+ /** QML hex colours put alpha FIRST (#AARRGGBB); CSS puts it last. */
11
+ export function qmlColor(v) {
12
+ if (typeof v !== 'string')
13
+ return v == null ? undefined : String(v);
14
+ if (v[0] === '#' && v.length === 9)
15
+ return `#${v.slice(3)}${v.slice(1, 3)}`;
16
+ if (v[0] === '#' && v.length === 5)
17
+ return `#${v.slice(2)}${v.slice(1, 2)}`;
18
+ return v;
19
+ }
20
+ /** QML property name → the style key the renderer animates. */
21
+ export const STYLE_KEY = {
22
+ x: 'left',
23
+ y: 'top',
24
+ width: 'width',
25
+ height: 'height',
26
+ color: 'backgroundColor',
27
+ radius: 'borderRadius',
28
+ };
29
+ /**
30
+ * Merge the instance's motion sources into the style. The renderer
31
+ * animates; the property jumps — the declared divergence from
32
+ * docs/components/qml.md ("Behavior").
33
+ */
34
+ export function applyMotion(inst, style) {
35
+ const motion = inst.state;
36
+ let transition;
37
+ if (motion.behaviors) {
38
+ for (const [prop, beh] of Object.entries(motion.behaviors)) {
39
+ if (beh.slots.get('enabled')?.peek() === false)
40
+ continue;
41
+ const key = STYLE_KEY[prop];
42
+ if (!key)
43
+ continue;
44
+ // A Behavior takes its duration from its animation child; a bare
45
+ // `NumberAnimation on x` carries its own.
46
+ const anim = beh.children.find((c) => c.slots.has('duration'));
47
+ const duration = num(anim?.slot('duration').peek()) ||
48
+ num(beh.slots.get('duration')?.peek()) ||
49
+ 250;
50
+ (transition ??= {})[key] = duration;
51
+ }
52
+ }
53
+ if (motion.stateTransitions) {
54
+ for (const [prop, duration] of Object.entries(motion.stateTransitions)) {
55
+ const key = STYLE_KEY[prop];
56
+ if (key)
57
+ (transition ??= {})[key] = duration;
58
+ }
59
+ }
60
+ if (transition)
61
+ style.transition = transition;
62
+ if (motion.loopAnims) {
63
+ const animation = {};
64
+ for (const [prop, spec] of Object.entries(motion.loopAnims)) {
65
+ const key = STYLE_KEY[prop];
66
+ if (!key)
67
+ continue;
68
+ animation[key] = {
69
+ from: prop === 'color' ? qmlColor(spec.from) : spec.from,
70
+ to: prop === 'color' ? qmlColor(spec.to) : spec.to,
71
+ duration: spec.duration,
72
+ };
73
+ }
74
+ style.animation = animation;
75
+ }
76
+ }
77
+ /** Ref callback capturing the host node for coordinate re-basing, text
78
+ * measurement and `forceActiveFocus()`. */
79
+ export function captureNode(inst) {
80
+ let fn = inst.state.__captureNode;
81
+ if (!fn) {
82
+ fn = (node) => {
83
+ inst.state.node = node;
84
+ };
85
+ inst.state.__captureNode = fn;
86
+ }
87
+ return fn;
88
+ }
89
+ export const hostNode = (inst) => inst.state.node ?? null;
90
+ /** The `anchors.*` slot set every Item carries. */
91
+ export const anchorProperties = {};
92
+ for (const n of [
93
+ 'fill',
94
+ 'centerIn',
95
+ 'left',
96
+ 'right',
97
+ 'top',
98
+ 'bottom',
99
+ 'horizontalCenter',
100
+ 'verticalCenter',
101
+ 'margins',
102
+ 'leftMargin',
103
+ 'rightMargin',
104
+ 'topMargin',
105
+ 'bottomMargin',
106
+ ]) {
107
+ anchorProperties[`anchors.${n}`] = { default: undefined };
108
+ }
109
+ /** Item's own init: focus plumbing and the state engine. A type that
110
+ * declares its own `init` replaces this (registry semantics), so it calls
111
+ * `initItem(inst)` first — Row, Flickable and Loader all do. */
112
+ export function initItem(inst) {
113
+ inst.methods.set('forceActiveFocus', () => {
114
+ const node = hostNode(inst);
115
+ node?.focus?.();
116
+ return undefined;
117
+ });
118
+ setupStates(inst);
119
+ }
120
+ export { geometryStyle };
121
+ //# sourceMappingURL=view-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-utils.js","sourceRoot":"","sources":["../../src/qml/view-utils.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AACtE,mEAAmE;AACnE,8BAA8B;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAU,EAAU,EAAE,CACxC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAA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a;IACb,WAAW;IACX,cAAc;CACf,EAAE,CAAC;IACF,gBAAgB,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC5D,CAAC;AAED;;gEAEgE;AAChE,MAAM,UAAU,QAAQ,CAAC,IAAiB;IACxC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAiC,CAAC;QAC5D,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,WAAW,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Key, ReactElement, ReactNode } from 'react';
2
+ import type { ReactX11Elements, Theme } from 'react-x11';
3
+ /** The host elements, by name. */
4
+ export type Host = ReactX11Elements;
5
+ interface CommonProps {
6
+ key?: Key;
7
+ /** Honoured by every node at runtime; declared only on `<window>` — the
8
+ * same narrow declaration the calendar works around. */
9
+ theme?: Theme | Record<string, string | number>;
10
+ /** The query hook every component forwards (docs/README.md,
11
+ * "Conventions"). react-x11 passes `data-*` through; the declarations
12
+ * just do not spell it, so it is added here rather than cast away at
13
+ * every call site. */
14
+ 'data-testname'?: string;
15
+ }
16
+ export declare function hx<K extends keyof Host>(type: K, props?: (Omit<Host[K], 'theme'> & CommonProps) | null, ...children: ReactNode[]): ReactElement;
17
+ export {};
18
+ //# sourceMappingURL=hx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hx.d.ts","sourceRoot":"","sources":["../../src/tabs/hx.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzD,kCAAkC;AAClC,MAAM,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAEpC,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV;6DACyD;IACzD,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAChD;;;2BAGuB;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,IAAI,EACrC,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,IAAI,EACrD,GAAG,QAAQ,EAAE,SAAS,EAAE,GACvB,YAAY,CAEd"}
@@ -0,0 +1,10 @@
1
+ // `React.createElement`, typed against react-x11's host elements — a copy of
2
+ // `src/timeline/hx.ts`, duplicated on purpose: components in this package do
3
+ // not import each other (a lateral import welds two components into one
4
+ // tree-shaking unit — see AGENTS.md), and fifty shared lines are cheaper than
5
+ // that. See `src/internal/hx.ts` for the full why of the shape.
6
+ import React from 'react';
7
+ export function hx(type, props, ...children) {
8
+ return React.createElement(type, props, ...children);
9
+ }
10
+ //# sourceMappingURL=hx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hx.js","sourceRoot":"","sources":["../../src/tabs/hx.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,8EAA8E;AAC9E,gEAAgE;AAChE,OAAO,KAAK,MAAM,OAAO,CAAC;AAmB1B,MAAM,UAAU,EAAE,CAChB,IAAO,EACP,KAAqD,EACrD,GAAG,QAAqB;IAExB,OAAO,KAAK,CAAC,aAAa,CAAC,IAAc,EAAE,KAAc,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,143 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ import type { Style } from 'react-x11/style';
3
+ /** What `style` props here accept, matching the rest of the package. */
4
+ type StyleInput = Style | Style[];
5
+ export type TabsVariant = 'line' | 'subtle' | 'enclosed' | 'outline' | 'plain';
6
+ export type TabsSize = 'sm' | 'md' | 'lg';
7
+ /** What `onValueChange` reports — Chakra's `details` object, so a handler
8
+ * written for Chakra (`(e) => setValue(e.value)`) transfers unchanged. */
9
+ export interface TabsValueChange {
10
+ value: string;
11
+ }
12
+ export interface TabsProps {
13
+ /** The selected trigger's value. Providing it makes the tabs controlled. */
14
+ value?: string;
15
+ /**
16
+ * The initially selected value, when uncontrolled. There is no implicit
17
+ * default: with neither prop nothing is selected and no panel shows, as in
18
+ * Chakra — the root cannot know its triggers until they mount, and a first
19
+ * render that selected nobody only to snap a frame later would be worse
20
+ * than asking for one line.
21
+ */
22
+ defaultValue?: string;
23
+ /** Selection changed — by click or by keyboard. Fires in controlled and
24
+ * uncontrolled mode alike. */
25
+ onValueChange?(change: TabsValueChange): void;
26
+ /** How the strip is drawn. Default `'line'`. */
27
+ variant?: TabsVariant;
28
+ /** Trigger padding, and the type inside. Default `'md'`. */
29
+ size?: TabsSize;
30
+ /** A vertical strip is a column beside its panel. Default `'horizontal'`. */
31
+ orientation?: 'horizontal' | 'vertical';
32
+ /**
33
+ * `'automatic'` (default) selects as the arrows move, the way a desktop
34
+ * notebook behaves. `'manual'` moves focus only and commits on Enter or
35
+ * Space — what you want when a panel is expensive to build.
36
+ */
37
+ activationMode?: 'automatic' | 'manual';
38
+ /** Triggers share the strip equally, filling its length. Default false. */
39
+ fitted?: boolean;
40
+ /** Where the triggers sit along the strip. Default `'start'`. */
41
+ justify?: 'start' | 'center' | 'end';
42
+ /** Build a panel the first time its tab is selected rather than up front.
43
+ * Default false: every panel mounts, hidden, so its state is live. */
44
+ lazyMount?: boolean;
45
+ /** Unmount a panel when its tab is deselected, giving up its state.
46
+ * Default false. */
47
+ unmountOnExit?: boolean;
48
+ /**
49
+ * The colour the selection takes — Chakra's `colorPalette`, as one colour.
50
+ * A `$token` is resolved against the palette. Default `$accent`.
51
+ */
52
+ accent?: string;
53
+ /**
54
+ * The colour behind the tabs, which is what an `enclosed` or `outline`
55
+ * selected trigger is filled with so it reads as part of the panel.
56
+ * Default `$background`; tabs on a card want `'$surface'`.
57
+ */
58
+ ground?: string;
59
+ /** The root `<box>`'s style — width, padding, `flexGrow`. */
60
+ style?: StyleInput;
61
+ 'data-testname'?: string;
62
+ children?: ReactNode;
63
+ }
64
+ /**
65
+ * Tabs.
66
+ *
67
+ * ```jsx
68
+ * <Tabs defaultValue="members">
69
+ * <TabsList>
70
+ * <TabsTrigger value="members">Members</TabsTrigger>
71
+ * <TabsTrigger value="projects">Projects</TabsTrigger>
72
+ * </TabsList>
73
+ * <TabsContent value="members">…</TabsContent>
74
+ * <TabsContent value="projects">…</TabsContent>
75
+ * </Tabs>
76
+ * ```
77
+ */
78
+ export declare function Tabs(props: TabsProps): ReactElement;
79
+ export interface TabsListProps {
80
+ style?: StyleInput;
81
+ 'data-testname'?: string;
82
+ children?: ReactNode;
83
+ }
84
+ /**
85
+ * The strip of triggers — a single tab stop, walked with the arrows.
86
+ *
87
+ * The arrows are visual, the list is logical: in a mirrored horizontal strip
88
+ * the *next* trigger is the one to the left, and in either direction the walk
89
+ * follows where layout actually put each trigger (sorted by position, not by
90
+ * mount order), wraps at the ends, and skips disabled triggers. Home/End jump
91
+ * to the ends. In `manual` mode focus moves without selecting, and Enter or
92
+ * Space commits — those keys are not handled here, because core makes them
93
+ * the click the trigger's own `onClick` already is.
94
+ */
95
+ export declare function TabsList(props: TabsListProps): ReactElement;
96
+ export interface TabsTriggerProps {
97
+ /** What this trigger selects — the `value` its `<TabsContent>` names. */
98
+ value: string;
99
+ /** Unclickable and skipped by the arrows. */
100
+ disabled?: boolean;
101
+ style?: StyleInput;
102
+ 'data-testname'?: string;
103
+ children?: ReactNode;
104
+ }
105
+ /**
106
+ * One tab. Prose and glyphs alike are legal children — a string is wrapped
107
+ * in `<text>`, and an `<Icon>` inherits the trigger's ink (its `size` does
108
+ * not inherit and has to be named).
109
+ */
110
+ export declare function TabsTrigger(props: TabsTriggerProps): ReactElement;
111
+ export interface TabsIndicatorProps {
112
+ /** Merged over the default chip — a wash of the accent, radius 4. */
113
+ style?: StyleInput;
114
+ }
115
+ /**
116
+ * A marker that follows the selected trigger — Chakra's `Tabs.Indicator`,
117
+ * and like there it is what gives the `plain` variant a look.
118
+ *
119
+ * Write it as a direct child of `<TabsList>`. It renders nothing where it
120
+ * stands: the selected trigger draws it, as a box behind its own label — so
121
+ * layout owns the geometry and a resize, a font change or an RTL mirror can
122
+ * never leave the marker where a trigger used to be. What that costs is the
123
+ * slide: this renderer cannot animate between two mounts, so the marker
124
+ * moves in one step.
125
+ */
126
+ export declare function TabsIndicator(props: TabsIndicatorProps): null;
127
+ export interface TabsContentProps {
128
+ /** Which trigger shows this panel. */
129
+ value: string;
130
+ style?: StyleInput;
131
+ 'data-testname'?: string;
132
+ children?: ReactNode;
133
+ }
134
+ /**
135
+ * One panel. Every panel mounts up front and the unselected ones are
136
+ * `display: 'none'` — out of layout, still alive, so a form half-filled on
137
+ * another tab keeps its state. `lazyMount` defers a panel until its first
138
+ * selection; `unmountOnExit` gives the state up when it hides. Both are on
139
+ * the root, because they are a policy about the set, not about one panel.
140
+ */
141
+ export declare function TabsContent(props: TabsContentProps): ReactElement | null;
142
+ export {};
143
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAc7C,wEAAwE;AACxE,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;AAgBlC,MAAM,MAAM,WAAW,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