@swiftbrowser/react 0.26.10 → 0.28.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/README.md CHANGED
@@ -185,7 +185,11 @@ is `Image(systemName: "swift").font(.system(size: 17, weight: .semibold))
185
185
  .foregroundStyle(.white).frame(width: 32, height: 32).background(.orange, in:
186
186
  RoundedRectangle(cornerRadius: 8))`. Each modifier wraps the view in the same
187
187
  `styled` element the Swift shim emits, so the renderer lays it out
188
- identically. A modifier that must apply twice goes in `modifiers={[…]}`, an
188
+ identically. The order matters as it does in SwiftUI: `aspectRatio={{ ratio: 1,
189
+ contentMode: 'fit' }} frame={{ maxWidth: 420 }}` is a square of at most 420
190
+ (the frame offers at most 420, and the square fits in it), while `frame`
191
+ written first offers the square the full width and then only narrows it. A
192
+ modifier that must apply twice goes in `modifiers={[…]}`, an
189
193
  ordered list. A layered style is an array: `foregroundStyle={['white',
190
194
  'indigo']}` is `.foregroundStyle(.white, .indigo)`, whose second style a
191
195
  `symbolRenderingMode="palette"` symbol draws its disc in. The environment
@@ -300,6 +304,16 @@ title="Rename" action={rename} /></> }}`);
300
304
  `presentationDetents` inside a sheet sets its detents. `useDismiss()` inside
301
305
  a pushed screen or a sheet pops or dismisses it.
302
306
 
307
+ A sheet, a full-screen cover or a popover inherits the environment of the
308
+ view that presents it, as SwiftUI's presentations do, though it is drawn at
309
+ the root: a `defaultMinListRowHeight`, `font`, `fontWeight`, `bold`,
310
+ `monospacedDigit`, `tint`, `lineLimit`, `multilineTextAlignment` or
311
+ `imageScale` set around the presenter reaches the sheet's lists and text,
312
+ and so does one set on the presenting view itself when written after the
313
+ `sheet` (around it, as SwiftUI orders modifiers). An app drawn through
314
+ `RemoteTree` has its sheets inherit the host's environment around the tree
315
+ too.
316
+
303
317
  Navigation is mirrored in the browser's history by default: pushing a
304
318
  screen or presenting a sheet adds an entry, and the browser's back (a
305
319
  phone's edge swipe, Android's back gesture, the toolbar button) pops or
@@ -398,6 +412,19 @@ makes its rows deletable (a swipe, or edit mode's minus) and `onMove` makes
398
412
  them reorder with a grip, with `moveItems` to apply the move to an array.
399
413
  `swipeActions`, `contextMenu` and `listRowBackground` are modifiers on a row.
400
414
 
415
+ `defaultMinListRowHeight` is `.environment(\.defaultMinListRowHeight, _)`:
416
+ set on any view, every list below spaces its rows at least that tall,
417
+ including the lists of an app drawn through `RemoteTree`. A Mac content
418
+ list's rows are 24 by default, where Apple's Mac apps space them like the
419
+ sidebar's, 32: one modifier at an app's top gives them all that. A list's
420
+ own `minRowHeight` overrides it for that list, and a Mac grouped form keeps
421
+ its form rows.
422
+
423
+ ```tsx
424
+ const mac = usePlatform() === 'macos';
425
+ <NavigationSplitView defaultMinListRowHeight={mac ? 32 : undefined} sidebar={…} detail={…} />
426
+ ```
427
+
401
428
  ### Size classes
402
429
 
403
430
  `useHorizontalSizeClass()` is `compact` below 700 points of width (a phone)
@@ -426,7 +453,16 @@ titles when regular and the first column when compact.
426
453
  a number fixes the column's width; `{ min, ideal, max }` starts it at `ideal`
427
454
  and, on a Mac, lets the user drag it between `min` and `max`. Without it the
428
455
  sidebar is the platform's default (140 on a Mac, 320 on an iPad); Apple's Mac
429
- apps use about 200.
456
+ apps use about 200. `onSidebarWidthChange(width)` hears the width the user
457
+ dragged the sidebar to on a Mac, once the drag ends; keep it (in
458
+ `useAppStorage`, say) and pass it back as `ideal` to start there next time, as
459
+ a Mac app restores its columns.
460
+
461
+ On a Mac the sidebar panel's top 44 points are the window's color, where
462
+ macOS draws the title bar behind the window's buttons. A page has no window
463
+ buttons there; `<SwiftUIView sidebarTitleBar={false}>` (or `mount(...,
464
+ { sidebarTitleBar: false })`, `renderer.sidebarTitleBar = false`) keeps the
465
+ panel's sidebar fill to its top. Web only: a native app is in a real window.
430
466
 
431
467
  ### Platform
432
468
 
@@ -11,9 +11,10 @@ export interface ListProps<T = unknown> extends ViewModifiers {
11
11
  /** `.formStyle(_:)` on a `Form`: on a Mac `grouped` lays it out in grouped sections, `columns` (and the default) in the columns style. */
12
12
  formStyle?: 'automatic' | 'grouped' | 'columns';
13
13
  /**
14
- * `.environment(\.defaultMinListRowHeight, _)`: the rows are at least this
15
- * tall. Absent, the platform's default (44 on iOS, 24 on a Mac); a Mac app
16
- * spaces a content list's rows like a sidebar's, 32 (`usePlatform`).
14
+ * This list's rows are at least this tall, over the
15
+ * `defaultMinListRowHeight` set above it (the modifier, which every list
16
+ * below inherits; set it once at an app's top). Absent both, the
17
+ * platform's default (44 on iOS, 24 on a Mac).
17
18
  */
18
19
  minRowHeight?: number;
19
20
  /** Edit mode (`EditButton`). */
@@ -1 +1 @@
1
- {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/components/lists.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAA2D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhG,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAW5F,gEAAgE;AAChE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa;IAC3D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gHAAgH;IAChH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0IAA0I;IAC1I,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAChD;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,sHAAsH;IACtH,SAAS,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,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AAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CAyBtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"remoteTree.d.ts","sourceRoot":"","sources":["../../src/components/remoteTree.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAsF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3H,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK7D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC;AA0DD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,SAAS,CA2E5E"}
1
+ {"version":3,"file":"remoteTree.d.ts","sourceRoot":"","sources":["../../src/components/remoteTree.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAsF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3H,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAM7D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC;AAgED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,SAAS,CA6E5E"}
@@ -40,6 +40,12 @@ export interface NavigationSplitViewProps extends ViewModifiers {
40
40
  * 320 on an iPad).
41
41
  */
42
42
  sidebarWidth?: SplitColumnWidth;
43
+ /**
44
+ * The sidebar was dragged to a new width (a Mac's column divider), once
45
+ * the drag ends: keep it and pass it back as `sidebarWidth`'s `ideal` to
46
+ * start there next time, as a Mac app restores its columns.
47
+ */
48
+ onSidebarWidthChange?: (width: number) => void;
43
49
  }
44
50
  export declare function NavigationSplitView(props: NavigationSplitViewProps): ReactNode;
45
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/components/split.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzG,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAI5D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI9E,MAAM,MAAM,6BAA6B,GAAG,WAAW,GAAG,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAChE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,gDAA6C,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC/D,wBAAwB,CA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KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC/D,wBAAwB,CAAC,EAAE,CAAC,UAAU,EAAE,6BAA6B,KAAK,IAAI,CAAC;IAC/E;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAQD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,SAAS,CAyD9E;AAsDD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,GAAG,IAAI,EAC5B,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,MAAM,IAAI,EACjB,MAAM,UAAO,GACZ,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,IAAI,CAchD;AAED,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAE9E"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import type { RendererEvent } from '@swiftbrowser/web/src/protocol';
9
9
  import type { ReactNode } from 'react';
10
+ import type { Effective } from './tree';
10
11
  export type EventType = RendererEvent['type'];
11
12
  export type EventOf<K extends EventType> = Extract<RendererEvent, {
12
13
  type: K;
@@ -65,6 +66,18 @@ export interface Instance {
65
66
  committedProps: Record<string, unknown> | null;
66
67
  committedParent: TreeNode | null;
67
68
  committedChildren: Instance[];
69
+ /** The element React has it under (virtual kinds included); null while detached. */
70
+ parent: TreeNode | null;
71
+ /** Changed since the last flush (itself, a child, its visibility), or under something that has: resolved again at the next. */
72
+ stale: boolean;
73
+ /** How it was last emitted (tree.ts `Effective`); null before its first flush. */
74
+ entry: Effective | null;
75
+ /** Whether it is in the emitted tree as of the last flush. */
76
+ shown: boolean;
77
+ /** The element it is a child of as emitted: its React parent, or the target it was hoisted to. */
78
+ effectiveParent: TreeNode | null;
79
+ /** The flush that last resolved it (tree.ts `generation`); a reused subtree keeps an older one. */
80
+ resolvedIn: number;
68
81
  }
69
82
  /** The root container, element id 0. */
70
83
  export interface RootNode {
@@ -72,6 +85,9 @@ export interface RootNode {
72
85
  kind: 'root';
73
86
  children: Instance[];
74
87
  committedChildren: Instance[];
88
+ parent: null;
89
+ stale: boolean;
90
+ entry: Effective | null;
75
91
  }
76
92
  export type TreeNode = Instance | RootNode;
77
93
  //# sourceMappingURL=instance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/host/instance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAC/E;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;KAAG,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI;CAAE,GAAG;IAAE,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAA;CAAE,CAAC;AAE3H,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,aAAa,E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  */
5
5
  import Reconciler from 'react-reconciler';
6
6
  import type { Instance } from './instance';
7
- import type { HostTree } from './tree';
7
+ import { type HostTree } from './tree';
8
8
  export declare const reconciler: Reconciler.Reconciler<HostTree, Instance, never, never, never, Instance>;
9
9
  //# sourceMappingURL=reconciler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../src/host/reconciler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2JvC,eAAO,MAAM,UAAU,0EAAyB,CAAC"}
1
+ {"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../src/host/reconciler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAqJlE,eAAO,MAAM,UAAU,0EAAyB,CAAC"}
@@ -4,9 +4,16 @@
4
4
  * (preferences and hoists), diffs the result against what was emitted last
5
5
  * time and produces one render pass: creates and updates, inserts (parents
6
6
  * before children, as the Swift core orders them), removes, `commit`.
7
+ *
8
+ * The flush is incremental: every mutation the reconciler makes marks the
9
+ * instance and its ancestors stale (`markStale`), and a flush resolves and
10
+ * diffs only the stale subtrees, reusing each clean subtree's effective
11
+ * entry from the last flush, what it hoisted and the preferences it sent
12
+ * up replayed into the ancestors resolved again. A knob dragged in a tree
13
+ * of three thousand elements then costs the knob's path, not the tree.
7
14
  */
8
15
  import type { Animation, Op, RendererEvent } from '@swiftbrowser/web/src/protocol';
9
- import { type HostProps, type Instance, type RootNode } from './instance';
16
+ import { type HoistTarget, type HostProps, type Instance, type RootNode, type TreeNode } from './instance';
10
17
  export type OpsSink = (ops: Op[]) => void;
11
18
  export interface HostTreeOptions {
12
19
  /**
@@ -18,6 +25,40 @@ export interface HostTreeOptions {
18
25
  */
19
26
  remote?: boolean;
20
27
  }
28
+ /**
29
+ * What a subtree sends past its top to the ancestors that take it: a
30
+ * preference's props for the nearest element of its target kind, or an
31
+ * element hoisted after that target's own children. Kept with the subtree's
32
+ * entry and replayed when the subtree is reused, resolved against the
33
+ * ancestors it then has.
34
+ */
35
+ type Contribution = {
36
+ kind: 'pref';
37
+ target: HoistTarget | undefined;
38
+ props: Record<string, unknown>;
39
+ } | {
40
+ kind: 'hoist';
41
+ target: HoistTarget | undefined;
42
+ node: Instance;
43
+ };
44
+ /** An element as emitted: its props with the preferences merged in, its children (own, then hoisted), what left it. */
45
+ export interface Effective {
46
+ /** The props as sent: the element's own object until a preference or an inherited title mode writes, then a copy. */
47
+ props: Record<string, unknown>;
48
+ /** The props before the title mode inherited from the screen below (a stack's screens), to derive it from again. */
49
+ base: Record<string, unknown>;
50
+ children: Instance[];
51
+ /** Children hoisted here from inside the subtree, appended after `children` once the whole tree is visited. */
52
+ hoisted: Instance[];
53
+ /** What this subtree sent to the ancestors above it, in visit order. */
54
+ escaping: Contribution[];
55
+ }
56
+ /** `node` changed (its props, its children, its visibility): it and every ancestor are resolved and diffed again at the next flush. */
57
+ export declare function markStale(node: TreeNode): void;
58
+ /** Puts `child` under `parent` at `index` (the end when absent), as the reconciler asks. */
59
+ export declare function attach(parent: TreeNode, child: Instance, index?: number): void;
60
+ /** Takes `child` out of `parent`, if it is there. */
61
+ export declare function detach(parent: TreeNode, child: Instance): void;
21
62
  export declare class HostTree {
22
63
  private readonly sink;
23
64
  private readonly options;
@@ -25,9 +66,10 @@ export declare class HostTree {
25
66
  private nextId;
26
67
  /** Emitted elements by id, for event dispatch. */
27
68
  private readonly live;
28
- private committedLive;
29
69
  /** Ids whose element changed kind: removed at the end of the next flush. */
30
70
  private retired;
71
+ /** Which flush is under way; an instance resolved in it carries the number. */
72
+ private generation;
31
73
  /** `withAnimation`: stamped on the next `commit`. */
32
74
  pendingAnimation: Animation | undefined;
33
75
  /** `withAnimation(_:completionCriteria:_:completion:)`: stamped on the next `commit` with its serial; the callback waits in `completions`. */
@@ -47,6 +89,8 @@ export declare class HostTree {
47
89
  get remote(): boolean;
48
90
  createInstance(props: HostProps): Instance;
49
91
  updateInstance(instance: Instance, next: HostProps): void;
92
+ /** `node` is hidden or shown again (Suspense): it leaves or rejoins the emitted tree. */
93
+ setHidden(instance: Instance, hidden: boolean): void;
50
94
  /** Emit the ops for everything that changed since the last commit. */
51
95
  commit(): void;
52
96
  flush(): Op[];
@@ -57,4 +101,5 @@ export declare class HostTree {
57
101
  }
58
102
  /** Structural equality of JSON-like values. */
59
103
  export declare function deepEqual(a: unknown, b: unknown): boolean;
104
+ export {};
60
105
  //# sourceMappingURL=tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/host/tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAY,EAAE,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAEhH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,IAAI,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqCD,qBAAa,QAAQ;IAmBjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAnB1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAgE;IACvF,OAAO,CAAC,MAAM,CAAK;IACnB,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CA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