@samva/markup 0.1.0 → 0.1.2
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/dist/ast.js +1 -1
- package/dist/{checks-CW0nFj5n.js → checks-D-zFQt5R.js} +2 -2
- package/dist/checks.js +1 -1
- package/dist/compile-sms.d.ts +1 -1
- package/dist/compile-whatsapp.d.ts +1 -1
- package/dist/components.d.ts +3 -3
- package/dist/conditionals.js +1 -1
- package/dist/diagnostics.js +2 -2
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/{jsx-runtime-fSxcvlx4.d.ts → jsx-runtime-eNIMY87F.d.ts} +2 -2
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/ops.js +2 -2
- package/dist/{parser-yzjUOGhc.d.ts → parser-DkQKIjDa.d.ts} +11 -2
- package/dist/parser.d.ts +2 -2
- package/dist/parser.js +48 -9
- package/dist/predicate-CvkzT-a2.js +539 -0
- package/dist/{predicate-DTtVtLK7.d.ts → predicate-G2SeSvoN.d.ts} +9 -2
- package/dist/predicate.d.ts +2 -2
- package/dist/predicate.js +2 -417
- package/dist/presets/category-mapping.d.ts +1 -1
- package/dist/presets/public-gallery.d.ts +2 -490
- package/dist/presets/public-gallery.js +2 -1
- package/dist/presets/public-handoff.d.ts +2 -68
- package/dist/presets/public-handoff.js +110 -24
- package/dist/presets/public-preview-artifacts.d.ts +2 -2
- package/dist/presets/public-preview.d.ts +2 -1168
- package/dist/presets/public-preview.js +17 -17
- package/dist/presets/sources.js +17 -17
- package/dist/public-gallery-D0Zv0pZE.d.ts +611 -0
- package/dist/public-preview-u1Z9aaGq.d.ts +1168 -0
- package/dist/render-template.d.ts +2 -2
- package/dist/render-template.js +1 -1
- package/dist/{variables-3NGLpNTB.d.ts → variables-if1VrV34.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +1 -1
- package/generated/sml-email-language-reference.md +1 -1
- package/generated/sml-language-reference.md +1 -1
- package/package.json +6 -3
- package/dist/ast.js.map +0 -1
- package/dist/candidate.js.map +0 -1
- package/dist/checks-CW0nFj5n.js.map +0 -1
- package/dist/classes.js.map +0 -1
- package/dist/compile-sms.js.map +0 -1
- package/dist/compile-whatsapp.js.map +0 -1
- package/dist/compile.js.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/conditionals.js.map +0 -1
- package/dist/diagnostics.js.map +0 -1
- package/dist/emit.js.map +0 -1
- package/dist/footer.js.map +0 -1
- package/dist/interpolate.js.map +0 -1
- package/dist/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/lexer.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/ops.js.map +0 -1
- package/dist/parser.js.map +0 -1
- package/dist/predicate.js.map +0 -1
- package/dist/presets/category-mapping.js.map +0 -1
- package/dist/presets/public-gallery.js.map +0 -1
- package/dist/presets/public-handoff.js.map +0 -1
- package/dist/presets/public-preview-artifacts.js.map +0 -1
- package/dist/presets/public-preview.js.map +0 -1
- package/dist/presets/sources.js.map +0 -1
- package/dist/presets.js.map +0 -1
- package/dist/printer.js.map +0 -1
- package/dist/registry.js.map +0 -1
- package/dist/render-template.js.map +0 -1
- package/dist/sms-segments.js.map +0 -1
- package/dist/theme-css.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/tokens.js.map +0 -1
- package/dist/variables.js.map +0 -1
- package/dist/version-BITr58kk.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as SmlParseError } from "./diagnostics-oveE-laV.js";
|
|
2
2
|
import { C as SmlDocument } from "./ast-DAhnAvQN.js";
|
|
3
|
-
import { a as VariableKind, l as Variables } from "./variables-
|
|
4
|
-
import { a as JsxResult } from "./jsx-runtime-
|
|
3
|
+
import { a as VariableKind, l as Variables } from "./variables-if1VrV34.js";
|
|
4
|
+
import { a as JsxResult } from "./jsx-runtime-eNIMY87F.js";
|
|
5
5
|
import { Result } from "effect";
|
|
6
6
|
//#region src/render-template.d.ts
|
|
7
7
|
/**
|
package/dist/render-template.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as parsePredicate, n as collectPredicateVariables } from "./predicate-CvkzT-a2.js";
|
|
2
2
|
import { isRootTag } from "./ast.js";
|
|
3
3
|
import { createVariablesProxy } from "./variables.js";
|
|
4
4
|
import { parseSml } from "./parser.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as PredicateAst } from "./predicate-G2SeSvoN.js";
|
|
2
2
|
//#region src/variables.d.ts
|
|
3
3
|
/** Brand carried by every VariableRef, keyed off a private symbol. */
|
|
4
4
|
declare const VARIABLE_REF: unique symbol;
|
|
@@ -74,4 +74,4 @@ declare const createVariablesProxy: <T extends Record<string, unknown>>() => {
|
|
|
74
74
|
};
|
|
75
75
|
//#endregion
|
|
76
76
|
export { VariableKind as a, VariableRefBrand as c, isPredicateRef as d, isVariableRef as f, VARIABLE_REF as i, Variables as l, PREDICATE_REF as n, VariableRecorder as o, printPredicateRef as p, PredicateRef as r, VariableRef as s, CollectedVariable as t, createVariablesProxy as u };
|
|
77
|
-
//# sourceMappingURL=variables-
|
|
77
|
+
//# sourceMappingURL=variables-if1VrV34.d.ts.map
|
package/dist/variables.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as VariableKind, c as VariableRefBrand, d as isPredicateRef, f as isVariableRef, i as VARIABLE_REF, l as Variables, n as PREDICATE_REF, o as VariableRecorder, p as printPredicateRef, r as PredicateRef, s as VariableRef, t as CollectedVariable, u as createVariablesProxy } from "./variables-
|
|
1
|
+
import { a as VariableKind, c as VariableRefBrand, d as isPredicateRef, f as isVariableRef, i as VARIABLE_REF, l as Variables, n as PREDICATE_REF, o as VariableRecorder, p as printPredicateRef, r as PredicateRef, s as VariableRef, t as CollectedVariable, u as createVariablesProxy } from "./variables-if1VrV34.js";
|
|
2
2
|
export { CollectedVariable, PREDICATE_REF, PredicateRef, VARIABLE_REF, VariableKind, VariableRecorder, VariableRef, VariableRefBrand, Variables, createVariablesProxy, isPredicateRef, isVariableRef, printPredicateRef };
|
package/dist/variables.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samva/markup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Type-safe authoring and compilation primitives for Samva templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
|
+
"!dist/**/*.map",
|
|
28
29
|
"generated",
|
|
29
30
|
"package.json",
|
|
30
31
|
"README.md",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"type": "module",
|
|
35
36
|
"sideEffects": false,
|
|
36
37
|
"exports": {
|
|
38
|
+
"./package.json": "./package.json",
|
|
37
39
|
"./ast": {
|
|
38
40
|
"types": "./dist/ast.d.ts",
|
|
39
41
|
"import": "./dist/ast.js"
|
|
@@ -183,6 +185,7 @@
|
|
|
183
185
|
"build": "tsdown",
|
|
184
186
|
"prepack": "bun run build",
|
|
185
187
|
"codegen:presets": "bun run scripts/codegen-presets.ts && oxfmt presets/sources.gen.ts",
|
|
188
|
+
"import:public-handoff": "bun run scripts/import-public-template-handoff.ts",
|
|
186
189
|
"codegen:tokens": "bun run scripts/codegen-tokens.ts && oxfmt src/tokens.ts",
|
|
187
190
|
"codegen:sml-reference": "bun run scripts/generate-sml-reference.ts",
|
|
188
191
|
"codegen:docs": "bun run scripts/codegen-docs.ts",
|
|
@@ -191,10 +194,10 @@
|
|
|
191
194
|
"typecheck": "tsgo --noEmit"
|
|
192
195
|
},
|
|
193
196
|
"dependencies": {
|
|
194
|
-
"effect": "4.0.0-
|
|
197
|
+
"effect": "4.0.0-rc.111"
|
|
195
198
|
},
|
|
196
199
|
"devDependencies": {
|
|
197
|
-
"@effect/vitest": "4.0.0-
|
|
200
|
+
"@effect/vitest": "4.0.0-rc.111",
|
|
198
201
|
"tailwindcss": "^4.3.3",
|
|
199
202
|
"tsdown": "^0.22.13",
|
|
200
203
|
"typescript": "^6.0.3",
|
package/dist/ast.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","names":[],"sources":["../src/ast.ts"],"sourcesContent":["import { Result, Schema } from \"effect\";\n\nimport { SpanSchema } from \"./diagnostics\";\nimport { collectPredicateVariables, parsePredicate } from \"./predicate\";\n\n// Typed SML AST. The parser is the only producer; the schema exists for\n// boundaries that ship AST JSON (editor ops, agent tools). Shape only — the\n// content model (what may nest where) is the parser's job, so decoding an AST\n// someone assembled by hand still round-trips through print → parse for full\n// validation.\n//\n// Node ids are assigned in document order at parse time (\"n0\", \"n1\", ...):\n// identical source always yields identical ids, which the compiler relies on\n// for deterministic artifacts and the editor for DOM ⇄ AST mapping.\n//\n// `tag` is a closed vocabulary — permanently: composition lives in the TSX\n// authoring layer, so SML stays a flat closed grammar. New tags (e.g. <For>)\n// land by widening the unions — nothing else about the node shape assumes a\n// fixed set.\n//\n// One document = one channel, declared by the root tag: <Email> (blocks +\n// inline + Tailwind subset), <Sms> (verbatim text body), <WhatsApp> (Meta's\n// template anatomy as the closed grammar). Cross-channel compile is rejected\n// by design; what the channels share is the language machinery.\n\nexport const BLOCK_TAGS = [\n \"Email\",\n \"Subject\",\n \"Preview\",\n \"Container\",\n \"Section\",\n \"Row\",\n \"Column\",\n \"Heading\",\n \"Text\",\n \"Button\",\n \"Image\",\n \"Divider\",\n \"Spacer\",\n \"List\",\n \"ListItem\",\n \"If\",\n \"Else\",\n] as const;\n\nexport const INLINE_TAGS = [\"strong\", \"em\", \"a\"] as const;\n\n/** Email-only helper tags scoped by their parent primitive. */\nexport const AUXILIARY_TAGS = [\"Source\"] as const;\n\n/** Structured-channel tags: the sms/whatsapp vocabulary beyond shared If/Else. */\nexport const CHANNEL_TAGS = [\"Sms\", \"WhatsApp\", \"Header\", \"Body\", \"Footer\", \"Buttons\"] as const;\n\nexport const SML_TAGS = [\n ...BLOCK_TAGS,\n ...INLINE_TAGS,\n ...AUXILIARY_TAGS,\n ...CHANNEL_TAGS,\n] as const;\n\nexport type BlockTag = (typeof BLOCK_TAGS)[number];\nexport type InlineTag = (typeof INLINE_TAGS)[number];\nexport type AuxiliaryTag = (typeof AUXILIARY_TAGS)[number];\nexport type ChannelTag = (typeof CHANNEL_TAGS)[number];\nexport type SmlTag = (typeof SML_TAGS)[number];\n\n// ── Channels ─────────────────────────────────────────────────────────────────\n\n/** Channels supported by the public SML document model. */\nexport type Channel = \"email\" | \"sms\" | \"whatsapp\";\n\n/** Resolved primary width for email documents that omit `<Email width={…}>`. */\nexport const DEFAULT_EMAIL_WIDTH = 600;\n\n/** Root tag → channel. The root tag IS the channel declaration. */\nexport const CHANNEL_BY_ROOT_TAG = {\n Email: \"email\",\n Sms: \"sms\",\n WhatsApp: \"whatsapp\",\n} as const satisfies Partial<Record<SmlTag, Channel>>;\n\nexport type RootTag = keyof typeof CHANNEL_BY_ROOT_TAG;\n\nexport const ROOT_TAGS = Object.keys(CHANNEL_BY_ROOT_TAG) as ReadonlyArray<RootTag>;\n\nexport const isRootTag = (tag: string): tag is RootTag => tag in CHANNEL_BY_ROOT_TAG;\n\n/** The channel a parsed document targets, read off its root tag. */\nexport const documentChannel = (document: SmlDocument): Channel =>\n CHANNEL_BY_ROOT_TAG[document.root.tag as RootTag];\n\nexport const AttributeValueSchema = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"string\"),\n value: Schema.String,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"number\"),\n value: Schema.Finite,\n }),\n]);\n\nexport type AttributeValue = typeof AttributeValueSchema.Type;\n\nexport const AttributeSchema = Schema.Struct({\n name: Schema.String,\n value: AttributeValueSchema,\n /** Span of the whole `name=\"value\"` pair. */\n span: SpanSchema,\n /** Span of the value contents (inside quotes/braces) — class diagnostics point here. */\n valueSpan: SpanSchema,\n});\n\nexport interface Attribute extends Schema.Schema.Type<typeof AttributeSchema> {}\n\nexport const TextNodeSchema = Schema.Struct({\n kind: Schema.Literal(\"text\"),\n id: Schema.String,\n value: Schema.String,\n span: SpanSchema,\n});\n\nexport interface TextNode extends Schema.Schema.Type<typeof TextNodeSchema> {}\n\nexport const InterpolationNodeSchema = Schema.Struct({\n kind: Schema.Literal(\"interpolation\"),\n id: Schema.String,\n name: Schema.String,\n /** {{name}} vs ${name} — both today's syntaxes, preserved through print. */\n syntax: Schema.Literals([\"curly\", \"dollar\"]),\n span: SpanSchema,\n});\n\nexport interface InterpolationNode extends Schema.Schema.Type<typeof InterpolationNodeSchema> {}\n\nexport interface ElementNode {\n readonly kind: \"element\";\n readonly id: string;\n readonly tag: SmlTag;\n readonly attributes: ReadonlyArray<Attribute>;\n readonly children: ReadonlyArray<SmlNode>;\n readonly span: typeof SpanSchema.Type;\n}\n\nexport type SmlNode = ElementNode | TextNode | InterpolationNode;\n\nexport const ElementNodeSchema: Schema.Codec<ElementNode> = Schema.Struct({\n kind: Schema.Literal(\"element\"),\n id: Schema.String,\n tag: Schema.Literals(SML_TAGS),\n attributes: Schema.Array(AttributeSchema),\n children: Schema.Array(Schema.suspend((): Schema.Codec<SmlNode> => SmlNodeSchema)),\n span: SpanSchema,\n});\n\nexport const SmlNodeSchema: Schema.Codec<SmlNode> = Schema.Union([\n ElementNodeSchema,\n TextNodeSchema,\n InterpolationNodeSchema,\n]);\n\nexport const SmlDocumentSchema = Schema.Struct({\n kind: Schema.Literal(\"document\"),\n /** Always a root element: `<Email>`, `<Sms>`, or `<WhatsApp>`. */\n root: ElementNodeSchema,\n});\n\nexport interface SmlDocument extends Schema.Schema.Type<typeof SmlDocumentSchema> {}\n\nexport const attributeValue = (node: ElementNode, name: string): AttributeValue | undefined =>\n node.attributes.find((attribute) => attribute.name === name)?.value;\n\nexport const stringAttribute = (node: ElementNode, name: string): string | undefined => {\n const value = attributeValue(node, name);\n return value?.kind === \"string\" ? value.value : undefined;\n};\n\nexport const numberAttribute = (node: ElementNode, name: string): number | undefined => {\n const value = attributeValue(node, name);\n if (value === undefined) return undefined;\n return value.kind === \"number\" ? value.value : Number.parseInt(value.value, 10);\n};\n\n/**\n * The editor-only display label (navigator rename) — a universal attribute the\n * compiler never reads, so it never reaches HTML. Absent when unset.\n */\nexport const nodeLabel = (node: ElementNode): string | undefined => stringAttribute(node, \"label\");\n\n/**\n * The editor-only visibility flag. A `hidden=\"true\"` node stays in the source\n * (and the navigator, dimmed) but is dropped from every compile — preview and\n * send alike. Any other value / absence means visible.\n */\nexport const isHiddenNode = (node: ElementNode): boolean =>\n stringAttribute(node, \"hidden\") === \"true\";\n\n/**\n * All variable references in the document: `{{name}}` / `${name}` in children\n * and attribute values, plus names referenced by `<If test=\"...\">` predicates.\n */\nexport const collectVariableReferences = (document: SmlDocument): ReadonlySet<string> => {\n const names = new Set<string>();\n const attributePattern = /\\$\\{\\s*\\/?([\\w.]+)\\s*\\}|\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g;\n const visit = (node: SmlNode): void => {\n if (node.kind === \"interpolation\") {\n names.add(node.name);\n return;\n }\n if (node.kind === \"text\") return;\n for (const attribute of node.attributes) {\n if (attribute.value.kind !== \"string\") continue;\n if (node.tag === \"If\" && attribute.name === \"test\") {\n // Parser-produced documents always carry a valid predicate; a\n // hand-assembled AST with a broken one contributes nothing here and is\n // caught by the print → parse validation round-trip.\n const parsed = parsePredicate(attribute.value.value);\n if (Result.isSuccess(parsed)) {\n for (const name of collectPredicateVariables(parsed.success)) names.add(name);\n }\n continue;\n }\n for (const match of attribute.value.value.matchAll(attributePattern)) {\n const name = match[1] ?? match[2];\n if (name !== undefined) names.add(name);\n }\n }\n for (const child of node.children) visit(child);\n };\n visit(document.root);\n return names;\n};\n"],"mappings":";;;;AAyBA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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,UAAU,MAAM,MAAM,SAAS,gBAAgB,GAAG;IACpE,MAAM,OAAO,MAAM,MAAM,MAAM;IAC/B,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,IAAI;GACxC;EACF;EACA,KAAK,MAAM,SAAS,KAAK,UAAU,MAAM,KAAK;CAChD;CACA,MAAM,SAAS,IAAI;CACnB,OAAO;AACT"}
|
package/dist/candidate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"candidate.js","names":[],"sources":["../src/candidate.ts"],"sourcesContent":["// Tailwind candidate segmentation: `[sm:|dark:]root[-value | -[arbitrary]][/modifier][!]`.\n// Bracket-aware splitting only — which roots exist and what values mean is the\n// registry's job (registry.ts). Mirrors the shape of tailwindcss/src/candidate.ts\n// at ~10% of the grammar.\n\nexport interface ParsedCandidate {\n readonly raw: string;\n /** Variant names in written order (validity is checked by the resolver). */\n readonly variants: ReadonlyArray<string>;\n /** root[-value] with variants/modifier/important stripped. */\n readonly base: string;\n /** Contents after the last `/` outside brackets, or null. */\n readonly modifier: string | null;\n /** Trailing `!`. */\n readonly important: boolean;\n}\n\nconst splitOutsideBrackets = (value: string, separator: string): Array<string> => {\n const parts: Array<string> = [];\n let depth = 0;\n let start = 0;\n for (let index = 0; index < value.length; index++) {\n const char = value[index]!;\n if (char === \"[\") depth++;\n else if (char === \"]\") depth = Math.max(0, depth - 1);\n else if (char === separator && depth === 0) {\n parts.push(value.slice(start, index));\n start = index + 1;\n }\n }\n parts.push(value.slice(start));\n return parts;\n};\n\nexport const parseCandidate = (raw: string): ParsedCandidate => {\n let rest = raw;\n const important = rest.endsWith(\"!\");\n if (important) rest = rest.slice(0, -1);\n\n const segments = splitOutsideBrackets(rest, \":\");\n const base = segments[segments.length - 1]!;\n const variants = segments.slice(0, -1);\n\n const lastSlash = (() => {\n let depth = 0;\n for (let index = base.length - 1; index >= 0; index--) {\n const char = base[index]!;\n if (char === \"]\") depth++;\n else if (char === \"[\") depth = Math.max(0, depth - 1);\n else if (char === \"/\" && depth === 0) return index;\n }\n return -1;\n })();\n\n if (lastSlash === -1) return { raw, variants, base, modifier: null, important };\n return {\n raw,\n variants,\n base: base.slice(0, lastSlash),\n modifier: base.slice(lastSlash + 1),\n important,\n };\n};\n\n/**\n * Splits `base` into (root, value) against a known root set, preferring the\n * longest matching root (\"max-w-lg\" → root \"max-w\", not \"max\").\n * `value` is `null` for a bare root (\"border\", \"rounded\"),\n * `{ kind: \"arbitrary\" }` for `root-[...]`, else `{ kind: \"named\" }`.\n */\nexport const splitRoot = (\n base: string,\n roots: ReadonlySet<string>,\n): {\n readonly root: string;\n readonly value: { kind: \"named\" | \"arbitrary\"; value: string } | null;\n} | null => {\n if (roots.has(base)) return { root: base, value: null };\n let dash = base.lastIndexOf(\"-\");\n while (dash > 0) {\n const root = base.slice(0, dash);\n if (roots.has(root)) {\n const rawValue = base.slice(dash + 1);\n if (rawValue.startsWith(\"[\") && rawValue.endsWith(\"]\")) {\n return { root, value: { kind: \"arbitrary\", value: rawValue.slice(1, -1) } };\n }\n return { root, value: { kind: \"named\", value: rawValue } };\n }\n dash = base.lastIndexOf(\"-\", dash - 1);\n }\n return null;\n};\n"],"mappings":";AAiBA,MAAM,wBAAwB,OAAe,cAAqC;CAChF,MAAM,QAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAO,MAAM;EACnB,IAAI,SAAS,KAAK;OACb,IAAI,SAAS,KAAK,QAAQ,KAAK,IAAI,GAAG,QAAQ,CAAC;OAC/C,IAAI,SAAS,aAAa,UAAU,GAAG;GAC1C,MAAM,KAAK,MAAM,MAAM,OAAO,KAAK,CAAC;GACpC,QAAQ,QAAQ;EAClB;CACF;CACA,MAAM,KAAK,MAAM,MAAM,KAAK,CAAC;CAC7B,OAAO;AACT;AAEA,MAAa,kBAAkB,QAAiC;CAC9D,IAAI,OAAO;C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