wi-chat 0.0.0-stage → 0.3.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/dist/core/index.cjs +2 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +454 -0
- package/dist/core/useAgent.d.ts +35 -0
- package/dist/core/useChat.d.ts +195 -0
- package/dist/core/useChatSession.d.ts +89 -0
- package/dist/core/useHistory.d.ts +63 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +76 -0
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +124 -0
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +72 -0
- package/dist/mobile-ui/chat/types.d.ts +9 -0
- package/dist/mobile-ui/index.cjs +2 -0
- package/dist/mobile-ui/index.d.ts +7 -0
- package/dist/mobile-ui/index.js +218 -0
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +95 -0
- package/dist/mobile-ui/style.css +1 -0
- package/dist/parser/answer.d.ts +51 -0
- package/dist/parser/answerCom/iframePage/parseIframePage.d.ts +49 -0
- package/dist/parser/answerCom/iframePage/types.d.ts +11 -0
- package/dist/parser/answerCom/knowledgeStream/parseKnowledgeStream.d.ts +54 -0
- package/dist/parser/answerCom/knowledgeStream/types.d.ts +27 -0
- package/dist/parser/answerCom/recordset/parseRecordset.d.ts +48 -0
- package/dist/parser/answerCom/recordset/types.d.ts +36 -0
- package/dist/parser/attach/attachActions.d.ts +43 -0
- package/dist/parser/attach/index.d.ts +9 -0
- package/dist/parser/attach/parseAttach.d.ts +27 -0
- package/dist/parser/attach/types.d.ts +48 -0
- package/dist/parser/deepThinking/parseDeepThinking.d.ts +30 -0
- package/dist/parser/deepThinking/types.d.ts +14 -0
- package/dist/parser/history/history.d.ts +54 -0
- package/dist/parser/history/index.d.ts +7 -0
- package/dist/parser/index.cjs +3 -0
- package/dist/parser/index.d.ts +42 -0
- package/dist/parser/index.js +439 -0
- package/dist/parser/message.d.ts +60 -0
- package/dist/parser/registry.d.ts +81 -0
- package/dist/parser/sse.d.ts +34 -0
- package/dist/parser/stream.d.ts +8 -0
- package/dist/renderers/aiAnswer/AiAnswerBubble.vue.d.ts +58 -0
- package/dist/renderers/aiAnswer/contentMap.d.ts +13 -0
- package/dist/renderers/deepThinking/DeepThinkingSteps.vue.d.ts +21 -0
- package/dist/renderers/iframePage/IframePage.vue.d.ts +19 -0
- package/dist/renderers/iframePage/useIframePage.d.ts +64 -0
- package/dist/renderers/index.cjs +2 -0
- package/dist/renderers/index.d.ts +9 -0
- package/dist/renderers/index.js +243 -0
- package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +19 -0
- package/dist/renderers/style.css +1 -0
- package/dist/request/api.d.ts +132 -0
- package/dist/request/client.d.ts +30 -0
- package/dist/request/index.cjs +4 -0
- package/dist/request/index.d.ts +18 -0
- package/dist/request/index.js +264 -0
- package/dist/request/login.d.ts +37 -0
- package/dist/request/ws.d.ts +91 -0
- package/dist/style.css +24 -0
- package/dist/styles/github.css +2 -0
- package/dist/styles/katex.css +2 -0
- package/dist/theme/index.cjs +3 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +37 -0
- package/dist/theme/theme.d.ts +40 -0
- package/dist/tools/attachDownload.d.ts +20 -0
- package/dist/tools/index.cjs +17 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +251 -0
- package/dist/tools/markdown/MarkdownContent.vue.d.ts +36 -0
- package/dist/tools/markdown/imagePreview.d.ts +15 -0
- package/dist/tools/markdown/index.d.ts +5 -0
- package/dist/tools/markdown/renderMarkdown.d.ts +22 -0
- package/dist/tools/markdown/tableDownload.d.ts +14 -0
- package/dist/tools/stream.d.ts +9 -0
- package/dist/tools/style.css +1 -0
- package/dist/tools/useAutoScroll.d.ts +31 -0
- package/dist/web-ui/attach/AttachmentCard.vue.d.ts +91 -0
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +94 -0
- package/dist/web-ui/attach/types.d.ts +5 -0
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +160 -0
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +83 -0
- package/dist/web-ui/chat/types.d.ts +24 -0
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +67 -0
- package/dist/web-ui/envswitch/types.d.ts +22 -0
- package/dist/web-ui/index.cjs +2 -0
- package/dist/web-ui/index.d.ts +14 -0
- package/dist/web-ui/index.js +1034 -0
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +215 -0
- package/dist/web-ui/recordset/RecordsetTable.vue.d.ts +37 -0
- package/dist/web-ui/recordset/webAnswerContentMap.d.ts +9 -0
- package/dist/web-ui/style.css +1 -0
- package/package.json +124 -4
- package/styles/github.css +2 -0
- package/styles/katex.css +2 -0
- package/README.md +0 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ChatAttachment } from './types';
|
|
2
|
+
|
|
3
|
+
/** 常见图片扩展名集合 */
|
|
4
|
+
export declare const IMAGE_EXTENSIONS: Set<string>;
|
|
5
|
+
/**
|
|
6
|
+
* 格式化文件大小为易读字符串(B / KB / MB)
|
|
7
|
+
* @param size 文件大小数值(字节数)
|
|
8
|
+
* @returns 格式化后的字符串,如 "1.2 MB"
|
|
9
|
+
*/
|
|
10
|
+
export declare const formatFileSize: (size: number) => string;
|
|
11
|
+
/**
|
|
12
|
+
* 判断指定附件是否为图片
|
|
13
|
+
* @param item 附件对象
|
|
14
|
+
* @returns 是否为图片
|
|
15
|
+
*/
|
|
16
|
+
export declare const isImageAttachment: (item: ChatAttachment) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 远端文件地址解析内核:绝对地址(http/https)与根相对地址(/ 开头)原样透传,
|
|
19
|
+
* 其余按「base + 端点路径 + file_id」拼接(base 尾斜杠容忍)。
|
|
20
|
+
* 各文件端点共用(附件下载 `/file/download_file`、算法文件 `/algorithm/get_file_data` 等),
|
|
21
|
+
* 收敛"透传 + 拼 base"这一段公共逻辑,端点差异由调用方以 endpointPath 声明。
|
|
22
|
+
* @param fileId 服务端文件 ID(或已是完整地址的值)
|
|
23
|
+
* @param baseURL 后端基础地址(可为空串,得到相对路径)
|
|
24
|
+
* @param endpointPath 端点路径(形如 '/file/download_file')
|
|
25
|
+
* @returns 解析后的完整(或相对)文件地址
|
|
26
|
+
*/
|
|
27
|
+
export declare const resolveRemoteFileUrl: (fileId: string, baseURL: string, endpointPath: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* 解析远端文件下载地址
|
|
30
|
+
* @param fileId 服务端文件ID
|
|
31
|
+
* @param baseURL 后端基础地址(如 https://widev.cpolar.cn/ai_dev)
|
|
32
|
+
* @param customResolver 可选的自定义解析函数
|
|
33
|
+
* @returns 完整文件下载地址
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveAttachDownloadUrl: (fileId?: string, baseURL?: string, customResolver?: (id: string) => string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* 计算附件预览地址(主要用于图片预览)
|
|
38
|
+
* @param item 附件对象
|
|
39
|
+
* @param baseURL 后端基础地址
|
|
40
|
+
* @param customResolver 可选自定义解析函数
|
|
41
|
+
* @returns 可供预览的 URL
|
|
42
|
+
*/
|
|
43
|
+
export declare const resolveAttachPreviewUrl: (item: ChatAttachment, baseURL?: string, customResolver?: (id: string) => string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wi-chat-parser 子包 附件子模块(attach)
|
|
3
|
+
* 含附件数据结构定义、统一附件解析与附件展示/下载层工具。
|
|
4
|
+
*
|
|
5
|
+
* 注意:用具名 re-export 而非 export *,原因同 parser/index.ts 头注释。
|
|
6
|
+
*/
|
|
7
|
+
export { IMAGE_EXTENSIONS, formatFileSize, isImageAttachment, resolveRemoteFileUrl, resolveAttachDownloadUrl, resolveAttachPreviewUrl } from './attachActions';
|
|
8
|
+
export { parseRealtimeAttachment, parseHistoryAttachment, extractHistoryAttachments, normalizeAttachment } from './parseAttach';
|
|
9
|
+
export type { AttachmentType, FileAttachContent, ChatAttachment } from './types';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChatAttachment, FileAttachContent } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 解析实时上传的原生文件(File 或 Blob)
|
|
5
|
+
* @param file 本地文件对象
|
|
6
|
+
* @returns 标准 ChatAttachment 结构
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseRealtimeAttachment: (file: any) => ChatAttachment<FileAttachContent>;
|
|
9
|
+
/**
|
|
10
|
+
* 解析服务端历史明细/回答中的单个附件项
|
|
11
|
+
* @param rawFile 服务端返回的单个文件对象(包含 file_id, file_name, file_content 等)
|
|
12
|
+
* @returns 标准 ChatAttachment 结构
|
|
13
|
+
*/
|
|
14
|
+
export declare const parseHistoryAttachment: (rawFile: any) => ChatAttachment<FileAttachContent>;
|
|
15
|
+
/**
|
|
16
|
+
* 从服务端历史接口返回的原始数据中安全提取全部附件项
|
|
17
|
+
* 兼容 values.attach.files、values.answer.attach.files、values.attach_files 等各种包装格式
|
|
18
|
+
* @param raw 服务端返回的原始 JSON 对象
|
|
19
|
+
* @returns 规范化的 ChatAttachment 列表
|
|
20
|
+
*/
|
|
21
|
+
export declare const extractHistoryAttachments: (raw: any) => ChatAttachment[];
|
|
22
|
+
/**
|
|
23
|
+
* 兜底多态归一化函数:统一收敛任何形态的附件输入(原生 File/Blob、历史对象、或已有 attachContent 的结构)
|
|
24
|
+
* @param input 输入项
|
|
25
|
+
* @returns 标准 ChatAttachment
|
|
26
|
+
*/
|
|
27
|
+
export declare const normalizeAttachment: (input: any) => ChatAttachment;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 提问附件核心类型定义
|
|
3
|
+
* 供解析层(chat-parser)、状态编排层(chat-core)与展示层(chat-web-ui 等)统一使用。
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 附件类型联合类型:
|
|
7
|
+
* - 'file': 普通附件文件(图片、文档、音视频等)
|
|
8
|
+
* - 'table': 业务数据表格(后续扩展)
|
|
9
|
+
* - 'metric': 指标记录(后续扩展)
|
|
10
|
+
*/
|
|
11
|
+
export type AttachmentType = 'file' | 'table' | 'metric' | string;
|
|
12
|
+
/**
|
|
13
|
+
* 文件类型附件的专有内容(type === 'file')
|
|
14
|
+
*/
|
|
15
|
+
export interface FileAttachContent {
|
|
16
|
+
/** 文件名(服务端 file_name 或本地上传文件名) */
|
|
17
|
+
file_name?: string;
|
|
18
|
+
/** 服务端文件ID(远端历史文件) */
|
|
19
|
+
fileId?: string;
|
|
20
|
+
/** 文件大小(数值字节数或已格式化字符串) */
|
|
21
|
+
size?: number | string;
|
|
22
|
+
/** 文件后缀名 / 格式扩展名(如 png、pdf、docx,小写) */
|
|
23
|
+
suffix?: string;
|
|
24
|
+
/** 本地原始 File/Blob 对象(待发送阶段持有) */
|
|
25
|
+
raw?: any;
|
|
26
|
+
/** 可直接访问的图片预览链接(如 blob: 或 http(s):// 或 data:image/*) */
|
|
27
|
+
url?: string;
|
|
28
|
+
/** 文本文件内容或 Base64 内容 */
|
|
29
|
+
fileContent?: string;
|
|
30
|
+
/** 文件大类分类标识,如 'image' | 'file' | 'audio' 等 */
|
|
31
|
+
groupType?: string;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 统一附件数据结构
|
|
36
|
+
* 顶层包含通用字段 name、description、type,不同类型的差异化数据全部收敛于 attachContent。
|
|
37
|
+
*/
|
|
38
|
+
export interface ChatAttachment<T = FileAttachContent | any> {
|
|
39
|
+
/** 附件类型:'file' | 'table' | 'metric' 等,默认 'file' */
|
|
40
|
+
type?: AttachmentType;
|
|
41
|
+
/** 附件名称 / 标题(所有类型通用) */
|
|
42
|
+
name: string;
|
|
43
|
+
/** 附件描述(如 "PNG · 1.2 MB"、"业务表格,10 条记录") */
|
|
44
|
+
description?: string;
|
|
45
|
+
/** 对应不同类型专属的内容数据对象 */
|
|
46
|
+
attachContent?: T;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AiAnswerReport, AiAnswerValues } from '../answer';
|
|
2
|
+
import { StreamChunk } from '../sse';
|
|
3
|
+
import { AnswerParser } from '../registry';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 处理「深度思考」相关的实时流式 chunk,把片段追加到当前 report 的 exec_process 中。
|
|
7
|
+
* 签名对齐 registry 的 `applyChunk` 回调(chunk / reports 在前,answerValues 等尾参按需省略):
|
|
8
|
+
* `reports` 为 registry 预取的 `answerValues.answer.reports` 同一引用,push 即累积。
|
|
9
|
+
* @param chunk 流式数据块
|
|
10
|
+
* @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
|
|
11
|
+
* @returns 是否消费了该 chunk
|
|
12
|
+
*/
|
|
13
|
+
export declare const applyDeepThinkingChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[]) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 从 report 的 exec_process 历史数据中收集「深度思考」展示步骤(markdown 片段数组)。
|
|
16
|
+
* 流式拼接的中间态(streamContent / collecting)仅存在于解析层,返回时已算好,UI 不再参与拼接。
|
|
17
|
+
*/
|
|
18
|
+
export declare const collectDeepThinkingSteps: (report: AiAnswerReport<any>) => string[];
|
|
19
|
+
/**
|
|
20
|
+
* 从一份回答的整体数据里收集全部思考展示步骤(跨所有 report 聚合)。
|
|
21
|
+
* 供消息组装层(history / useChat)在生成 AssistantMessage 时提前算好 `thinking.steps`,
|
|
22
|
+
* 渲染组件只消费已算好的文本数组,不再内部拼接。
|
|
23
|
+
*/
|
|
24
|
+
export declare const collectThinkingSteps: (answerValues: AiAnswerValues) => string[];
|
|
25
|
+
/**
|
|
26
|
+
* 深度思考答案类型的注册表条目(registry 内置,实时链路):
|
|
27
|
+
* 历史形态与实时累积一致(exec_process 原样保留、无需归一化),
|
|
28
|
+
* 故不设 answerType / normalizeReport,不参与历史分发。
|
|
29
|
+
*/
|
|
30
|
+
export declare const deepThinkingParser: AnswerParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deepThinking 答案类型的类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 执行过程中的一条步骤项(深度思考 / 流式过程的原始片段)
|
|
6
|
+
*/
|
|
7
|
+
export interface ExecProcessItem {
|
|
8
|
+
/** 步骤类型(begin / begin_stream / send_stream / end_stream 等) */
|
|
9
|
+
mode?: string;
|
|
10
|
+
/** 子类型(部分事件携带) */
|
|
11
|
+
type?: string;
|
|
12
|
+
/** 步骤载荷(多为文本增量) */
|
|
13
|
+
value?: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ChatApi, HistoryGroup } from 'wi-chat/request';
|
|
2
|
+
import { ChatAttachment, Message } from '../message';
|
|
3
|
+
import { AnswerParseOptions } from '../registry';
|
|
4
|
+
|
|
5
|
+
export type { HistoryGroup };
|
|
6
|
+
/** 从历史接口原始数据中提取提问携带的附件列表(已委托给 attach 模块统一解析) */
|
|
7
|
+
export declare const extractAttachmentsFromHistory: (raw: any) => ChatAttachment[];
|
|
8
|
+
/** 拉取历史分组列表(按 create_time 降序:最新创建的组排最上面) */
|
|
9
|
+
export declare const getHistoryGroups: (api: ChatApi) => Promise<HistoryGroup[]>;
|
|
10
|
+
/** 创建历史分组,返回分组 id */
|
|
11
|
+
export declare const createHistoryGroup: (api: ChatApi, groupTitle: string) => Promise<string>;
|
|
12
|
+
/** 删除历史分组 */
|
|
13
|
+
export declare const deleteHistoryGroup: (api: ChatApi, groupId: string) => Promise<any>;
|
|
14
|
+
/** 修改分组标题 */
|
|
15
|
+
export declare const setHistoryGroupTitle: (api: ChatApi, groupId: string, title: string) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* 按分组加载会话消息列表(user + assistant 交错;回答有限并发拉取)。
|
|
18
|
+
* @param api 业务 API
|
|
19
|
+
* @param historyGroupId 历史分组 id
|
|
20
|
+
* @param lastCount 拉取最近条数,默认 10
|
|
21
|
+
* @param lastEnd 起始明细序号(向上翻页),默认 0 = 最近一页
|
|
22
|
+
* @param options 答案解析配置(beforeKnowledgeRender + 自定义 parsers,透传给 normalizeAnswer)
|
|
23
|
+
* @returns 交错完整的消息列表
|
|
24
|
+
*/
|
|
25
|
+
export declare const loadGroupMessages: (api: ChatApi, historyGroupId: string, lastCount?: number, lastEnd?: number, options?: AnswerParseOptions) => Promise<Message[]>;
|
|
26
|
+
/**
|
|
27
|
+
* 历史加载进度回调负荷:
|
|
28
|
+
* - `{ type: 'users' }`:分组明细已经就绪(user 提问全部可见),先把提问渲染出来,不等回答;
|
|
29
|
+
* - `{ type: 'assistant' }`:单条回答(get_history_answer)已就绪,按 `user.id` 归位填进对应空位。
|
|
30
|
+
* 该回调使 UI 层可"插空式"渐进渲染:query_history_detail 先返回、get_history_answer 后逐个到达。
|
|
31
|
+
*/
|
|
32
|
+
export type GroupMessagesProgress = {
|
|
33
|
+
type: 'users';
|
|
34
|
+
users: Message[];
|
|
35
|
+
} | {
|
|
36
|
+
type: 'assistant';
|
|
37
|
+
/** 该记录在 query_history_detail 中的槽位序(0 起),消费方按此槽位回填、避免依赖 user.id 匹配 */
|
|
38
|
+
index: number;
|
|
39
|
+
user: Message;
|
|
40
|
+
assistant: Message;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* 渐进版 loadGroupMessages:作用等同于 loadGroupMessages(返回最终交错完整 Message[]),
|
|
44
|
+
* 但会通过 onProgress 在"明细就绪 / 单条回答就绪"两个时点进行增量通知,供消费方先显示用户提问、
|
|
45
|
+
* 再按到达顺序把回答逐条填进对应位置,从而不必等 `history/get_history_answer` 全部返回才渲染。
|
|
46
|
+
* @param api 业务 API
|
|
47
|
+
* @param historyGroupId 历史分组 id
|
|
48
|
+
* @param lastCount 拉取最近条数,默认 10
|
|
49
|
+
* @param onProgress 增量通知回调(users / assistant 两个时点)
|
|
50
|
+
* @param lastEnd 起始明细序号(向上翻页),默认 0 = 最近一页
|
|
51
|
+
* @param options 答案解析配置(beforeKnowledgeRender + 自定义 parsers,透传给 normalizeAnswer)
|
|
52
|
+
* @returns 交错完整的消息列表
|
|
53
|
+
*/
|
|
54
|
+
export declare const loadGroupMessagesByStep: (api: ChatApi, historyGroupId: string, lastCount?: number, onProgress?: (progress: GroupMessagesProgress) => void, lastEnd?: number, options?: AnswerParseOptions) => Promise<Message[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* history 模块 —— 历史分组业务逻辑
|
|
3
|
+
*
|
|
4
|
+
* 注意:用具名 re-export 而非 export *,原因同 parser/index.ts 头注释。
|
|
5
|
+
*/
|
|
6
|
+
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';
|
|
7
|
+
export type { GroupMessagesProgress, HistoryGroup } from './history';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),M=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),P=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),oe=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],z=(e,t,n,r)=>{var u;if(!e.mode||!oe.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const s=r==null?void 0:r.beforeKnowledgeRender,o=l=>s?s(l):l;if(e.mode==="knowledge_stream_begin"){const l=t.at(-1);return(l==null?void 0:l.answer_type)==="knowledge_stream_result"?(l.values=l.values??[],l.values.push({answer:""}),!0):l&&!l.answer_type?(M(l),!0):(t.push($()),!0)}if(e.mode!=="knowledge_stream")return!1;let i=t.at(-1);i&&!i.answer_type?i=M(i):(!i||i.answer_type!=="knowledge_stream_result")&&(i=$(),t.push(i)),i.values=(u=i.values)!=null&&u.length?i.values:[{answer:""}];const a=i.values[i.values.length-1],c=`${a.raw??""}${e.value||""}`;return a.raw=c,a.answer=o(c),!0},O=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=o=>n?n(o):o;let s=[];return Array.isArray(e.knowledge)&&(s=e.knowledge.map(o=>typeof o=="string"?o:o==null?void 0:o.answer).filter(o=>typeof o=="string"&&o!=="")),s.length===0&&typeof e.answer=="string"&&e.answer!==""&&(s=[e.answer]),s.length&&(e.values=s.map(o=>({answer:r(o),raw:o}))),e},x={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:z,normalizeReport:O},N=["begin","begin_stream","send_stream","end_stream"],L=(e,t)=>{if(!N.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},H=e=>{const t=[];let n="",r=!1;for(const s of(e.exec_process??[]).filter(o=>N.includes(o.mode||""))){const o=typeof s.value=="string"?s.value:"";s.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",o.trim()&&t.push(o.trim())):s.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=o):s.mode==="send_stream"&&r?n+=o:s.mode==="end_stream"&&r&&(n+=o,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},S=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(H)},D={id:"deep_thinking",applyChunk:L},B='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',se="iframe-resizer/child 5.1.5",ie=B,b=`<script>${B}<\/script>`,ae=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),U=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=o=>{const i=t&&typeof t=="object"?t[o]:void 0;if(typeof i=="string"&&i)return i;const a=e[o];return typeof a=="string"&&a?a:void 0},r=n("url"),s=n("srcdoc");return{...r?{url:r}:{},...s?{srcdoc:s}:{}}},_=e=>e&&(e.includes("</head>")?e.replace("</head>",`${b}</head>`):e.includes("<body")?e.replace("<body",`${b}<body`):b+e),ce=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(se),W=(e,t)=>{if(e.mode!=="result"||ae(e.value)!=="url")return!1;const n=U(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=_(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},G=e=>{if(ce(e.values))return e;const t=U(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=_(t.srcdoc)),e.values=t),e},K={id:"iframe_page",answerType:"url",applyChunk:W,normalizeReport:G},y="recordset",le=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],ue=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),g=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),q=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(g(t))return t;if(g(e))return e},X=(e,t)=>{if(e.mode!=="result"||ue(e.value)!==y)return!1;const n=q(e.value);return n&&t.push({answer_type:y,values:n}),!0},V=e=>{if(g(e.values))return e;const t=e;if(!g(t))return e;const n={};for(const r of le)n[r]=t[r];return e.values=n,e},J={id:"recordset",answerType:y,applyChunk:X,normalizeReport:V},w=[D,x,K,J],de=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...w,...t]:w},me=(e,t,n)=>{var i;const r=(i=e.answer)==null?void 0:i.reports;if(!r)return[];const s=new Set(((n==null?void 0:n.parsers)??[]).filter(a=>a.applyChunk&&a.answerType).map(a=>a.answerType)),o=[];for(const a of de(n))a.applyChunk&&(w.includes(a)&&a.answerType&&s.has(a.answerType)||a.applyChunk(t,r,e,n)&&o.push(a.id));return o},Z=(e,t)=>{var o;const n=e.answer_type;if(!n)return;const s=((t==null?void 0:t.parsers)??[]).find(i=>i.answerType===n&&!!i.normalizeReport)??w.find(i=>i.answerType===n&&!!i.normalizeReport);(o=s==null?void 0:s.normalizeReport)==null||o.call(s,e,t)},A=(e,t="",n="",r)=>{var i;const s=(e==null?void 0:e.values)??e;if((i=s==null?void 0:s.answer)!=null&&i.reports){const a=s;for(const c of a.answer.reports)Z(c,r);return a}const o=P(t,n);return typeof s=="string"&&z({mode:"knowledge_stream",value:s},o.answer.reports,o,r),o},fe={User:"user",Assistant:"assistant"};let pe=0;const E=(e="msg")=>`${e}-${++pe}`,Y=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Q=()=>{let e="";return{push(t){const n=(e+t).split(`
|
|
2
|
+
`);return e=n.pop()||"",n},flush(){const t=e;return e="",t?[t]:[]}}},he=async(e,t)=>{const n=e.getReader(),r=new TextDecoder,s=Q(),o=i=>{const a=Y(i);a&&t(a)};try{for(;;){const{done:i,value:a}=await n.read();if(i)break;s.push(r.decode(a,{stream:!0})).forEach(o)}s.flush().forEach(o)}catch(i){throw await n.cancel().catch(()=>{}),i}finally{n.releaseLock()}},h=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),C=e=>!e||isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,ye=e=>{var r;if(e.type&&e.type!=="file")return!1;const t=e.attachContent||{};if(t.groupType==="image")return!0;const n=(t.suffix||((r=e.name)!=null&&r.includes(".")?e.name.split(".").pop():"")||"").toLowerCase();return!!(h.has(n)||t.raw&&typeof t.raw.type=="string"&&t.raw.type.startsWith("image/"))},F=(e,t,n)=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`${(t||"").replace(/\/$/,"")}${n}?file_id=${e}`,ee=(e,t="",n)=>e?n?n(e):F(e,t,"/file/download_file"):"",ge=(e,t="",n)=>{const r=e.attachContent||{};return r.url?r.url:typeof r.fileContent=="string"&&r.fileContent.startsWith("data:image/")?r.fileContent:r.fileId?ee(r.fileId,t,n):""},v=e=>{var a;const t=(e==null?void 0:e.name)||"",n=t.includes(".")&&((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"",r=h.has(n)||(e==null?void 0:e.type)&&typeof e.type=="string"&&e.type.startsWith("image/");let s;if(r&&typeof window<"u"&&typeof URL<"u"&&e instanceof Blob)try{s=URL.createObjectURL(e)}catch{s=void 0}const o=C(e==null?void 0:e.size),i=[n.toUpperCase(),o].filter(Boolean).join(" · ");return{type:"file",name:t,description:i,attachContent:{file_name:t,size:e==null?void 0:e.size,suffix:n,raw:e,url:s,groupType:r?"image":"file"}}},R=e=>{var o;const t=(e==null?void 0:e.file_name)??(e==null?void 0:e.name)??(e==null?void 0:e.title)??"",n=t.includes(".")&&((o=t.split(".").pop())==null?void 0:o.toLowerCase())||"",r=h.has(n)||(e==null?void 0:e.groupType)==="image",s=n?n.toUpperCase():"";return{type:"file",name:t,description:s,attachContent:{file_name:(e==null?void 0:e.file_name)??t,fileId:(e==null?void 0:e.file_id)??(e==null?void 0:e.id),fileContent:e==null?void 0:e.file_content,suffix:n,groupType:r?"image":"file"}}},te=e=>{var r,s,o,i;const t=(e==null?void 0:e.values)??e,n=((r=t==null?void 0:t.attach)==null?void 0:r.files)??((o=(s=t==null?void 0:t.answer)==null?void 0:s.attach)==null?void 0:o.files)??(t==null?void 0:t.attach_files)??((i=t==null?void 0:t.answer)==null?void 0:i.attach_files)??[];return!Array.isArray(n)||n.length===0?[]:n.map(a=>R(a))},we=e=>{var r,s;if(!e)return{type:"file",name:"",description:"",attachContent:{}};if(typeof Blob<"u"&&e instanceof Blob)return v(e);if(typeof e=="object"&&e.attachContent){const o=e.type||"file",i=e.name||e.attachContent.file_name||e.attachContent.name||"";let a=e.description||"";const c={...e.attachContent};if(o==="file"&&(!c.suffix&&i.includes(".")&&(c.suffix=((r=i.split(".").pop())==null?void 0:r.toLowerCase())||""),(c.groupType==="image"||c.suffix&&h.has(c.suffix.toLowerCase())||c.raw&&typeof c.raw.type=="string"&&c.raw.type.startsWith("image/"))&&(c.groupType="image"),!a)){const l=typeof c.size=="number"?C(c.size):c.size||"";a=[c.suffix?c.suffix.toUpperCase():"",l].filter(Boolean).join(" · ")}return{...e,type:o,name:i,description:a,attachContent:c}}if(e.file_id||e.fileId)return R(e);if(e.raw&&typeof Blob<"u"&&e.raw instanceof Blob){const o=v(e.raw);return{...o,...e,attachContent:{...o.attachContent,...e.attachContent}}}const t=e.name||e.title||"",n=t.includes(".")&&((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"";return{type:e.type||"file",name:t,description:e.description||(n?n.toUpperCase():""),attachContent:{file_name:t,suffix:n,...e}}},T=e=>te(e),be=async e=>[...(await e.getHistoryGroups()).groups??[]].sort((r,s)=>String(s.create_time??"").localeCompare(String(r.create_time??""))),ve=async(e,t)=>{const n=await e.createHistoryGroup(t),r=(n==null?void 0:n.group_id)??(n==null?void 0:n.history_group_id)??"";if(!r)throw new Error("创建对话分组失败");return r},ze=(e,t)=>e.deleteHistoryGroup(t),Se=(e,t,n)=>e.setHistoryGroupTitle(t,n),ne=5,re=async(e,t,n)=>{const r=new Array(e.length);let s=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;s<e.length;){const i=s++;r[i]=await n(e[i],i)}});return await Promise.all(o),r},_e=async(e,t,n=10,r=0,s)=>{if(!t)return[];const i=[...await e.getHistoryDetail(t,r,n)].sort((u,l)=>String(u.create_time||"").localeCompare(String(l.create_time||""))),a=await re(i,ne,async u=>{try{return await e.getHistoryAnswer(u.history_id||"")}catch{return null}}),c=[];return i.forEach((u,l)=>{const p=u.history_id||E("h"),d=a[l],m=d!=null?T(d):[];if(c.push({id:p,historyId:u.history_id,role:"user",content:u.question??"",attachments:m.length>0?m:void 0}),d!=null){const f=A(d,p,u.question??"",s);c.push({id:`${p}-answer`,historyId:u.history_id,role:"assistant",answer:f,error:!1,stopped:!1,thinking:{steps:S(f),expanded:!1}})}}),c},Ae=async(e,t,n=10,r,s=0,o)=>{if(!t)return r==null||r({type:"users",users:[]}),[];const a=[...await e.getHistoryDetail(t,s,n)].sort((d,m)=>String(d.create_time||"").localeCompare(String(m.create_time||""))),c=a.map(d=>d.history_id||E("h")),u=a.map((d,m)=>({id:c[m],historyId:d.history_id,role:"user",content:d.question??""}));r==null||r({type:"users",users:u});const l=new Array(a.length).fill(null);await re(a,ne,async(d,m)=>{let f=null;try{f=await e.getHistoryAnswer(d.history_id||"")}catch{f=null}if(f==null)return;const I=T(f);I.length>0&&(u[m].attachments=I);const j=A(f,c[m],d.question??"",o),k={id:`${c[m]}-answer`,historyId:d.history_id,role:"assistant",answer:j,error:!1,stopped:!1,thinking:{steps:S(j),expanded:!1}};l[m]=k,r==null||r({type:"assistant",index:m,user:u[m],assistant:k})});const p=[];return a.forEach((d,m)=>{p.push(u[m]);const f=l[m];f&&p.push(f)}),p};exports.IFRAME_RESIZER_CHILD_SCRIPT=ie;exports.IMAGE_EXTENSIONS=h;exports.RECORDSET_ANSWER_TYPE=y;exports.RoleEnum=fe;exports.applyAnswerChunk=me;exports.applyDeepThinkingChunk=L;exports.applyIframePageChunk=W;exports.applyKnowledgeStreamChunk=z;exports.applyRecordsetChunk=X;exports.collectDeepThinkingSteps=H;exports.collectThinkingSteps=S;exports.consumeStream=he;exports.createEmptyAnswerValues=P;exports.createHistoryGroup=ve;exports.createLineSplitter=Q;exports.deepThinkingParser=D;exports.deleteHistoryGroup=ze;exports.extractAttachmentsFromHistory=T;exports.extractHistoryAttachments=te;exports.formatFileSize=C;exports.getHistoryGroups=be;exports.iframePageParser=K;exports.injectIframeResizerScript=_;exports.isImageAttachment=ye;exports.knowledgeStreamParser=x;exports.loadGroupMessages=_e;exports.loadGroupMessagesByStep=Ae;exports.nextLocalMessageId=E;exports.normalizeAnswer=A;exports.normalizeAnswerReport=Z;exports.normalizeAttachment=we;exports.normalizeIframePageReport=G;exports.normalizeKnowledgeStreamReport=O;exports.normalizeRecordsetReport=V;exports.parseHistoryAttachment=R;exports.parseRealtimeAttachment=v;exports.parseSseLine=Y;exports.readRecordsetPayload=q;exports.recordsetParser=J;exports.resolveAttachDownloadUrl=ee;exports.resolveAttachPreviewUrl=ge;exports.resolveRemoteFileUrl=F;exports.setHistoryGroupTitle=Se;
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wi-chat-parser —— 内容解析
|
|
3
|
+
* 把服务端 / AI 返回的原始内容解析成统一的结构化数据。
|
|
4
|
+
*
|
|
5
|
+
* 组织:
|
|
6
|
+
* - 公共回答类型 / 聚合解析:`./answer`
|
|
7
|
+
* - 答案类型解析注册表(实时/历史双链路,AnswerParser 实例注入):`./registry`
|
|
8
|
+
* - 消息类型(对话 / 历史共用):`./message`
|
|
9
|
+
* - 流式解析(含 StreamChunk):`./sse`
|
|
10
|
+
* - SSE 字节流消费(consumeStream,依赖 WHATWG ReadableStream):`./stream`
|
|
11
|
+
* - 各答案类型的解析与专属类型按子目录收敛(answerCom / deepThinking / history 平级):
|
|
12
|
+
* - `./answerCom`:回答内容组件,每个组件一个子目录:
|
|
13
|
+
* - `./answerCom/knowledgeStream`:知识流(applyKnowledgeStreamChunk / createEmptyAnswerValues / types)
|
|
14
|
+
* - `./answerCom/iframePage`:iframe 页面(applyIframePageChunk / 注入 child 脚本 / types)
|
|
15
|
+
* - `./answerCom/recordset`:记录集表格(applyRecordsetChunk / normalizeRecordsetReport / types)
|
|
16
|
+
* - `./deepThinking`:思考(applyDeepThinkingChunk / collectDeepThinkingSteps / types)
|
|
17
|
+
* - `./history`:历史分组与会话的业务逻辑(依赖 wi-chat-request)
|
|
18
|
+
*
|
|
19
|
+
* 注意:全部用具名 re-export 而非 export *——TS < 5.0 的 nodenext 下 star 转发成员
|
|
20
|
+
* 不物化(消费端报 TS2305),且 vite/esbuild 隔离转译要求类型显式标注 export type。
|
|
21
|
+
*/
|
|
22
|
+
export { normalizeAnswer } from './answer';
|
|
23
|
+
export type { AiAnswerReport, AiAnswerValues } from './answer';
|
|
24
|
+
export { applyAnswerChunk, normalizeAnswerReport } from './registry';
|
|
25
|
+
export type { AnswerParser, AnswerParseOptions } from './registry';
|
|
26
|
+
export { RoleEnum, nextLocalMessageId } from './message';
|
|
27
|
+
export type { Role, UserMessage, AssistantMessage, Message } from './message';
|
|
28
|
+
export { parseSseLine, createLineSplitter } from './sse';
|
|
29
|
+
export type { StreamChunk, LineSplitter } from './sse';
|
|
30
|
+
export { consumeStream } from './stream';
|
|
31
|
+
export { IMAGE_EXTENSIONS, formatFileSize, isImageAttachment, resolveRemoteFileUrl, resolveAttachDownloadUrl, resolveAttachPreviewUrl, parseRealtimeAttachment, parseHistoryAttachment, extractHistoryAttachments, normalizeAttachment } from './attach';
|
|
32
|
+
export type { ChatAttachment, FileAttachContent, AttachmentType } from './attach';
|
|
33
|
+
export { createEmptyAnswerValues, applyKnowledgeStreamChunk, normalizeKnowledgeStreamReport, knowledgeStreamParser } from './answerCom/knowledgeStream/parseKnowledgeStream';
|
|
34
|
+
export type { KnowledgeStreamValue, BeforeKnowledgeRender, KnowledgeRenderOptions } from './answerCom/knowledgeStream/types';
|
|
35
|
+
export { IFRAME_RESIZER_CHILD_SCRIPT, injectIframeResizerScript, applyIframePageChunk, normalizeIframePageReport, iframePageParser } from './answerCom/iframePage/parseIframePage';
|
|
36
|
+
export type { IframePageValue } from './answerCom/iframePage/types';
|
|
37
|
+
export { RECORDSET_ANSWER_TYPE, readRecordsetPayload, applyRecordsetChunk, normalizeRecordsetReport, recordsetParser } from './answerCom/recordset/parseRecordset';
|
|
38
|
+
export type { RecordsetColumn, RecordsetValue } from './answerCom/recordset/types';
|
|
39
|
+
export { applyDeepThinkingChunk, collectDeepThinkingSteps, collectThinkingSteps, deepThinkingParser } from './deepThinking/parseDeepThinking';
|
|
40
|
+
export type { ExecProcessItem } from './deepThinking/types';
|
|
41
|
+
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';
|
|
42
|
+
export type { GroupMessagesProgress, HistoryGroup } from './history';
|