@zhin.js/console 1.0.7 → 1.0.9
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 +86 -21
- package/app/bin.ts +52 -0
- package/app/build.ts +211 -0
- package/app/dev.ts +84 -0
- package/app/index.ts +89 -315
- package/app/websocket.ts +109 -0
- package/client/public/vendor/react-dom.production.min.js +1 -0
- package/client/public/vendor/react.production.min.js +1 -0
- package/client/tailwind.config.js +18 -3
- package/lib/bin.d.ts +3 -0
- package/lib/bin.d.ts.map +1 -0
- package/lib/bin.js +45 -0
- package/lib/bin.js.map +1 -0
- package/lib/build.d.ts +33 -0
- package/lib/build.d.ts.map +1 -0
- package/lib/build.js +168 -0
- package/lib/build.js.map +1 -0
- package/lib/dev.d.ts +16 -0
- package/lib/dev.d.ts.map +1 -0
- package/lib/dev.js +71 -0
- package/lib/dev.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +89 -260
- package/lib/index.js.map +1 -1
- package/lib/websocket.d.ts +14 -0
- package/lib/websocket.d.ts.map +1 -0
- package/lib/websocket.js +85 -0
- package/lib/websocket.js.map +1 -0
- package/package.json +9 -3
package/lib/build.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface BuildOptions {
|
|
2
|
+
/** 插件根目录 */
|
|
3
|
+
pluginRoot: string;
|
|
4
|
+
/** 输出目录,默认为 pluginRoot/dist */
|
|
5
|
+
outDir?: string;
|
|
6
|
+
/** 是否启用 tailwindcss,默认 true */
|
|
7
|
+
enableTailwind?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ConsoleBuildOptions {
|
|
10
|
+
/** Console 插件根目录 */
|
|
11
|
+
consoleRoot: string;
|
|
12
|
+
/** 输出目录,默认为 consoleRoot/dist */
|
|
13
|
+
outDir?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 构建插件的客户端代码(单文件模式)
|
|
17
|
+
* 用于构建普通插件的 client/index.tsx 文件
|
|
18
|
+
*
|
|
19
|
+
* 策略:将公共依赖配置为 external,运行时从 console 加载的 vendor chunks 中复用
|
|
20
|
+
* @param options 构建选项
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildPluginClient(options: BuildOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* 构建 Console 插件的客户端代码(SPA 应用模式)
|
|
25
|
+
* Console 有完整的 index.html 和 src 目录结构
|
|
26
|
+
* @param options Console 构建选项
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildConsoleClient(options: ConsoleBuildOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* 构建当前目录的插件客户端代码
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildCurrentPlugin(): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../app/build.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,YAAY;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA0CD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D5E;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA4Df;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKxD"}
|
package/lib/build.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { build, searchForWorkspaceRoot } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
/**
|
|
7
|
+
* 查找插件的客户端入口文件
|
|
8
|
+
* @param pluginRoot 插件根目录
|
|
9
|
+
* @returns 入口文件路径,如果不存在则返回 null
|
|
10
|
+
*/
|
|
11
|
+
function findClientEntry(pluginRoot) {
|
|
12
|
+
const possibleEntries = [
|
|
13
|
+
path.join(pluginRoot, "client/index.tsx"),
|
|
14
|
+
path.join(pluginRoot, "client/index.ts"),
|
|
15
|
+
path.join(pluginRoot, "src/main.tsx"),
|
|
16
|
+
path.join(pluginRoot, "src/main.ts"),
|
|
17
|
+
];
|
|
18
|
+
for (const entry of possibleEntries) {
|
|
19
|
+
if (fs.existsSync(entry)) {
|
|
20
|
+
return entry;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 验证构建环境
|
|
27
|
+
* @param pluginRoot 插件根目录
|
|
28
|
+
* @throws 如果环境不满足构建要求
|
|
29
|
+
*/
|
|
30
|
+
function validateBuildEnvironment(pluginRoot) {
|
|
31
|
+
if (!fs.existsSync(pluginRoot)) {
|
|
32
|
+
throw new Error(`Plugin root directory does not exist: ${pluginRoot}`);
|
|
33
|
+
}
|
|
34
|
+
const entry = findClientEntry(pluginRoot);
|
|
35
|
+
if (!entry) {
|
|
36
|
+
throw new Error(`No client entry file found in ${pluginRoot}. Looking for: client/index.tsx, client/index.ts, src/main.tsx, or src/main.ts`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 构建插件的客户端代码(单文件模式)
|
|
41
|
+
* 用于构建普通插件的 client/index.tsx 文件
|
|
42
|
+
*
|
|
43
|
+
* 策略:将公共依赖配置为 external,运行时从 console 加载的 vendor chunks 中复用
|
|
44
|
+
* @param options 构建选项
|
|
45
|
+
*/
|
|
46
|
+
export async function buildPluginClient(options) {
|
|
47
|
+
const { pluginRoot, outDir = path.join(pluginRoot, "dist"), enableTailwind = true, } = options;
|
|
48
|
+
// 验证构建环境
|
|
49
|
+
validateBuildEnvironment(pluginRoot);
|
|
50
|
+
const entry = findClientEntry(pluginRoot);
|
|
51
|
+
if (!entry) {
|
|
52
|
+
throw new Error(`No client entry file found in ${pluginRoot}`);
|
|
53
|
+
}
|
|
54
|
+
const plugins = [react()];
|
|
55
|
+
if (enableTailwind) {
|
|
56
|
+
plugins.push(tailwindcss());
|
|
57
|
+
}
|
|
58
|
+
// 构建配置 - 库模式
|
|
59
|
+
const clientRoot = path.dirname(entry);
|
|
60
|
+
await build({
|
|
61
|
+
root: clientRoot,
|
|
62
|
+
plugins,
|
|
63
|
+
build: {
|
|
64
|
+
outDir,
|
|
65
|
+
emptyOutDir: true,
|
|
66
|
+
lib: {
|
|
67
|
+
entry,
|
|
68
|
+
formats: ["es"],
|
|
69
|
+
fileName: "index",
|
|
70
|
+
},
|
|
71
|
+
rollupOptions: {
|
|
72
|
+
makeAbsoluteExternalsRelative: true,
|
|
73
|
+
external: [
|
|
74
|
+
'react',
|
|
75
|
+
'react-dom',
|
|
76
|
+
'react/jsx-runtime',
|
|
77
|
+
'clsx',
|
|
78
|
+
'tailwind-merge',
|
|
79
|
+
'lucide-react',
|
|
80
|
+
'@radix-ui/themes'
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
resolve: {
|
|
85
|
+
dedupe: [
|
|
86
|
+
"react",
|
|
87
|
+
"react-dom",
|
|
88
|
+
"clsx",
|
|
89
|
+
"tailwind-merge",
|
|
90
|
+
],
|
|
91
|
+
alias: {
|
|
92
|
+
"@": path.resolve(pluginRoot, "client/src"),
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
console.log(`✅ Plugin client code built successfully: ${outDir}`);
|
|
97
|
+
console.log(`📦 External dependencies will be loaded from console vendor chunks`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 构建 Console 插件的客户端代码(SPA 应用模式)
|
|
101
|
+
* Console 有完整的 index.html 和 src 目录结构
|
|
102
|
+
* @param options Console 构建选项
|
|
103
|
+
*/
|
|
104
|
+
export async function buildConsoleClient(options) {
|
|
105
|
+
const { consoleRoot, outDir = path.join(consoleRoot, "dist") } = options;
|
|
106
|
+
const clientRoot = path.join(consoleRoot, "client");
|
|
107
|
+
// 检查 client 目录是否存在
|
|
108
|
+
if (!fs.existsSync(clientRoot)) {
|
|
109
|
+
throw new Error(`Console client directory does not exist: ${clientRoot}`);
|
|
110
|
+
}
|
|
111
|
+
// 检查 index.html 是否存在
|
|
112
|
+
const indexHtml = path.join(clientRoot, "index.html");
|
|
113
|
+
if (!fs.existsSync(indexHtml)) {
|
|
114
|
+
throw new Error(`index.html not found in: ${clientRoot}`);
|
|
115
|
+
}
|
|
116
|
+
const workspaceRoot = searchForWorkspaceRoot(consoleRoot);
|
|
117
|
+
const consoleClientRoot = path.resolve(workspaceRoot, "plugins/client/client");
|
|
118
|
+
const plugins = [react(), tailwindcss()];
|
|
119
|
+
await build({
|
|
120
|
+
root: clientRoot,
|
|
121
|
+
plugins,
|
|
122
|
+
build: {
|
|
123
|
+
outDir,
|
|
124
|
+
emptyOutDir: true,
|
|
125
|
+
// 设置最小 chunk 大小,避免过度分割
|
|
126
|
+
chunkSizeWarningLimit: 1000,
|
|
127
|
+
// SPA 应用模式,不是库模式
|
|
128
|
+
rollupOptions: {
|
|
129
|
+
input: indexHtml,
|
|
130
|
+
// 保留导出签名
|
|
131
|
+
preserveEntrySignatures: 'strict',
|
|
132
|
+
output: {
|
|
133
|
+
// 确保文件名稳定,不使用哈希,方便插件引用
|
|
134
|
+
chunkFileNames: '[name].js',
|
|
135
|
+
entryFileNames: '[name].js',
|
|
136
|
+
assetFileNames: '[name].[ext]',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
resolve: {
|
|
141
|
+
dedupe: [
|
|
142
|
+
"react",
|
|
143
|
+
"react-dom",
|
|
144
|
+
"clsx",
|
|
145
|
+
"tailwind-merge",
|
|
146
|
+
"@reduxjs/toolkit",
|
|
147
|
+
"react-router",
|
|
148
|
+
"react-redux",
|
|
149
|
+
"redux-persist",
|
|
150
|
+
],
|
|
151
|
+
alias: {
|
|
152
|
+
"@zhin.js/client": consoleClientRoot,
|
|
153
|
+
"@": path.resolve(clientRoot, "src"),
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
console.log(`✅ Console client built successfully: ${outDir}`);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 构建当前目录的插件客户端代码
|
|
161
|
+
*/
|
|
162
|
+
export async function buildCurrentPlugin() {
|
|
163
|
+
const currentDir = process.cwd();
|
|
164
|
+
await buildPluginClient({
|
|
165
|
+
pluginRoot: currentDir,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=build.js.map
|
package/lib/build.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../app/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAkBpB;;;;GAIG;AACH,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,eAAe,GAAG;QACtB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,iBAAiB,CAAC;QACxC,IAAI,CAAC,I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O,CAAC,GAAG,EAAE,CAAC;IACjC,MAAM,iBAAiB,CAAC;QACtB,UAAU,EAAE,UAAU;KACvB,CAAC,CAAC;AACL,CAAC"}
|
package/lib/dev.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ViteDevServer } from "vite";
|
|
2
|
+
export interface DevServerOptions {
|
|
3
|
+
/** 客户端代码根目录 */
|
|
4
|
+
root: string;
|
|
5
|
+
/** 基础路径,默认 /vite/ */
|
|
6
|
+
base?: string;
|
|
7
|
+
/** 是否启用 tailwindcss,默认 true */
|
|
8
|
+
enableTailwind?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 创建 Vite 开发服务器
|
|
12
|
+
* @param options 开发服务器选项
|
|
13
|
+
* @returns Vite 开发服务器实例
|
|
14
|
+
*/
|
|
15
|
+
export declare function createViteDevServer(options: DevServerOptions): Promise<ViteDevServer>;
|
|
16
|
+
//# sourceMappingURL=dev.d.ts.map
|
package/lib/dev.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../app/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,MAAM,CAAC;AAK3E,MAAM,WAAW,gBAAgB;IAC/B,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CA8DxB"}
|
package/lib/dev.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
4
|
+
import path from "path";
|
|
5
|
+
/**
|
|
6
|
+
* 创建 Vite 开发服务器
|
|
7
|
+
* @param options 开发服务器选项
|
|
8
|
+
* @returns Vite 开发服务器实例
|
|
9
|
+
*/
|
|
10
|
+
export async function createViteDevServer(options) {
|
|
11
|
+
const { root, base = "/vite/", enableTailwind = true } = options;
|
|
12
|
+
const plugins = [react()];
|
|
13
|
+
if (enableTailwind) {
|
|
14
|
+
plugins.push(tailwindcss());
|
|
15
|
+
}
|
|
16
|
+
return await await createServer({
|
|
17
|
+
root,
|
|
18
|
+
base,
|
|
19
|
+
plugins: [react(), tailwindcss()],
|
|
20
|
+
server: {
|
|
21
|
+
middlewareMode: true,
|
|
22
|
+
allowedHosts: true,
|
|
23
|
+
fs: {
|
|
24
|
+
strict: false,
|
|
25
|
+
// 添加文件访问过滤,避免访问特殊文件
|
|
26
|
+
allow: [
|
|
27
|
+
// 允许访问的目录
|
|
28
|
+
root,
|
|
29
|
+
searchForWorkspaceRoot(root),
|
|
30
|
+
path.resolve(process.cwd(), 'node_modules'),
|
|
31
|
+
path.resolve(process.cwd(), 'client'),
|
|
32
|
+
path.resolve(process.cwd(), 'src'),
|
|
33
|
+
],
|
|
34
|
+
// 拒绝访问某些文件模式
|
|
35
|
+
deny: [
|
|
36
|
+
'**/.git/**',
|
|
37
|
+
'**/node_modules/.cache/**',
|
|
38
|
+
'**/*.socket',
|
|
39
|
+
'**/*.pipe',
|
|
40
|
+
'**/Dockerfile*',
|
|
41
|
+
'**/.env*',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
resolve: {
|
|
46
|
+
dedupe: [
|
|
47
|
+
"react",
|
|
48
|
+
"react-dom",
|
|
49
|
+
"clsx",
|
|
50
|
+
"tailwind-merge",
|
|
51
|
+
"@reduxjs/toolkit",
|
|
52
|
+
"react-router",
|
|
53
|
+
"react-redux",
|
|
54
|
+
"redux-persist",
|
|
55
|
+
],
|
|
56
|
+
alias: {
|
|
57
|
+
"@zhin.js/client": path.resolve(root, "../../client/client"),
|
|
58
|
+
"@": path.resolve(root, "../client/src"),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
optimizeDeps: {
|
|
62
|
+
include: ["react", "react-dom"],
|
|
63
|
+
},
|
|
64
|
+
build: {
|
|
65
|
+
rollupOptions: {
|
|
66
|
+
input: root + "/index.html",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=dev.js.map
|
package/lib/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../app/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAWxB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAyB;IAEzB,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,EAAE,cAAc,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjE,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1B,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,MAAM,YAAY,CAAC;QAC9B,IAAI;QACJ,IAAI;QACJ,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,EAAE;YACN,cAAc,EAAE,IAAI;YACpB,YAAY,EAAE,IAAI;YAClB,EAAE,EAAE;gBACF,MAAM,EAAE,KAAK;gBACb,oBAAoB;gBACpB,KAAK,EAAE;oBACL,UAAU;oBACV,IAAI;oBACJ,sBAAsB,CAAC,IAAI,CAAC;oBAC5B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;oBAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC;oBACrC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC;iBACnC;gBACD,aAAa;gBACb,IAAI,EAAE;oBACJ,YAAY;oBACZ,2BAA2B;oBAC3B,aAAa;oBACb,WAAW;oBACX,gBAAgB;oBAChB,UAAU;iBACX;aACF;SACF;QACD,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,OAAO;gBACP,WAAW;gBACX,MAAM;gBACN,gBAAgB;gBAChB,kBAAkB;gBAClB,cAAc;gBACd,aAAa;gBACb,eAAe;aAChB;YACD,KAAK,EAAE;gBACL,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC;gBAC5D,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;aACzC;SACF;QACD,YAAY,EAAE;YACZ,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;SAChC;QACD,KAAK,EAAE;YACL,aAAa,EAAE;gBACb,KAAK,EAAE,IAAI,GAAG,aAAa;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../app/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../app/index.ts"],"names":[],"mappings":"AACA,OAAQ,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAQrC,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,aAAa;QACrB,GAAG,EAAE,SAAS,CAAC;KAChB;CACF;AACD,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AACN,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,EAAE,EAAE,eAAe,CAAC;CACrB,CAAC"}
|