@e2e-dev/web 0.11.0-canary-20260928184528

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 (121) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +138 -0
  4. package/dist/.build.json +1 -0
  5. package/dist/actions.d.ts +23 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +174 -0
  8. package/dist/actions.js.map +1 -0
  9. package/dist/attempt-session.d.ts +77 -0
  10. package/dist/attempt-session.d.ts.map +1 -0
  11. package/dist/attempt-session.js +293 -0
  12. package/dist/attempt-session.js.map +1 -0
  13. package/dist/browser-connection.d.ts +34 -0
  14. package/dist/browser-connection.d.ts.map +1 -0
  15. package/dist/browser-connection.js +86 -0
  16. package/dist/browser-connection.js.map +1 -0
  17. package/dist/capture-scope.d.ts +21 -0
  18. package/dist/capture-scope.d.ts.map +1 -0
  19. package/dist/capture-scope.js +61 -0
  20. package/dist/capture-scope.js.map +1 -0
  21. package/dist/cdp-recovery.d.ts +29 -0
  22. package/dist/cdp-recovery.d.ts.map +1 -0
  23. package/dist/cdp-recovery.js +84 -0
  24. package/dist/cdp-recovery.js.map +1 -0
  25. package/dist/cdp-selectors.d.ts +15 -0
  26. package/dist/cdp-selectors.d.ts.map +1 -0
  27. package/dist/cdp-selectors.js +52 -0
  28. package/dist/cdp-selectors.js.map +1 -0
  29. package/dist/closed-shadow.d.ts +64 -0
  30. package/dist/closed-shadow.d.ts.map +1 -0
  31. package/dist/closed-shadow.js +142 -0
  32. package/dist/closed-shadow.js.map +1 -0
  33. package/dist/dialogs.d.ts +38 -0
  34. package/dist/dialogs.d.ts.map +1 -0
  35. package/dist/dialogs.js +87 -0
  36. package/dist/dialogs.js.map +1 -0
  37. package/dist/engine.d.ts +26 -0
  38. package/dist/engine.d.ts.map +1 -0
  39. package/dist/engine.js +176 -0
  40. package/dist/engine.js.map +1 -0
  41. package/dist/evaluation.d.ts +18 -0
  42. package/dist/evaluation.d.ts.map +1 -0
  43. package/dist/evaluation.js +35 -0
  44. package/dist/evaluation.js.map +1 -0
  45. package/dist/in-page/read-semantics.d.ts +28 -0
  46. package/dist/in-page/read-semantics.d.ts.map +1 -0
  47. package/dist/in-page/read-semantics.js +1178 -0
  48. package/dist/in-page/read-semantics.js.map +1 -0
  49. package/dist/index.d.ts +22 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +14 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/install.d.ts +40 -0
  54. package/dist/install.d.ts.map +1 -0
  55. package/dist/install.js +117 -0
  56. package/dist/install.js.map +1 -0
  57. package/dist/label-selector.d.ts +37 -0
  58. package/dist/label-selector.d.ts.map +1 -0
  59. package/dist/label-selector.js +53 -0
  60. package/dist/label-selector.js.map +1 -0
  61. package/dist/locators.d.ts +76 -0
  62. package/dist/locators.d.ts.map +1 -0
  63. package/dist/locators.js +289 -0
  64. package/dist/locators.js.map +1 -0
  65. package/dist/observation-capture.d.ts +12 -0
  66. package/dist/observation-capture.d.ts.map +1 -0
  67. package/dist/observation-capture.js +93 -0
  68. package/dist/observation-capture.js.map +1 -0
  69. package/dist/observation.d.ts +63 -0
  70. package/dist/observation.d.ts.map +1 -0
  71. package/dist/observation.js +280 -0
  72. package/dist/observation.js.map +1 -0
  73. package/dist/observe.d.ts +51 -0
  74. package/dist/observe.d.ts.map +1 -0
  75. package/dist/observe.js +105 -0
  76. package/dist/observe.js.map +1 -0
  77. package/dist/operation-budget.d.ts +11 -0
  78. package/dist/operation-budget.d.ts.map +1 -0
  79. package/dist/operation-budget.js +40 -0
  80. package/dist/operation-budget.js.map +1 -0
  81. package/dist/protected-app.d.ts +32 -0
  82. package/dist/protected-app.d.ts.map +1 -0
  83. package/dist/protected-app.js +39 -0
  84. package/dist/protected-app.js.map +1 -0
  85. package/dist/provider.d.ts +158 -0
  86. package/dist/provider.d.ts.map +1 -0
  87. package/dist/provider.js +311 -0
  88. package/dist/provider.js.map +1 -0
  89. package/dist/read-node.d.ts +152 -0
  90. package/dist/read-node.d.ts.map +1 -0
  91. package/dist/read-node.js +42 -0
  92. package/dist/read-node.js.map +1 -0
  93. package/dist/refs.d.ts +43 -0
  94. package/dist/refs.d.ts.map +1 -0
  95. package/dist/refs.js +85 -0
  96. package/dist/refs.js.map +1 -0
  97. package/dist/route-pattern.d.ts +13 -0
  98. package/dist/route-pattern.d.ts.map +1 -0
  99. package/dist/route-pattern.js +55 -0
  100. package/dist/route-pattern.js.map +1 -0
  101. package/dist/selector-engines.d.ts +6 -0
  102. package/dist/selector-engines.d.ts.map +1 -0
  103. package/dist/selector-engines.js +8 -0
  104. package/dist/selector-engines.js.map +1 -0
  105. package/dist/support.d.ts +147 -0
  106. package/dist/support.d.ts.map +1 -0
  107. package/dist/support.js +366 -0
  108. package/dist/support.js.map +1 -0
  109. package/dist/surface.d.ts +313 -0
  110. package/dist/surface.d.ts.map +1 -0
  111. package/dist/surface.js +691 -0
  112. package/dist/surface.js.map +1 -0
  113. package/dist/video.d.ts +59 -0
  114. package/dist/video.d.ts.map +1 -0
  115. package/dist/video.js +116 -0
  116. package/dist/video.js.map +1 -0
  117. package/dist/web.d.ts +191 -0
  118. package/dist/web.d.ts.map +1 -0
  119. package/dist/web.js +382 -0
  120. package/dist/web.js.map +1 -0
  121. package/package.json +67 -0
package/dist/engine.js ADDED
@@ -0,0 +1,176 @@
1
+ /**
2
+ * The Playwright engine for e2e: a browser body built with the
3
+ * public `defineEngine`, validated by the same rules and graded by the same
4
+ * capabilities as any other engine. Core imports nothing from here; this
5
+ * package imports the contract from `e2e/engine` and contributes the `web`
6
+ * fixture the way a device engine contributes `device`.
7
+ */
8
+ import { ConfigurationError, defineEngine, LOCATOR_ACTION_KINDS, POINTER_ACTION_KINDS, obj, } from 'e2e/engine';
9
+ import { createRequire } from 'node:module';
10
+ import { asBrowserProvider } from './provider.js';
11
+ import { PlaywrightSurface } from './surface.js';
12
+ import { createWebFixture } from './web.js';
13
+ /** Creates one Playwright engine: one browser per worker, one context per attempt. */
14
+ const surfaces = new WeakMap();
15
+ /** The live surface of a handle this module created, or undefined for any other engine. */
16
+ export function surfaceOf(engine) {
17
+ const surface = surfaces.get(engine);
18
+ if (surface === undefined)
19
+ return undefined;
20
+ return { page: () => surface.requirePage(), context: () => surface.requireContext() };
21
+ }
22
+ export function web(options = {}) {
23
+ const provider = typeof options.browser === 'object' && options.browser !== null ? asBrowserProvider(options.browser) : undefined;
24
+ if (provider !== undefined && options.connect !== undefined) {
25
+ throw new ConfigurationError('INVALID_CONFIG', `web({ browser, connect }) names two browser sources; browser provider "${provider.name}" leases its own browsers, so remove connect`);
26
+ }
27
+ if (options.connect !== undefined && typeof options.browser === 'string' && options.browser !== 'chromium') {
28
+ throw new ConfigurationError('INVALID_CONFIG', `web({ connect }) requires the chromium browser; CDP attach is chromium-only, got "${options.browser}"`);
29
+ }
30
+ if ('allowedOrigins' in options) {
31
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ allowedOrigins }) is gone: navigation and secret fills are not gated by origin; remove the option');
32
+ }
33
+ if (options.headers !== undefined)
34
+ validateHeaders(options.headers);
35
+ if (options.basicAuth !== undefined)
36
+ validateBasicAuth(options.basicAuth);
37
+ if (options.testIdAttribute !== undefined)
38
+ validateTestIdAttribute(options.testIdAttribute);
39
+ const reconnecting = options.connect?.reconnectEndpoint !== undefined;
40
+ if (reconnecting && typeof options.connect?.reconnectEndpoint !== 'function') {
41
+ throw new ConfigurationError('INVALID_CONFIG', 'connect.reconnectEndpoint must be a function');
42
+ }
43
+ // A per-attempt lease rides the same persistent context as `reconnectEndpoint`, with the same limits.
44
+ const recoverable = reconnecting || provider?.scope === 'attempt';
45
+ if (recoverable && (options.headers !== undefined || options.basicAuth !== undefined)) {
46
+ const mode = provider === undefined ? 'connect.reconnectEndpoint' : `browser provider "${provider.name}" with scope "attempt"`;
47
+ throw new ConfigurationError('INVALID_CONFIG', `${mode} uses a persistent context; headers and basicAuth require a newly created context`);
48
+ }
49
+ const surface = new PlaywrightSurface(options);
50
+ const handle = defineEngine({
51
+ name: 'web',
52
+ version: ownVersion(),
53
+ spiVersion: 1,
54
+ platform: 'web',
55
+ prepare: (info) => surface.prepare(info),
56
+ finish: (info) => surface.finish(info),
57
+ init: (info) => surface.init(info),
58
+ startAttempt: (context) => surface.startAttempt(context),
59
+ settleAttempt: (context) => surface.settleAttempt(context),
60
+ endAttempt: (context) => surface.endAttempt(context),
61
+ dispose: (context) => surface.dispose(context),
62
+ observe: (operation, observeOptions) => surface.observe(operation, observeOptions),
63
+ locate: (expression, operation) => surface.locate(expression, operation),
64
+ perform: (ref, action, operation) => surface.perform(ref, action, operation),
65
+ // A browser honors every action kind of the contract; `actions.ts` dispatches each.
66
+ actions: LOCATOR_ACTION_KINDS,
67
+ // A page takes every pointer action of the contract at a bare point too.
68
+ performAt: (point, action, operation) => surface.performAt(point, action, operation),
69
+ pointerActions: POINTER_ACTION_KINDS,
70
+ keyboard: {
71
+ type: (text, keyboardOptions, operation) => surface.typeText(text, keyboardOptions, operation),
72
+ press: (key, operation) => surface.pressKey(key, operation),
73
+ },
74
+ app: declaredApp(options),
75
+ session: {
76
+ open: (url, operation) => surface.open(url, operation),
77
+ back: (operation) => surface.back(operation),
78
+ restart: (operation) => surface.restart(operation),
79
+ ...(recoverable ? {} : { reset: (operation) => surface.reset(operation) }),
80
+ },
81
+ artifacts: {
82
+ screenshot: (label, operation) => surface.screenshot(label, operation),
83
+ startTrace: (operation) => surface.startTrace(operation),
84
+ stopTrace: (operation) => surface.stopTrace(operation),
85
+ startVideo: (operation) => surface.startVideo(operation),
86
+ stopVideo: (operation) => surface.stopVideo(operation),
87
+ },
88
+ ...(recoverable
89
+ ? {}
90
+ : {
91
+ state: {
92
+ capture: (operation) => surface.captureState(operation),
93
+ restore: (state, operation) => surface.restoreState(state, operation),
94
+ },
95
+ }),
96
+ fixtures: {
97
+ web: (context) => createWebFixture(surface, context),
98
+ },
99
+ });
100
+ surfaces.set(handle, surface);
101
+ return handle;
102
+ }
103
+ /** An HTTP header field name: one or more `token` characters (RFC 9110). */
104
+ const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
105
+ /** A control character no HTTP field value may carry; a horizontal tab is the one the grammar allows. */
106
+ // oxlint-disable-next-line no-control-regex -- the control characters are the point
107
+ const FIELD_VALUE_CONTROL = /[\u0000-\u0008\u000A-\u001F\u007F]/;
108
+ /** True for a plain object; the shape both options take. Config runs as JavaScript, so the types alone are no guard. */
109
+ function isRecord(value) {
110
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
111
+ }
112
+ /**
113
+ * Refuses a header the browser could not send, at config load rather than at
114
+ * the first request: a name outside the token grammar, a value carrying a
115
+ * control character (a line break is a header-injection vector), or a value
116
+ * that is not a string at all.
117
+ */
118
+ function validateHeaders(headers) {
119
+ if (!isRecord(headers)) {
120
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ headers }) must be an object of header name to value');
121
+ }
122
+ for (const [name, value] of Object.entries(headers)) {
123
+ if (!HEADER_NAME.test(name)) {
124
+ throw new ConfigurationError('INVALID_CONFIG', `web({ headers }) has an invalid header name: "${name}"`);
125
+ }
126
+ if (typeof value !== 'string') {
127
+ throw new ConfigurationError('INVALID_CONFIG', `web({ headers }) header "${name}" must be a string, got ${typeof value}`);
128
+ }
129
+ if (FIELD_VALUE_CONTROL.test(value)) {
130
+ throw new ConfigurationError('INVALID_CONFIG', `web({ headers }) header "${name}" must not contain a control character`);
131
+ }
132
+ }
133
+ }
134
+ /** Refuses credentials the browser could not present: a missing field, or a `:` in the user name (RFC 7617). */
135
+ function validateBasicAuth(basicAuth) {
136
+ if (!isRecord(basicAuth)) {
137
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ basicAuth }) must be an object with username and password');
138
+ }
139
+ const { username, password } = basicAuth;
140
+ if (typeof username !== 'string' || username === '') {
141
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ basicAuth }) requires a non-empty username string');
142
+ }
143
+ if (username.includes(':')) {
144
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ basicAuth }) username must not contain ":"');
145
+ }
146
+ if (typeof password !== 'string') {
147
+ throw new ConfigurationError('INVALID_CONFIG', 'web({ basicAuth }) requires a password string');
148
+ }
149
+ }
150
+ /**
151
+ * An attribute name the document grammar accepts (XML `Name`, ASCII): a value
152
+ * outside it could never be on an element, so `getByTestId` would match nothing
153
+ * and every `testId` query would fail silently.
154
+ */
155
+ const ATTRIBUTE_NAME = /^[A-Za-z_:][A-Za-z0-9_:.-]*$/;
156
+ /** Refuses a test-id attribute no element could carry, at config load. */
157
+ function validateTestIdAttribute(attribute) {
158
+ if (typeof attribute !== 'string' || !ATTRIBUTE_NAME.test(attribute)) {
159
+ throw new ConfigurationError('INVALID_CONFIG', `web({ testIdAttribute }) must be an attribute name such as "data-testid", got ${JSON.stringify(attribute)}`);
160
+ }
161
+ }
162
+ /** The app-declaration half of the options, so browser knobs never reach the manifest. */
163
+ function declaredApp(options) {
164
+ const { url, environment, identity, command, readyUrl, services } = options;
165
+ return obj({ url, environment, identity, command, readyUrl, services });
166
+ }
167
+ /** This package's published version, read through require resolution. */
168
+ function ownVersion() {
169
+ try {
170
+ return createRequire(import.meta.url)('../package.json').version;
171
+ }
172
+ catch {
173
+ return 'unknown';
174
+ }
175
+ }
176
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,GAAG,GAGJ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,gBAAgB,E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AAS,WAAW,CAAC,OAAmB;IACtC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5E,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,yEAAyE;AACzE,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,OAAQ,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC;IAC5F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ type EvaluationResult = {
2
+ ok: true;
3
+ value: unknown;
4
+ } | {
5
+ ok: false;
6
+ message: string;
7
+ };
8
+ /**
9
+ * Compiles the page-side error boundary without evaluating the caller's source in this process.
10
+ *
11
+ * A function serialized with `toString()` carries whatever the loader compiled
12
+ * it to. tsx runs esbuild with `keepNames`, which wraps every nested named
13
+ * binding in a module-scoped `__name(target, name)` helper; the page has no
14
+ * such helper, so the same one is declared next to the inlined source.
15
+ */
16
+ export declare function compileEvaluation(source: string, hasArgument: boolean): (arg: unknown) => Promise<EvaluationResult>;
17
+ export {};
18
+ //# sourceMappingURL=evaluation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation.d.ts","sourceRoot":"","sources":["../src/evaluation.ts"],"names":[],"mappings":"AAIA,KAAK,gBAAgB,GACjB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAqBnH"}
@@ -0,0 +1,35 @@
1
+ /** Separates exceptions thrown by trusted page code from failures of the evaluation transport. */
2
+ import { TestError } from 'e2e/engine';
3
+ import { message } from './support.js';
4
+ /**
5
+ * Compiles the page-side error boundary without evaluating the caller's source in this process.
6
+ *
7
+ * A function serialized with `toString()` carries whatever the loader compiled
8
+ * it to. tsx runs esbuild with `keepNames`, which wraps every nested named
9
+ * binding in a module-scoped `__name(target, name)` helper; the page has no
10
+ * such helper, so the same one is declared next to the inlined source.
11
+ */
12
+ export function compileEvaluation(source, hasArgument) {
13
+ try {
14
+ return new Function('arg', `
15
+ return (async () => {
16
+ const __name = (target, value) => Object.defineProperty(target, 'name', { value, configurable: true });
17
+ try {
18
+ return { ok: true, value: await (${source}\n)(${hasArgument ? 'arg' : ''}) };
19
+ } catch (cause) {
20
+ let message;
21
+ try {
22
+ message = typeof cause?.message === 'string' ? cause.message : String(cause);
23
+ } catch {
24
+ message = 'Page evaluation threw an unprintable value';
25
+ }
26
+ return { ok: false, message };
27
+ }
28
+ })();
29
+ `);
30
+ }
31
+ catch (cause) {
32
+ throw new TestError('EVALUATE_FAILED', message(cause), { cause });
33
+ }
34
+ }
35
+ //# sourceMappingURL=evaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation.js","sourceRoot":"","sources":["../src/evaluation.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMvC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,WAAoB;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE;;;;6CAIc,MAAM,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;KAW7E,CAAgD,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The in-page semantic reader. Playwright serializes it with `toString()` and
3
+ * runs it inside the page (`read-node.ts` assembles the three page functions
4
+ * from its source), so it must stay one self-contained function: no imports
5
+ * beyond types, no module-scope references, every constant inside the body.
6
+ * That is why it has a file of its own.
7
+ */
8
+ import type { SemanticMode, SemanticResult } from '../read-node.ts';
9
+ /**
10
+ * Serialized into the page by Playwright. Must stay self-contained: no outer
11
+ * captures beyond its two arguments.
12
+ *
13
+ * `mode.kind === 'node'` reads exactly one element for locator reads. An
14
+ * element no longer in its document reads as detached with its value alone:
15
+ * a handle taken a moment earlier can point at a node the page has since
16
+ * replaced, and what such a node reports (no boxes, so hidden) describes
17
+ * nothing on screen.
18
+ * `mode.kind === 'tree'` walks the subtree for one agent observation and
19
+ * returns live element handles aligned with the flattened node list. The two
20
+ * modes also project nodes differently; those differences are data (see
21
+ * `projection` below), not scattered branches.
22
+ */
23
+ export declare const readSemanticsFunction: <Mode extends SemanticMode>(element: Element, options: {
24
+ testIdAttribute: string;
25
+ secureFieldSelector: string;
26
+ mode: Mode;
27
+ }) => SemanticResult<Mode>;
28
+ //# sourceMappingURL=read-semantics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-semantics.d.ts","sourceRoot":"","sources":["../../src/in-page/read-semantics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAgC,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElG;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GAAI,IAAI,SAAS,YAAY,WACpD,OAAO,WACP;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,KAC5E,cAAc,CAAC,IAAI,CAunCrB,CAAC"}