@gethopp/figma-mcp-bridge 0.0.5 → 0.0.6
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/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/leader.d.ts +1 -0
- package/dist/leader.js +15 -10
- package/dist/leader.js.map +1 -1
- package/dist/schema.d.ts +37 -0
- package/dist/schema.js +52 -0
- package/dist/schema.js.map +1 -0
- package/dist/tools.js +4 -22
- package/dist/tools.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { Node } from "./node.js";
|
|
5
5
|
import { Election } from "./election.js";
|
|
6
6
|
import { registerTools } from "./tools.js";
|
|
7
|
+
import { VERSION } from "./version.js";
|
|
7
8
|
const PORT = 1994;
|
|
8
9
|
async function main() {
|
|
9
10
|
const node = new Node(PORT);
|
|
@@ -21,7 +22,7 @@ async function main() {
|
|
|
21
22
|
// Create MCP server (stdio transport)
|
|
22
23
|
const server = new McpServer({
|
|
23
24
|
name: "figma-bridge",
|
|
24
|
-
version:
|
|
25
|
+
version: VERSION,
|
|
25
26
|
});
|
|
26
27
|
registerTools(server, node);
|
|
27
28
|
console.error(`Starting MCP server (role: ${node.roleName})`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,E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CAAC,QAAQ,GAAG,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/leader.d.ts
CHANGED
package/dist/leader.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import { Bridge } from "./bridge.js";
|
|
3
|
+
import { validateRpc } from "./schema.js";
|
|
4
|
+
import { VERSION } from "./version.js";
|
|
3
5
|
/**
|
|
4
6
|
* Leader owns the WebSocket bridge to Figma and exposes HTTP endpoints for followers.
|
|
5
7
|
* Endpoints:
|
|
@@ -23,7 +25,7 @@ export class Leader {
|
|
|
23
25
|
const server = http.createServer((req, res) => {
|
|
24
26
|
if (req.url === "/ping" && req.method === "GET") {
|
|
25
27
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
26
|
-
res.end(JSON.stringify({ status: "ok", version:
|
|
28
|
+
res.end(JSON.stringify({ status: "ok", version: VERSION }));
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
if (req.url === "/rpc" && req.method === "POST") {
|
|
@@ -62,22 +64,25 @@ export class Leader {
|
|
|
62
64
|
req.on("end", async () => {
|
|
63
65
|
try {
|
|
64
66
|
const rpcReq = JSON.parse(body);
|
|
67
|
+
const validationError = validateRpc(rpcReq.tool, rpcReq.nodeIds, rpcReq.params);
|
|
68
|
+
if (validationError) {
|
|
69
|
+
this.sendJSON(res, 400, { error: validationError });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
65
72
|
const resp = await this.bridge.sendWithParams(rpcReq.tool, rpcReq.nodeIds, rpcReq.params);
|
|
66
|
-
|
|
67
|
-
? { error: resp.error }
|
|
68
|
-
: { data: resp.data };
|
|
69
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
70
|
-
res.end(JSON.stringify(rpcResp));
|
|
73
|
+
this.sendJSON(res, 200, resp.error ? { error: resp.error } : { data: resp.data });
|
|
71
74
|
}
|
|
72
75
|
catch (err) {
|
|
73
|
-
|
|
76
|
+
this.sendJSON(res, 200, {
|
|
74
77
|
error: err instanceof Error ? err.message : String(err),
|
|
75
|
-
};
|
|
76
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
77
|
-
res.end(JSON.stringify(rpcResp));
|
|
78
|
+
});
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
}
|
|
82
|
+
sendJSON(res, status, body) {
|
|
83
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
84
|
+
res.end(JSON.stringify(body));
|
|
85
|
+
}
|
|
81
86
|
stop() {
|
|
82
87
|
this.bridge.close();
|
|
83
88
|
if (this.server) {
|
package/dist/leader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leader.js","sourceRoot":"","sources":["../src/leader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"leader.js","sourceRoot":"","sources":["../src/leader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IAIG;IAHZ,MAAM,CAAS;IACf,MAAM,GAAuB,IAAI,CAAC;IAE1C,YAAoB,IAAY;QAAZ,SA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AAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAC3C,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,MAAM,CACd,CAAC;gBAEF,IAAI,CAAC,QAAQ,CACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CACzD,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE;oBACtB,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBACxD,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,QAAQ,CACd,GAAwB,EACxB,MAAc,EACd,IAAiB;QAEjB,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC9D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Figma node IDs use colon-separated format, e.g. "4029:12345". */
|
|
3
|
+
export declare const figmaNodeId: z.ZodString;
|
|
4
|
+
export declare const toolInputSchemas: {
|
|
5
|
+
readonly get_node: z.ZodObject<{
|
|
6
|
+
nodeId: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
nodeId: string;
|
|
9
|
+
}, {
|
|
10
|
+
nodeId: string;
|
|
11
|
+
}>;
|
|
12
|
+
readonly get_design_context: z.ZodObject<{
|
|
13
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
depth?: number | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
depth?: number | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
readonly get_screenshot: z.ZodObject<{
|
|
20
|
+
nodeIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
21
|
+
format: z.ZodOptional<z.ZodString>;
|
|
22
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
nodeIds?: string[] | undefined;
|
|
25
|
+
format?: string | undefined;
|
|
26
|
+
scale?: number | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
nodeIds?: string[] | undefined;
|
|
29
|
+
format?: string | undefined;
|
|
30
|
+
scale?: number | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Validate an RPC request against the corresponding tool's input schema.
|
|
35
|
+
* Returns an error string on failure, null if valid or no schema exists for the tool.
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateRpc(tool: string, nodeIds?: string[], params?: Record<string, unknown>): string | null;
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Figma node IDs use colon-separated format, e.g. "4029:12345". */
|
|
3
|
+
export const figmaNodeId = z
|
|
4
|
+
.string()
|
|
5
|
+
.regex(/^\d+:\d+$/, "Node ID must use colon format, e.g. '4029:12345'");
|
|
6
|
+
export const toolInputSchemas = {
|
|
7
|
+
get_node: z.object({
|
|
8
|
+
nodeId: figmaNodeId.describe("The node ID to fetch"),
|
|
9
|
+
}),
|
|
10
|
+
get_design_context: z.object({
|
|
11
|
+
depth: z
|
|
12
|
+
.number()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("How many levels deep to traverse the node tree (default 2)"),
|
|
15
|
+
}),
|
|
16
|
+
get_screenshot: z.object({
|
|
17
|
+
nodeIds: z
|
|
18
|
+
.array(figmaNodeId)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Optional list of node IDs to export (colon-separated format, e.g. '4029:12345' — never use hyphens). If empty, exports the current selection"),
|
|
21
|
+
format: z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Export format: PNG (default) or SVG or JPG or PDF"),
|
|
25
|
+
scale: z
|
|
26
|
+
.number()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("Export scale for raster formats (default 2)"),
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Maps the RPC wire format { tool, nodeIds?, params? } to each tool's
|
|
33
|
+
* expected input shape. Typed as Record<ToolName, ...> so adding a schema
|
|
34
|
+
* without a mapper is a compile error.
|
|
35
|
+
*/
|
|
36
|
+
const rpcToArgs = {
|
|
37
|
+
get_node: (nodeIds) => ({ nodeId: nodeIds?.[0] }),
|
|
38
|
+
get_design_context: (_nodeIds, params) => ({ ...params }),
|
|
39
|
+
get_screenshot: (nodeIds, params) => ({ nodeIds, ...params }),
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Validate an RPC request against the corresponding tool's input schema.
|
|
43
|
+
* Returns an error string on failure, null if valid or no schema exists for the tool.
|
|
44
|
+
*/
|
|
45
|
+
export function validateRpc(tool, nodeIds, params) {
|
|
46
|
+
if (!(tool in toolInputSchemas))
|
|
47
|
+
return null;
|
|
48
|
+
const name = tool;
|
|
49
|
+
const result = toolInputSchemas[name].safeParse(rpcToArgs[name](nodeIds, params));
|
|
50
|
+
return result.success ? null : result.error.issues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IACzD,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;CAC9D,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,OAAkB,EAClB,MAAgC;IAEhC,IAAI,CAAC,CAAC,IAAI,IAAI,gBAAgB,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7C,MAAM,IAAI,GAAG,IAAgB,CAAC;IAC9B,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,CAC7C,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CACjC,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChE,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toolInputSchemas } from "./schema.js";
|
|
2
2
|
export function registerTools(server, node) {
|
|
3
3
|
server.tool("get_document", "Get the current Figma page document tree", async () => {
|
|
4
4
|
return renderResponse(() => node.send("get_document"));
|
|
@@ -6,7 +6,7 @@ export function registerTools(server, node) {
|
|
|
6
6
|
server.tool("get_selection", "Get the currently selected nodes in Figma", async () => {
|
|
7
7
|
return renderResponse(() => node.send("get_selection"));
|
|
8
8
|
});
|
|
9
|
-
server.tool("get_node", "Get a specific Figma node by ID
|
|
9
|
+
server.tool("get_node", "Get a specific Figma node by ID. Must use colon format, e.g. '4029:12345', never use hyphens.", toolInputSchemas.get_node.shape, async ({ nodeId }) => {
|
|
10
10
|
return renderResponse(() => node.send("get_node", [nodeId]));
|
|
11
11
|
});
|
|
12
12
|
server.tool("get_styles", "Get all local styles in the document", async () => {
|
|
@@ -15,12 +15,7 @@ export function registerTools(server, node) {
|
|
|
15
15
|
server.tool("get_metadata", "Get metadata about the current Figma document including file name, pages, and current page info", async () => {
|
|
16
16
|
return renderResponse(() => node.send("get_metadata"));
|
|
17
17
|
});
|
|
18
|
-
server.tool("get_design_context", "Get the design context for the current selection or page. Returns a summarized tree structure optimized for understanding the current design context.", {
|
|
19
|
-
depth: z
|
|
20
|
-
.number()
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("How many levels deep to traverse the node tree (default 2)"),
|
|
23
|
-
}, async ({ depth }) => {
|
|
18
|
+
server.tool("get_design_context", "Get the design context for the current selection or page. Returns a summarized tree structure optimized for understanding the current design context.", toolInputSchemas.get_design_context.shape, async ({ depth }) => {
|
|
24
19
|
const params = {};
|
|
25
20
|
if (depth !== undefined && depth > 0) {
|
|
26
21
|
params.depth = depth;
|
|
@@ -30,20 +25,7 @@ export function registerTools(server, node) {
|
|
|
30
25
|
server.tool("get_variable_defs", "Get all local variable definitions including variable collections, modes, and variable values. Variables are Figma's system for design tokens (colors, numbers, strings, booleans).", async () => {
|
|
31
26
|
return renderResponse(() => node.send("get_variable_defs"));
|
|
32
27
|
});
|
|
33
|
-
server.tool("get_screenshot", "Export a screenshot of the selected nodes or specific nodes by ID. Returns base64-encoded image data.", {
|
|
34
|
-
nodeIds: z
|
|
35
|
-
.array(z.string())
|
|
36
|
-
.optional()
|
|
37
|
-
.describe("Optional list of node IDs to export — if empty, exports the current selection"),
|
|
38
|
-
format: z
|
|
39
|
-
.string()
|
|
40
|
-
.optional()
|
|
41
|
-
.describe("Export format: PNG (default) or SVG or JPG or PDF"),
|
|
42
|
-
scale: z
|
|
43
|
-
.number()
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("Export scale for raster formats (default 2)"),
|
|
46
|
-
}, async ({ nodeIds, format, scale }) => {
|
|
28
|
+
server.tool("get_screenshot", "Export a screenshot of the selected nodes or specific nodes by ID. Returns base64-encoded image data.", toolInputSchemas.get_screenshot.shape, async ({ nodeIds, format, scale }) => {
|
|
47
29
|
const params = {};
|
|
48
30
|
if (format)
|
|
49
31
|
params.format = format;
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,MAAM,UAAU,aAAa,CAAC,MAAiB,EAAE,IAAU;IACzD,MAAM,CAAC,IAAI,CACT,cAAc,EACd,0CAA0C,EAC1C,KAAK,IAAyB,EAAE;QAC9B,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IACzD,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,eAAe,EACf,2CAA2C,EAC3C,KAAK,IAAyB,EAAE;QAC9B,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1D,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,UAAU,EACV,+FAA+F,EAC/F,gBAAgB,CAAC,QAAQ,CAAC,KAAK,EAC/B,KAAK,EAAE,EAAE,MAAM,EAAE,EAAuB,EAAE;QACxC,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,YAAY,EACZ,sCAAsC,EACtC,KAAK,IAAyB,EAAE;QAC9B,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,cAAc,EACd,iGAAiG,EACjG,K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C,CACvD,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,EAAiC;IAEjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC7D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBACvD;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION: string;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC"}
|